Package org.atmosphere.inject
Class InjectableObjectFactory
java.lang.Object
org.atmosphere.inject.InjectableObjectFactory
- All Implemented Interfaces:
AtmosphereObjectFactory<Injectable<?>>,AtmosphereConfigAware
public class InjectableObjectFactory
extends Object
implements AtmosphereObjectFactory<Injectable<?>>
Support injection of Atmosphere's Internal object using
AtmosphereConfig,AtmosphereFramework,
invalid @link
{@link org.atmosphere.cpr.BroadcasterFactory,
AtmosphereResourceFactory ,DefaultMetaBroadcaster and
AtmosphereResourceSessionFactory and classes implementing the Injectable defined inside
META_INF/services/org.atmosphere.inject.Inject- Author:
- Jeanfrancois Arcand
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallowInjectionOf(Injectable<?> injectable) Pass information to the underlying Dependency Injection ImplementationallowInjectionOf(Injectable<?> injectable, boolean first) <U> voidapplyMethods(U instance, Class<U> defaultType) voidconfigure(AtmosphereConfig config) Configure an AtmosphereFramework object.protected <T,U extends T>
voidfieldInjectionException(Field field, U instance, Class<T> clazz, Exception ex) <U> UgetInjectable(Class<U> u) Use this method to retrieve availableInjectable.<T> Tinject(T instance) ApplyInjectableandInjectIntrospectorto a class already constructed.<U> voidinjectFields(Set<Field> fields, U instance, AtmosphereFramework framework, LinkedList<Injectable<?>> injectable) <U> voidinjectInjectable(U instance, Class<? extends U> defaultType, AtmosphereFramework framework) protected voidprotected <T,U extends T>
voidmethodInjectionException(Method m, U instance, Class<T> clazz, Exception ex) booleanneedRequestScoped(Class defaultType) <T,U extends T>
UnewClassInstance(Class<T> classType, Class<U> defaultType) Delegate the creation of Object to the underlying object provider like Spring, Guice, etc.protected <T,U extends T>
voidnullFieldInjectionFor(Field field, U instance, Class<T> clazz) protected <T,U extends T>
voidpostFieldInjection(Field field, U instance, Class<T> clazz) protected <T,U extends T>
voidpostMethodInjection(Method method, U instance, Class<T> clazz) protected <T,U extends T>
voidpreFieldInjection(Field field, U instance, Class<T> clazz) protected <T,U extends T>
voidpreMethodInjection(Method method, U instance, Class<T> clazz) voidrequestScoped(Object instance, Class defaultType) voidrequestScoped(Object instance, Class defaultType, AtmosphereResource r) protected voidretryInjection(AtmosphereFramework framework) toString()
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
InjectableObjectFactory
public InjectableObjectFactory()
-
-
Method Details
-
configure
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Parameters:
config-AtmosphereConfig
-
retryInjection
-
newClassInstance
public <T,U extends T> U newClassInstance(Class<T> classType, Class<U> defaultType) throws InstantiationException, IllegalAccessException Description copied from interface:AtmosphereObjectFactoryDelegate 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 theAtmosphereConfigAware.AtmosphereConfigAware.configure(AtmosphereConfig)should be called in that case.- Specified by:
newClassInstancein interfaceAtmosphereObjectFactory<Injectable<?>>- Parameters:
classType- The class' type to be createddefaultType- a class to be created @return an instance of T- Throws:
InstantiationExceptionIllegalAccessException
-
inject
ApplyInjectableandInjectIntrospectorto a class already constructed.- Parameters:
instance- the instance to inject to.- Returns:
- Throws:
InstantiationExceptionIllegalAccessException
-
applyMethods
- Type Parameters:
U-- Parameters:
instance- the requested object.defaultType- the type of the requested object- Throws:
IllegalAccessException
-
injectInjectable
public <U> void injectInjectable(U instance, Class<? extends U> defaultType, AtmosphereFramework framework) throws IllegalAccessException - Type Parameters:
U-- Parameters:
instance- the requested object.defaultType- the type of the requested objectframework- theAtmosphereFramework- Throws:
IllegalAccessException
-
injectFields
public <U> void injectFields(Set<Field> fields, U instance, AtmosphereFramework framework, LinkedList<Injectable<?>> injectable) throws IllegalAccessException - Throws:
IllegalAccessException
-
allowInjectionOf
Description copied from interface:AtmosphereObjectFactoryPass information to the underlying Dependency Injection Implementation- Specified by:
allowInjectionOfin interfaceAtmosphereObjectFactory<Injectable<?>>- Parameters:
injectable- an Z- Returns:
- this
-
allowInjectionOf
-
toString
-
getInjectable
Use this method to retrieve availableInjectable. This method is for application that inject their ownInjectableand 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(Object instance, Class defaultType, AtmosphereResource r) throws IllegalAccessException - Throws:
IllegalAccessException
-
requestScoped
- Throws:
IllegalAccessException
-
needRequestScoped
- Throws:
IllegalAccessException
-
listener
-
injectionFailed
protected void injectionFailed() -
nullFieldInjectionFor
-
fieldInjectionException
-
methodInjectionException
-
preFieldInjection
-
postFieldInjection
-
preMethodInjection
-
postMethodInjection
-