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()
.
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...)
HeaderConfig.X_ATMOSPHERE_TRANSPORT
header. Your AtmosphereHandler must also extends the
AbstractReflectorAtmosphereHandler
or implements the logic defined inside
AbstractReflectorAtmosphereHandler.postStateChange(org.atmosphere.cpr.AtmosphereResourceEvent)
Constructor and Description |
---|
AtmosphereResourceLifecycleInterceptor() |
AtmosphereResourceLifecycleInterceptor(boolean force) |
Modifier and Type | Method and Description |
---|---|
void |
configure(AtmosphereConfig config)
Configure an AtmosphereFramework object.
|
void |
destroy()
Clean the AtmosphereInterceptor when removed or when the Atmosphere is undeployed.
|
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() |
public AtmosphereResourceLifecycleInterceptor()
public AtmosphereResourceLifecycleInterceptor(boolean force)
public void configure(AtmosphereConfig config)
AtmosphereConfigAware
configure
in interface AtmosphereConfigAware
config
- AtmosphereConfig
public String method()
public int timeoutInSeconds()
public AtmosphereResourceLifecycleInterceptor method(String method)
public AtmosphereResourceLifecycleInterceptor timeoutInSeconds(int timeoutInSeconds)
public Action inspect(AtmosphereResource r)
AtmosphereResource
based on AtmosphereResource.TRANSPORT
value.inspect
in interface AtmosphereInterceptor
r
- a AtmosphereResource
public void postInspect(AtmosphereResource r)
AtmosphereInterceptor
AtmosphereResource
gets dispatched to AtmosphereHandler
.postInspect
in interface AtmosphereInterceptor
r
- a AtmosphereResource
public void destroy()
AtmosphereInterceptor
destroy
in interface AtmosphereInterceptor
Copyright © 2016. All rights reserved.