org.atmosphere.samples.pubsub
Class PubSub

java.lang.Object
  extended by org.atmosphere.samples.pubsub.PubSub

public class PubSub
extends Object

Simple PubSub resource that demonstrate many functionality supported by Atmosphere.

Author:
Jeanfrancois Arcand

Constructor Summary
PubSub()
           
 
Method Summary
 org.atmosphere.jersey.Broadcastable aggregate(String message)
          Retain Broadcast events until we have enough data.
 org.atmosphere.jersey.Broadcastable buffer(String message)
          Buffer the first broadcast events until the second one happens.
 org.atmosphere.jersey.Broadcastable delayPublish(String message)
          Delay for 5 seconds the executionof Broadcaster.broadcast(java.lang.Object) operation
 org.atmosphere.jersey.Broadcastable delayPublishAndResume(String message)
           
 org.atmosphere.jersey.Broadcastable delaySchedule(String message)
          Wait 5 seconds and then execute periodic Broadcaster.broadcast(java.lang.Object) operations.
 String manualDelayBroadcast(String message)
          Use the Broadcaster.delayBroadcast(java.lang.Object) directly instead of using the annotation.
 org.atmosphere.jersey.Broadcastable publish(String message)
          Broadcast messahge to this server and also to other server using JGroups
 org.atmosphere.jersey.Broadcastable publishWithXML(String message)
          ' Broadcast XML data using JAXB
 org.atmosphere.jersey.Broadcastable schedule(String message)
          Execute periodic Broadcaster.broadcast(java.lang.Object) operation.
 org.atmosphere.jersey.Broadcastable scheduleAndResume(String message)
          Execute periodic Broadcaster.broadcast(java.lang.Object) operation and resume the suspended connection after the first broadcast operation.
 org.atmosphere.jersey.Broadcastable subscribe()
          Suspend the response, and register a AtmosphereResourceEventListener that get notified when events occurs like client disconnection, broadcast or when the response get resumed.
 org.atmosphere.jersey.Broadcastable subscribeAndResume()
          Suspend the response, and tell teh framework to resume the response when the first @Broadcast operation occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PubSub

public PubSub()
Method Detail

subscribe

@Suspend(listeners=org.atmosphere.commons.util.EventsLogger.class)
public org.atmosphere.jersey.Broadcastable subscribe()
Suspend the response, and register a AtmosphereResourceEventListener that get notified when events occurs like client disconnection, broadcast or when the response get resumed.

Returns:
A Broadcastable used to broadcast events.

subscribeAndResume

@Suspend(resumeOnBroadcast=true,
         listeners=org.atmosphere.commons.util.EventsLogger.class)
public org.atmosphere.jersey.Broadcastable subscribeAndResume()
Suspend the response, and tell teh framework to resume the response when the first @Broadcast operation occurs.

Returns:
A Broadcastable used to broadcast events.

publishWithXML

public org.atmosphere.jersey.Broadcastable publishWithXML(String message)
' Broadcast XML data using JAXB

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

publish

@Cluster(name="chat",
         value=org.atmosphere.plugin.cluster.jgroups.JGroupsFilter.class)
public org.atmosphere.jersey.Broadcastable publish(String message)
Broadcast messahge to this server and also to other server using JGroups

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

aggregate

public org.atmosphere.jersey.Broadcastable aggregate(String message)
Retain Broadcast events until we have enough data. See the StringFilterAggregator to configure the amount of data buffered before the events gets written back to the set of suspended response.

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

scheduleAndResume

public org.atmosphere.jersey.Broadcastable scheduleAndResume(String message)
Execute periodic Broadcaster.broadcast(java.lang.Object) operation and resume the suspended connection after the first broadcast operation.

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

delaySchedule

public org.atmosphere.jersey.Broadcastable delaySchedule(String message)
Wait 5 seconds and then execute periodic Broadcaster.broadcast(java.lang.Object) operations.

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

schedule

public org.atmosphere.jersey.Broadcastable schedule(String message)
Execute periodic Broadcaster.broadcast(java.lang.Object) operation.

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

delayPublish

public org.atmosphere.jersey.Broadcastable delayPublish(String message)
Delay for 5 seconds the executionof Broadcaster.broadcast(java.lang.Object) operation

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

delayPublishAndResume

public org.atmosphere.jersey.Broadcastable delayPublishAndResume(String message)

buffer

public org.atmosphere.jersey.Broadcastable buffer(String message)
Buffer the first broadcast events until the second one happens.

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.

manualDelayBroadcast

public String manualDelayBroadcast(String message)
Use the Broadcaster.delayBroadcast(java.lang.Object) directly instead of using the annotation.

Parameters:
message - A String from an HTML form
Returns:
A Broadcastable used to broadcast events.


Copyright © 2010 SUN Microsystems. All Rights Reserved.