Package org.cometd.annotation
Class ServerAnnotationProcessor
- java.lang.Object
-
- org.cometd.annotation.ServerAnnotationProcessor
-
public class ServerAnnotationProcessor extends Object
Processes annotations in server-side service objects.
Service objects must be annotated with
Serviceat 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);
- See Also:
ClientAnnotationProcessor
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description ServerAnnotationProcessor(BayeuxServer bayeuxServer)ServerAnnotationProcessor(BayeuxServer bayeuxServer, Object... injectables)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static ObjectcallPublic(Object target, Method method, Object... arguments)protected static voidcheckMethodsPublic(Object bean, Class<? extends Annotation> annotationClass)protected static voidcheckSignaturesMatch(Method method, Class<?>[] expectedTypes, List<String> paramNames)booleandeprocess(Object bean)Performs the opposite processing done byprocess(Object)on callbacks methods annotated withListener,SubscriptionandRemoteCall, and on lifecycle methods annotated withPreDestroy.booleandeprocessCallbacks(Object bean)Performs the opposite processing done byprocessCallbacks(Object)on callback methods annotated withListener,SubscriptionandRemoteCall.protected List<Method>findAnnotatedMethods(Object bean, Class<? extends Annotation> annotationClass)protected ObjectgetField(Object bean, Field field)protected ObjectinvokePrivate(Object bean, Method method, Object... args)protected static ObjectinvokePublic(Object target, Method method, Object[] arguments)booleanprocess(Object bean)Processes dependencies annotated withInjectandSession, configuration methods annotated withConfigure, callback methods annotated withListener,SubscriptionandRemoteCall, and lifecycle methods annotated withPostConstruct.booleanprocessCallbacks(Object bean)booleanprocessConfigurations(Object bean)Processes the methods annotated withConfigure.booleanprocessDependencies(Object bean)Processes the dependencies annotated withInjectandSession.protected booleanprocessInjectable(Object bean, Object injectable)protected booleanprocessInjectables(Object bean, List<Object> injectables)protected List<String>processParameters(Method method)booleanprocessPostConstruct(Object bean)Processes lifecycle methods annotated withPostConstruct.booleanprocessPreDestroy(Object bean)Processes lifecycle methods annotated withPreDestroy.protected voidsetField(Object bean, Field field, Object value)
-
-
-
Constructor Detail
-
ServerAnnotationProcessor
public ServerAnnotationProcessor(BayeuxServer bayeuxServer)
-
ServerAnnotationProcessor
public ServerAnnotationProcessor(BayeuxServer bayeuxServer, Object... injectables)
-
-
Method Detail
-
process
public boolean process(Object bean)
Processes dependencies annotated withInjectandSession, configuration methods annotated withConfigure, callback methods annotated withListener,SubscriptionandRemoteCall, 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(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(Object bean)
Processes the dependencies annotated withInjectandSession.- Parameters:
bean- the annotated service instance- Returns:
- true if at least one annotated dependency has been processed, false otherwise
-
processPostConstruct
public boolean processPostConstruct(Object bean)
Processes lifecycle methods annotated withPostConstruct.- Parameters:
bean- the annotated service instance- Returns:
- true if at least one lifecycle method has been invoked, false otherwise
-
processCallbacks
public boolean processCallbacks(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(Object bean)
Performs the opposite processing done byprocess(Object)on callbacks methods annotated withListener,SubscriptionandRemoteCall, 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(Object bean)
Performs the opposite processing done byprocessCallbacks(Object)on callback methods annotated withListener,SubscriptionandRemoteCall.- Parameters:
bean- the annotated service instance- Returns:
- true if the at least one callback has been deprocessed
-
processPreDestroy
public boolean processPreDestroy(Object bean)
Processes lifecycle methods annotated withPreDestroy.- Parameters:
bean- the annotated service instance- Returns:
- true if at least one lifecycle method has been invoked, false otherwise
-
findAnnotatedMethods
protected List<Method> findAnnotatedMethods(Object bean, Class<? extends Annotation> annotationClass)
-
invokePublic
protected static Object invokePublic(Object target, Method method, Object[] arguments) throws Throwable
- Throws:
Throwable
-
checkMethodsPublic
protected static void checkMethodsPublic(Object bean, Class<? extends Annotation> annotationClass)
-
checkSignaturesMatch
protected static void checkSignaturesMatch(Method method, Class<?>[] expectedTypes, List<String> paramNames)
-
-