Class ClientAnnotationProcessor

java.lang.Object
org.cometd.annotation.AnnotationProcessor
org.cometd.annotation.client.ClientAnnotationProcessor

public class ClientAnnotationProcessor extends AnnotationProcessor

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);
 
  • Constructor Details

    • ClientAnnotationProcessor

      public ClientAnnotationProcessor(ClientSession clientSession)
    • ClientAnnotationProcessor

      public ClientAnnotationProcessor(ClientSession clientSession, Object... injectables)
  • Method Details

    • process

      public boolean process(Object bean)
      Processes dependencies annotated with Session, callbacks annotated with Listener and Subscription and lifecycle methods annotated with PostConstruct.
      Parameters:
      bean - the annotated service instance
      Returns:
      true if at least one dependency or callback has been processed, false otherwise
    • processPostConstruct

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

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

      public boolean deprocessCallbacks(Object bean)
      Performs the opposite processing done by processCallbacks(Object) on callback methods annotated with Listener and Subscription.
      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 with PreDestroy.
      Overrides:
      processPreDestroy in class AnnotationProcessor
      Parameters:
      bean - the annotated service instance
      Returns:
      true if at least one lifecycle method has been invoked, false otherwise