Package org.cometd.annotation
Class ClientAnnotationProcessor
java.lang.Object
org.cometd.annotation.ClientAnnotationProcessor
public class ClientAnnotationProcessor extends Object
Processes annotations in client-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 { @Listener(Channel.META_CONNECT) public void metaConnect(Message message) { // Do something } }
The processor is used in this way:
ClientSession bayeux = ...; ClientAnnotationProcessor processor = ClientAnnotationProcessor.get(bayeux); MyService s = new MyService(); processor.process(s);
- See Also:
ServerAnnotationProcessor
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description ClientAnnotationProcessor(ClientSession clientSession)
ClientAnnotationProcessor(ClientSession clientSession, Object... injectables)
-
Method Summary
Modifier and Type Method Description protected static Object
callPublic(Object target, Method method, Object... arguments)
protected static void
checkMethodsPublic(Object bean, Class<? extends Annotation> annotationClass)
protected static void
checkSignaturesMatch(Method method, Class<?>[] expectedTypes, List<String> paramNames)
boolean
deprocess(Object bean)
Performs the opposite processing done byprocess(Object)
on callbacks methods annotated withListener
andSubscription
, and on lifecycle methods annotated withPreDestroy
.boolean
deprocessCallbacks(Object bean)
Performs the opposite processing done byprocessCallbacks(Object)
on callback methods annotated withListener
andSubscription
.protected List<Method>
findAnnotatedMethods(Object bean, Class<? extends Annotation> annotationClass)
protected Object
getField(Object bean, Field field)
protected Object
invokePrivate(Object bean, Method method, Object... args)
protected static Object
invokePublic(Object target, Method method, Object[] arguments)
boolean
process(Object bean)
Processes dependencies annotated withSession
, callbacks annotated withListener
andSubscription
and lifecycle methods annotated withPostConstruct
.protected boolean
processInjectable(Object bean, Object injectable)
protected boolean
processInjectables(Object bean, List<Object> injectables)
protected List<String>
processParameters(Method method)
boolean
processPostConstruct(Object bean)
Processes lifecycle methods annotated withPostConstruct
.boolean
processPreDestroy(Object bean)
Processes lifecycle methods annotated withPreDestroy
.protected void
setField(Object bean, Field field, Object value)
-
Field Details
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
Method Details
-
process
Processes dependencies annotated withSession
, callbacks annotated withListener
andSubscription
and lifecycle methods annotated withPostConstruct
.- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one dependency or callback has been processed, false otherwise
-
processPostConstruct
Processes lifecycle methods annotated withPostConstruct
.- Parameters:
bean
- the annotated service instance- Returns:
- true if at least one lifecycle method has been invoked, false otherwise
-
deprocess
Performs the opposite processing done byprocess(Object)
on callbacks methods annotated withListener
andSubscription
, 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
Performs the opposite processing done byprocessCallbacks(Object)
on callback methods annotated withListener
andSubscription
.- Parameters:
bean
- the annotated service instance- Returns:
- true if the at least one callback has been deprocessed
-
processPreDestroy
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) -
processParameters
-
invokePrivate
-
invokePublic
protected static Object invokePublic(Object target, Method method, Object[] arguments) throws Throwable- Throws:
Throwable
-
callPublic
-
getField
-
setField
-
checkMethodsPublic
-
checkSignaturesMatch
-
processInjectables
-
processInjectable
-