org.atmosphere.interceptor
Class AtmosphereResourceLifecycleInterceptor

java.lang.Object
  extended by org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor
All Implemented Interfaces:
AtmosphereInterceptor

public class AtmosphereResourceLifecycleInterceptor
extends Object
implements AtmosphereInterceptor

This AtmosphereInterceptor implementation automatically suspends the intercepted AtmosphereResource and takes care of managing the response's state (flushing, resuming, etc.) when a Broadcaster.broadcast(java.lang.Object) is invoked. When used, AtmosphereHandler implementations no longer need to make calls to AtmosphereResource.suspend().

If your application doesn't use Broadcaster, this interceptor will not work and you need to programmatically resume, flush, etc.

By default, intercepted AtmosphereResource instances are suspended when a GET request is received. You can change the triggering http method by configuring ApplicationConfig.ATMOSPHERERESOURCE_INTERCEPTOR_METHOD

Use this class when you don't want to manage the suspend/resume operation from your particular Atmosphere framework implementation classes (AtmosphereHandler, WebSocketHandler, or Meteor instances) or extensions (GWT, Jersey, Wicket, etc...)

For this mechanism to work properly, each client must set the HeaderConfig.X_ATMOSPHERE_TRANSPORT header. Your AtmosphereHandler must also extends the AbstractReflectorAtmosphereHandler or implements the logic defined inside AbstractReflectorAtmosphereHandler.postStateChange(org.atmosphere.cpr.AtmosphereResourceEvent)

Author:
Jeanfrancois Arcand

Constructor Summary
AtmosphereResourceLifecycleInterceptor()
           
AtmosphereResourceLifecycleInterceptor(boolean force)
           
 
Method Summary
 void configure(AtmosphereConfig config)
          Allow this object to configure its state when initialized.
 Action inspect(AtmosphereResource r)
          Automatically suspend the AtmosphereResource based on AtmosphereResource.TRANSPORT value.
 String method()
           
 AtmosphereResourceLifecycleInterceptor method(String method)
           
 void postInspect(AtmosphereResource r)
          Invoked after an AtmosphereResource gets dispatched to AtmosphereHandler.
 int timeoutInSeconds()
           
 AtmosphereResourceLifecycleInterceptor timeoutInSeconds(int timeoutInSeconds)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtmosphereResourceLifecycleInterceptor

public AtmosphereResourceLifecycleInterceptor()

AtmosphereResourceLifecycleInterceptor

public AtmosphereResourceLifecycleInterceptor(boolean force)
Method Detail

configure

public void configure(AtmosphereConfig config)
Description copied from interface: AtmosphereInterceptor
Allow this object to configure its state when initialized.

Specified by:
configure in interface AtmosphereInterceptor
Parameters:
config - an AtmosphereConfig

method

public String method()

timeoutInSeconds

public int timeoutInSeconds()

method

public AtmosphereResourceLifecycleInterceptor method(String method)

timeoutInSeconds

public AtmosphereResourceLifecycleInterceptor timeoutInSeconds(int timeoutInSeconds)

inspect

public Action inspect(AtmosphereResource r)
Automatically suspend the AtmosphereResource based on AtmosphereResource.TRANSPORT value.

Specified by:
inspect in interface AtmosphereInterceptor
Parameters:
r - a AtmosphereResource
Returns:

postInspect

public void postInspect(AtmosphereResource r)
Description copied from interface: AtmosphereInterceptor
Invoked after an AtmosphereResource gets dispatched to AtmosphereHandler.

Specified by:
postInspect in interface AtmosphereInterceptor
Parameters:
r - a AtmosphereResource

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All Rights Reserved.