org.atmosphere.handler
Class AbstractReflectorAtmosphereHandler

java.lang.Object
  extended by org.atmosphere.handler.AbstractReflectorAtmosphereHandler
All Implemented Interfaces:
AtmosphereHandler, AtmosphereServletProcessor
Direct Known Subclasses:
AbstractReflectorAtmosphereHandler.Default, ManagedAtmosphereHandler, OnMessage, ReflectorServletProcessor

public abstract class AbstractReflectorAtmosphereHandler
extends Object
implements AtmosphereServletProcessor

Simple AtmosphereHandler that reflect every call to Broadcaster.broadcast(java.lang.Object), eg sent the broadcasted event back to the remote client. All broadcasts will be by default returned as it is to the suspended AtmosphereResponse.getOutputStream() or AtmosphereResponse.getWriter().

Author:
Jean-francois Arcand

Nested Class Summary
static class AbstractReflectorAtmosphereHandler.Default
           This default implementation does nothing when AbstractReflectorAtmosphereHandler.Default.onRequest(org.atmosphere.cpr.AtmosphereResource) is called.
 
Constructor Summary
AbstractReflectorAtmosphereHandler()
           
 
Method Summary
 void destroy()
          Destroy this handler
 void init(AtmosphereConfig config)
          Initialize the AtmosphereServletProcessor using the ServletConfig.
 void onStateChange(AtmosphereResourceEvent event)
          Write the AtmosphereResourceEvent.getMessage() back to the client using the AtmosphereResponse.getOutputStream() or AtmosphereResponse.getWriter().
protected  void postStateChange(AtmosphereResourceEvent event)
          Inspect the event and decide if the underlying connection must be resumed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.atmosphere.cpr.AtmosphereHandler
onRequest
 

Constructor Detail

AbstractReflectorAtmosphereHandler

public AbstractReflectorAtmosphereHandler()
Method Detail

onStateChange

public void onStateChange(AtmosphereResourceEvent event)
                   throws IOException
Write the AtmosphereResourceEvent.getMessage() back to the client using the AtmosphereResponse.getOutputStream() or AtmosphereResponse.getWriter(). If a Serializer is defined, it will be invoked and the write operation will be delegated to it.

By default, this method will try to use AtmosphereResponse.getWriter().

Specified by:
onStateChange in interface AtmosphereHandler
Parameters:
event - the AtmosphereResourceEvent.getMessage()
Throws:
IOException

postStateChange

protected final void postStateChange(AtmosphereResourceEvent event)
Inspect the event and decide if the underlying connection must be resumed.

Parameters:
event -

destroy

public void destroy()
Description copied from interface: AtmosphereHandler
Destroy this handler

Specified by:
destroy in interface AtmosphereHandler

init

public void init(AtmosphereConfig config)
          throws javax.servlet.ServletException
Description copied from interface: AtmosphereServletProcessor
Initialize the AtmosphereServletProcessor using the ServletConfig.

Specified by:
init in interface AtmosphereServletProcessor
Parameters:
config - the ServletConfig
Throws:
javax.servlet.ServletException


Copyright © 2015. All Rights Reserved.