public class ServerAnnotationProcessor extends Object
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);
ClientAnnotationProcessor
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger |
Constructor and Description |
---|
ServerAnnotationProcessor(BayeuxServer bayeuxServer) |
ServerAnnotationProcessor(BayeuxServer bayeuxServer,
Object... injectables) |
Modifier and Type | Method and Description |
---|---|
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 by
process(Object) on callbacks methods
annotated with Listener , Subscription and RemoteCall , and on
lifecycle methods annotated with PreDestroy . |
boolean |
deprocessCallbacks(Object bean)
Performs the opposite processing done by
processCallbacks(Object) on callback methods
annotated with Listener , Subscription and RemoteCall . |
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 with
Inject and Session ,
configuration methods annotated with Configure , callback methods
annotated with Listener , Subscription and RemoteCall ,
and lifecycle methods annotated with PostConstruct . |
boolean |
processCallbacks(Object bean)
|
boolean |
processConfigurations(Object bean)
Processes the methods annotated with
Configure . |
boolean |
processDependencies(Object bean)
Processes the dependencies annotated with
Inject and Session . |
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 with
PostConstruct . |
boolean |
processPreDestroy(Object bean)
Processes lifecycle methods annotated with
PreDestroy . |
protected void |
setField(Object bean,
Field field,
Object value) |
public ServerAnnotationProcessor(BayeuxServer bayeuxServer)
public ServerAnnotationProcessor(BayeuxServer bayeuxServer, Object... injectables)
public boolean process(Object bean)
Inject
and Session
,
configuration methods annotated with Configure
, callback methods
annotated with Listener
, Subscription
and RemoteCall
,
and lifecycle methods annotated with PostConstruct
.bean
- the annotated service instancepublic boolean processConfigurations(Object bean)
Configure
.bean
- the annotated service instancepublic boolean processDependencies(Object bean)
Inject
and Session
.bean
- the annotated service instancepublic boolean processPostConstruct(Object bean)
PostConstruct
.bean
- the annotated service instancepublic boolean processCallbacks(Object bean)
bean
- the annotated service instancepublic boolean deprocess(Object bean)
process(Object)
on callbacks methods
annotated with Listener
, Subscription
and RemoteCall
, and on
lifecycle methods annotated with PreDestroy
.bean
- the annotated service instanceprocess(Object)
public boolean deprocessCallbacks(Object bean)
processCallbacks(Object)
on callback methods
annotated with Listener
, Subscription
and RemoteCall
.bean
- the annotated service instancepublic boolean processPreDestroy(Object bean)
PreDestroy
.bean
- the annotated service instanceprotected List<Method> findAnnotatedMethods(Object bean, Class<? extends Annotation> annotationClass)
protected static Object invokePublic(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)
Copyright © 2008–2016 The CometD Project. All rights reserved.