Package org.cometd.annotation.server
Class ServerAnnotationProcessor
- java.lang.Object
-
- org.cometd.annotation.AnnotationProcessor
-
- org.cometd.annotation.server.ServerAnnotationProcessor
-
public class ServerAnnotationProcessor extends AnnotationProcessor
Processes annotations in server-side service objects.
Service objects must be annotated with
Service
at class level to be processed by this processor, for example:@Service public class MyService { @Session private ServerSession session; @Configure("/foo") public void configureFoo(ConfigurableServerChannel channel) { channel.setPersistent(...); channel.addListener(...); channel.addAuthorizer(...); } @Listener("/foo") public void handleFooMessages(ServerSession remote, ServerMessage.Mutable message) { // Do something } }
The processor is used in this way:
BayeuxServer bayeux = ...; ServerAnnotationProcessor processor = ServerAnnotationProcessor.get(bayeux); MyService s = new MyService(); processor.process(s);
-
-
Constructor Summary
Constructors Constructor Description ServerAnnotationProcessor(BayeuxServer bayeuxServer)
ServerAnnotationProcessor(BayeuxServer bayeuxServer, java.lang.Object... injectables)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
deprocess(java.lang.Object bean)
Performs the opposite processing done byprocess(Object)
on callbacks methods annotated withListener
,Subscription
andRemoteCall
, and on lifecycle methods annotated withPreDestroy
.boolean
deprocessCallbacks(java.lang.Object bean)
Performs the opposite processing done byprocessCallbacks(Object)
on callback methods annotated withListener
,Subscription
andRemoteCall
.boolean
process(java.lang.Object bean)
Processes dependencies annotated withInject
andSession
, configuration methods annotated withConfigure
, callback methods annotated withListener
,Subscription
andRemoteCall
, and lifecycle methods annotated withPostConstruct
.boolean
processCallbacks(java.lang.Object bean)
boolean
processConfigurations(java.lang.Object bean)
Processes the methods annotated withConfigure
.boolean
processDependencies(java.lang.Object bean)
Processes the dependencies annotated withInject
andSession
.boolean
processPostConstruct(java.lang.Object bean)
Processes lifecycle methods annotated withPostConstruct
.boolean
processPreDestroy(java.lang.Object bean)
Processes lifecycle methods annotated withPreDestroy
.-
Methods inherited from class org.cometd.annotation.AnnotationProcessor
callPublic, checkMethodsPublic, checkSignaturesMatch, findAnnotatedMethods, getField, invokePrivate, invokePublic, processInjectable, processInjectables, processParameters, setField
-
-
-
-
Constructor Detail
-
ServerAnnotationProcessor
public ServerAnnotationProcessor(BayeuxServer bayeuxServer)
-
ServerAnnotationProcessor
public ServerAnnotationProcessor(BayeuxServer bayeuxServer, java.lang.Object... injectables)
-
-
Method Detail
-
process
public boolean process(java.lang.Object bean)
Processes dependencies annotated withInject
andSession
, configuration methods annotated withConfigure
, callback methods annotated withListener
,Subscription
andRemoteCall
, and lifecycle methods annotated withPostConstruct
.- Parameters:
bean
- the annotated service instance- Returns:
- true if the bean contains at least one annotation that has been processed, false otherwise
-
processConfigurations
public boolean processConfigurations(java.lang.Object bean)
Processes the methods annotated withConfigure
.- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one annotated configure has been processed, false otherwise
-
processDependencies
public boolean processDependencies(java.lang.Object bean)
Processes the dependencies annotated withInject
andSession
.- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one annotated dependency has been processed, false otherwise
-
processPostConstruct
public boolean processPostConstruct(java.lang.Object bean)
Processes lifecycle methods annotated withPostConstruct
.- Overrides:
processPostConstruct
in classAnnotationProcessor
- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one lifecycle method has been invoked, false otherwise
-
processCallbacks
public boolean processCallbacks(java.lang.Object bean)
- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one annotated callback has been processed, false otherwise
-
deprocess
public boolean deprocess(java.lang.Object bean)
Performs the opposite processing done byprocess(Object)
on callbacks methods annotated withListener
,Subscription
andRemoteCall
, and on lifecycle methods annotated withPreDestroy
.- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one deprocessing has been performed, false otherwise
- See Also:
process(Object)
-
deprocessCallbacks
public boolean deprocessCallbacks(java.lang.Object bean)
Performs the opposite processing done byprocessCallbacks(Object)
on callback methods annotated withListener
,Subscription
andRemoteCall
.- Parameters:
bean
- the annotated service instance- Returns:
- true if the at least one callback has been deprocessed
-
processPreDestroy
public boolean processPreDestroy(java.lang.Object bean)
Processes lifecycle methods annotated withPreDestroy
.- Overrides:
processPreDestroy
in classAnnotationProcessor
- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one lifecycle method has been invoked, false otherwise
-
-