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
 Broadcastable aggregate(String message)
          Retain Broadcast events until we have enough data.
 Broadcastable buffer(String message)
          Buffer the first broadcast events until the second one happens.
 Broadcastable delayPublish(String message)
          Delay for 5 seconds the executionof Broadcaster.broadcast(java.lang.Object) operation
 Broadcastable delayPublishAndResume(String message)
           
 Broadcastable delaySchedule(String message)
          Wait 5 seconds and then execute periodic Broadcaster.broadcast(java.lang.Object) operations.
 void destroy()
           
 String manualDelayBroadcast(String message)
          Use the Broadcaster.delayBroadcast(java.lang.Object) directly instead of using the annotation.
 Broadcastable publish(String message)
          Broadcast messahge to this server and also to other server using JGroups
 Broadcastable publishWithXML(String message)
          ' Broadcast XML data using JAXB
 Broadcastable schedule(String message)
          Execute periodic Broadcaster.broadcast(java.lang.Object) operation.
 Broadcastable scheduleAndResume(String message)
          Execute periodic Broadcaster.broadcast(java.lang.Object) operation and resume the suspended connection after the first broadcast operation.
 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.
 Broadcastable subscribeAndResume()
          Suspend the response, and tell teh framework to resume the response \ when the first @Broadcast operation occurs.
 String subscribeAndResumeUsingExternalThread(String topic)
          Suspend the response, and register a AtmosphereResourceEventListener that get notified when events occurs like client disconnection, broadcast or when the response get resumed.
 
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

destroy

@PreDestroy
public void destroy()

subscribe

@Suspend(listeners=EventsLogger.class)
public 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.

subscribeAndResumeUsingExternalThread

@Suspend(resumeOnBroadcast=true,
         listeners=EventsLogger.class)
public String subscribeAndResumeUsingExternalThread(String topic)
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=EventsLogger.class)
public 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 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

public 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 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 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 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 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 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 Broadcastable delayPublishAndResume(String message)

buffer

public 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 © 2011. All Rights Reserved.