Package org.cometd.annotation
Class ServerAnnotationProcessor
- java.lang.Object
-
- org.cometd.annotation.ServerAnnotationProcessor
-
public class ServerAnnotationProcessor extends java.lang.ObjectProcesses 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(org.cometd.bayeux.server.BayeuxServer bayeuxServer)ServerAnnotationProcessor(org.cometd.bayeux.server.BayeuxServer bayeuxServer, java.lang.Object... injectables)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.ObjectcallPublic(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object... arguments)protected static voidcheckMethodsPublic(java.lang.Object bean, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)protected static voidcheckSignaturesMatch(java.lang.reflect.Method method, java.lang.Class<?>[] expectedTypes, java.util.List<java.lang.String> paramNames)booleandeprocess(java.lang.Object bean)Performs the opposite processing done byprocess(Object)on callbacks methods annotated withListener,SubscriptionandRemoteCall, and on lifecycle methods annotated withPreDestroy.booleandeprocessCallbacks(java.lang.Object bean)Performs the opposite processing done byprocessCallbacks(Object)on callback methods annotated withListener,SubscriptionandRemoteCall.protected java.util.List<java.lang.reflect.Method>findAnnotatedMethods(java.lang.Object bean, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)protected java.lang.ObjectgetField(java.lang.Object bean, java.lang.reflect.Field field)protected java.lang.ObjectinvokePrivate(java.lang.Object bean, java.lang.reflect.Method method, java.lang.Object... args)protected static java.lang.ObjectinvokePublic(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object[] arguments)booleanprocess(java.lang.Object bean)Processes dependencies annotated withInjectandSession, configuration methods annotated withConfigure, callback methods annotated withListener,SubscriptionandRemoteCall, and lifecycle methods annotated withPostConstruct.booleanprocessCallbacks(java.lang.Object bean)booleanprocessConfigurations(java.lang.Object bean)Processes the methods annotated withConfigure.booleanprocessDependencies(java.lang.Object bean)Processes the dependencies annotated withInjectandSession.protected booleanprocessInjectable(java.lang.Object bean, java.lang.Object injectable)protected booleanprocessInjectables(java.lang.Object bean, java.util.List<java.lang.Object> injectables)protected java.util.List<java.lang.String>processParameters(java.lang.reflect.Method method)booleanprocessPostConstruct(java.lang.Object bean)Processes lifecycle methods annotated withPostConstruct.booleanprocessPreDestroy(java.lang.Object bean)Processes lifecycle methods annotated withPreDestroy.protected voidsetField(java.lang.Object bean, java.lang.reflect.Field field, java.lang.Object value)
-
-
-
Method Detail
-
process
public boolean process(java.lang.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(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 withInjectandSession.- 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.- 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,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(java.lang.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(java.lang.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 java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Object bean, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
-
processParameters
protected java.util.List<java.lang.String> processParameters(java.lang.reflect.Method method)
-
invokePrivate
protected java.lang.Object invokePrivate(java.lang.Object bean, java.lang.reflect.Method method, java.lang.Object... args)
-
invokePublic
protected static java.lang.Object invokePublic(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object[] arguments) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
callPublic
protected static java.lang.Object callPublic(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object... arguments)
-
getField
protected java.lang.Object getField(java.lang.Object bean, java.lang.reflect.Field field)
-
setField
protected void setField(java.lang.Object bean, java.lang.reflect.Field field, java.lang.Object value)
-
checkMethodsPublic
protected static void checkMethodsPublic(java.lang.Object bean, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
-
checkSignaturesMatch
protected static void checkSignaturesMatch(java.lang.reflect.Method method, java.lang.Class<?>[] expectedTypes, java.util.List<java.lang.String> paramNames)
-
processInjectables
protected boolean processInjectables(java.lang.Object bean, java.util.List<java.lang.Object> injectables)
-
processInjectable
protected boolean processInjectable(java.lang.Object bean, java.lang.Object injectable)
-
-