Class ServerAnnotationProcessor

java.lang.Object
org.cometd.annotation.AnnotationProcessor
org.cometd.annotation.server.ServerAnnotationProcessor

public class ServerAnnotationProcessor extends AnnotationProcessor

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 Details

    • ServerAnnotationProcessor

      public ServerAnnotationProcessor(BayeuxServer bayeuxServer)
    • ServerAnnotationProcessor

      public ServerAnnotationProcessor(BayeuxServer bayeuxServer, Object... injectables)
  • Method Details

    • process

      public boolean process(Object service, Object... injectables)
      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.
      Parameters:
      service - the annotated service instance
      injectables - 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

      public boolean processConfigurations(Object service)
      Processes the methods annotated with Configure.
      Parameters:
      service - the annotated service instance
      Returns:
      true if at least one annotated configure has been processed, false otherwise
    • processDependencies

      public boolean processDependencies(Object service, Object... extraInjectables)
      Processes the dependencies annotated with Inject and Session.
      Parameters:
      service - the annotated service instance
      extraInjectables - additional objects that may be injected into the service instance
      Returns:
      true if at least one annotated dependency has been processed, false otherwise
    • processPostConstruct

      public boolean processPostConstruct(Object service)
      Processes lifecycle methods annotated with PostConstruct.
      Overrides:
      processPostConstruct in class AnnotationProcessor
      Parameters:
      service - the annotated service instance
      Returns:
      true if at least one lifecycle method has been invoked, false otherwise
    • processCallbacks

      public boolean processCallbacks(Object service)
      Processes the callbacks annotated with Listener, Subscription and RemoteCall.
      Parameters:
      service - the annotated service instance
      Returns:
      true if at least one annotated callback has been processed, false otherwise
    • deprocess

      public boolean deprocess(Object service)
      Performs the opposite processing done by process(Object, Object...) on callbacks methods annotated with Listener, Subscription and RemoteCall, and on lifecycle methods annotated with PreDestroy.
      Parameters:
      service - the annotated service instance
      Returns:
      true if at least one deprocessing has been performed, false otherwise
      See Also:
    • deprocessCallbacks

      public boolean deprocessCallbacks(Object service)
      Performs the opposite processing done by processCallbacks(Object) on callback methods annotated with Listener, Subscription and RemoteCall.
      Parameters:
      service - the annotated service instance
      Returns:
      true if the at least one callback has been deprocessed
    • processPreDestroy

      public boolean processPreDestroy(Object service)
      Processes lifecycle methods annotated with PreDestroy.
      Overrides:
      processPreDestroy in class AnnotationProcessor
      Parameters:
      service - the annotated service instance
      Returns:
      true if at least one lifecycle method has been invoked, false otherwise