Class ClientAnnotationProcessor


  • public class ClientAnnotationProcessor
    extends java.lang.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  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.Object callPublic​(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object... arguments)  
      protected static void checkMethodsPublic​(java.lang.Object bean, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)  
      protected static void checkSignaturesMatch​(java.lang.reflect.Method method, java.lang.Class<?>[] expectedTypes, java.util.List<java.lang.String> paramNames)  
      boolean deprocess​(java.lang.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.
      boolean deprocessCallbacks​(java.lang.Object bean)
      Performs the opposite processing done by processCallbacks(Object) on callback methods annotated with Listener and Subscription.
      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.Object getField​(java.lang.Object bean, java.lang.reflect.Field field)  
      protected java.lang.Object invokePrivate​(java.lang.Object bean, java.lang.reflect.Method method, java.lang.Object... args)  
      protected static java.lang.Object invokePublic​(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object[] arguments)  
      boolean process​(java.lang.Object bean)
      Processes dependencies annotated with Session, callbacks annotated with Listener and Subscription and lifecycle methods annotated with PostConstruct.
      protected boolean processInjectable​(java.lang.Object bean, java.lang.Object injectable)  
      protected boolean processInjectables​(java.lang.Object bean, java.util.List<java.lang.Object> injectables)  
      protected java.util.List<java.lang.String> processParameters​(java.lang.reflect.Method method)  
      boolean processPostConstruct​(java.lang.Object bean)
      Processes lifecycle methods annotated with PostConstruct.
      boolean processPreDestroy​(java.lang.Object bean)
      Processes lifecycle methods annotated with PreDestroy.
      protected void setField​(java.lang.Object bean, java.lang.reflect.Field field, java.lang.Object value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
    • Constructor Detail

      • ClientAnnotationProcessor

        public ClientAnnotationProcessor​(ClientSession clientSession)
      • ClientAnnotationProcessor

        public ClientAnnotationProcessor​(ClientSession clientSession,
                                         java.lang.Object... injectables)
    • Method Detail

      • process

        public boolean process​(java.lang.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​(java.lang.Object bean)
        Processes lifecycle methods annotated with PostConstruct.
        Parameters:
        bean - the annotated service instance
        Returns:
        true if at least one lifecycle method has been invoked, false otherwise
      • deprocess

        public boolean deprocess​(java.lang.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:
        process(Object)
      • deprocessCallbacks

        public boolean deprocessCallbacks​(java.lang.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​(java.lang.Object bean)
        Processes lifecycle methods annotated with PreDestroy.
        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)