Class ServerAnnotationProcessor
java.lang.Object
org.cometd.annotation.AnnotationProcessor
org.cometd.annotation.server.ServerAnnotationProcessor
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 = new ServerAnnotationProcessor(bayeux);
MyService s = new MyService();
processor.process(s);
-
Constructor Summary
ConstructorDescriptionServerAnnotationProcessor
(BayeuxServer bayeuxServer) ServerAnnotationProcessor
(BayeuxServer bayeuxServer, Object... injectables) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Performs the opposite processing done byprocess(Object, Object...)
on callbacks methods annotated withListener
,Subscription
andRemoteCall
, and on lifecycle methods annotated withPreDestroy
.boolean
deprocessCallbacks
(Object service) Performs the opposite processing done byprocessCallbacks(Object)
on callback methods annotated withListener
,Subscription
andRemoteCall
.boolean
Processes dependencies annotated withInject
andSession
, configuration methods annotated withConfigure
, callback methods annotated withListener
,Subscription
andRemoteCall
, and lifecycle methods annotated withPostConstruct
.boolean
processCallbacks
(Object service) boolean
processConfigurations
(Object service) Processes the methods annotated withConfigure
.boolean
processDependencies
(Object service, Object... extraInjectables) Processes the dependencies annotated withInject
andSession
.boolean
processPostConstruct
(Object service) Processes lifecycle methods annotated withPostConstruct
.boolean
processPreDestroy
(Object service) 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 Details
-
ServerAnnotationProcessor
-
ServerAnnotationProcessor
-
-
Method Details
-
process
Processes dependencies annotated withInject
andSession
, configuration methods annotated withConfigure
, callback methods annotated withListener
,Subscription
andRemoteCall
, and lifecycle methods annotated withPostConstruct
.- Parameters:
service
- the annotated service instanceinjectables
- additional objects that may be injected into the service instance- Returns:
- true if the service contains at least one annotation that has been processed, false otherwise
-
processConfigurations
-
processDependencies
Processes the dependencies annotated withInject
andSession
.- Parameters:
service
- the annotated service instanceextraInjectables
- additional objects that may be injected into the service instance- Returns:
- true if at least one annotated dependency has been processed, false otherwise
-
processPostConstruct
Processes lifecycle methods annotated withPostConstruct
.- Overrides:
processPostConstruct
in classAnnotationProcessor
- Parameters:
service
- the annotated service instance- Returns:
- true if at least one lifecycle method has been invoked, false otherwise
-
processCallbacks
- Parameters:
service
- the annotated service instance- Returns:
- true if at least one annotated callback has been processed, false otherwise
-
deprocess
Performs the opposite processing done byprocess(Object, Object...)
on callbacks methods annotated withListener
,Subscription
andRemoteCall
, and on lifecycle methods annotated withPreDestroy
.- Parameters:
service
- the annotated service instance- Returns:
- true if at least one deprocessing has been performed, false otherwise
- See Also:
-
deprocessCallbacks
Performs the opposite processing done byprocessCallbacks(Object)
on callback methods annotated withListener
,Subscription
andRemoteCall
.- Parameters:
service
- the annotated service instance- Returns:
- true if the at least one callback has been deprocessed
-
processPreDestroy
Processes lifecycle methods annotated withPreDestroy
.- Overrides:
processPreDestroy
in classAnnotationProcessor
- Parameters:
service
- the annotated service instance- Returns:
- true if at least one lifecycle method has been invoked, false otherwise
-