Class InjectableObjectFactory

    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
    • Constructor Detail

      • InjectableObjectFactory

        public InjectableObjectFactory()
    • Method Detail

      • newClassInstance

        public <T,​U extends T> U newClassInstance​(java.lang.Class<T> classType,
                                                        java.lang.Class<U> defaultType)
                                                 throws java.lang.InstantiationException,
                                                        java.lang.IllegalAccessException
        Description copied from interface: AtmosphereObjectFactory
        Delegate the creation of Object to the underlying object provider like Spring, Guice, etc. When creating a class, it is important to check if the class can be configured via its implementation of the AtmosphereConfigAware. AtmosphereConfigAware.configure(AtmosphereConfig) should be called in that case.
        Specified by:
        newClassInstance in interface AtmosphereObjectFactory<Injectable<?>>
        Parameters:
        classType - The class' type to be created
        defaultType - a class to be created @return an instance of T
        Throws:
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • inject

        public <T> T inject​(T instance)
                     throws java.lang.InstantiationException,
                            java.lang.IllegalAccessException
        Apply Injectable and InjectIntrospector to a class already constructed.
        Parameters:
        instance - the instance to inject to.
        Returns:
        Throws:
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • injectInjectable

        public <U> void injectInjectable​(U instance,
                                         java.lang.Class<? extends U> defaultType,
                                         AtmosphereFramework framework)
                                  throws java.lang.IllegalAccessException
        Type Parameters:
        U -
        Parameters:
        instance - the requested object.
        defaultType - the type of the requested object
        framework - the AtmosphereFramework
        Throws:
        java.lang.IllegalAccessException
      • injectFields

        public <U> void injectFields​(java.util.Set<java.lang.reflect.Field> fields,
                                     U instance,
                                     AtmosphereFramework framework,
                                     java.util.LinkedList<Injectable<?>> injectable)
                              throws java.lang.IllegalAccessException
        Throws:
        java.lang.IllegalAccessException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getInjectable

        public <U> U getInjectable​(java.lang.Class<U> u)
        Use this method to retrieve available Injectable. This method is for application that inject their own Injectable and needs already constructed classes.
        Type Parameters:
        U - the type
        Parameters:
        u - the class
        Returns:
        the class if exists, null if not
      • requestScoped

        public void requestScoped​(java.lang.Object instance,
                                  java.lang.Class defaultType,
                                  AtmosphereResource r)
                           throws java.lang.IllegalAccessException
        Throws:
        java.lang.IllegalAccessException
      • requestScoped

        public void requestScoped​(java.lang.Object instance,
                                  java.lang.Class defaultType)
                           throws java.lang.IllegalAccessException
        Throws:
        java.lang.IllegalAccessException
      • needRequestScoped

        public boolean needRequestScoped​(java.lang.Class defaultType)
                                  throws java.lang.IllegalAccessException
        Throws:
        java.lang.IllegalAccessException
      • injectionFailed

        protected void injectionFailed()
      • nullFieldInjectionFor

        protected <T,​U extends T> void nullFieldInjectionFor​(java.lang.reflect.Field field,
                                                                   U instance,
                                                                   java.lang.Class<T> clazz)
      • fieldInjectionException

        protected <T,​U extends T> void fieldInjectionException​(java.lang.reflect.Field field,
                                                                     U instance,
                                                                     java.lang.Class<T> clazz,
                                                                     java.lang.Exception ex)
      • methodInjectionException

        protected <T,​U extends T> void methodInjectionException​(java.lang.reflect.Method m,
                                                                      U instance,
                                                                      java.lang.Class<T> clazz,
                                                                      java.lang.Exception ex)
      • preFieldInjection

        protected <T,​U extends T> void preFieldInjection​(java.lang.reflect.Field field,
                                                               U instance,
                                                               java.lang.Class<T> clazz)
      • postFieldInjection

        protected <T,​U extends T> void postFieldInjection​(java.lang.reflect.Field field,
                                                                U instance,
                                                                java.lang.Class<T> clazz)
      • preMethodInjection

        protected <T,​U extends T> void preMethodInjection​(java.lang.reflect.Method method,
                                                                U instance,
                                                                java.lang.Class<T> clazz)
      • postMethodInjection

        protected <T,​U extends T> void postMethodInjection​(java.lang.reflect.Method method,
                                                                 U instance,
                                                                 java.lang.Class<T> clazz)