public class DefaultInstanceManager extends Object implements InstanceManager
Modifier and Type | Field and Description |
---|---|
protected ClassLoader |
classLoader |
protected ClassLoader |
containerClassLoader |
protected boolean |
ignoreAnnotations |
protected boolean |
privileged |
protected static StringManager |
sm
The string manager for this package.
|
Constructor and Description |
---|
DefaultInstanceManager(Context context,
Map<String,Map<String,String>> injectionMap,
Context catalinaContext,
ClassLoader containerClassLoader) |
Modifier and Type | Method and Description |
---|---|
void |
destroyInstance(Object instance) |
protected int |
getAnnotationCacheSize()
Makes cache size available to unit tests.
|
protected Class<?> |
loadClass(String className,
ClassLoader classLoader) |
protected Class<?> |
loadClassMaybePrivileged(String className,
ClassLoader classLoader) |
protected static void |
lookupFieldResource(Context context,
Object instance,
Field field,
String name,
Class<?> clazz)
Inject resources in specified field.
|
protected static void |
lookupMethodResource(Context context,
Object instance,
Method method,
String name,
Class<?> clazz)
Inject resources in specified method.
|
Object |
newInstance(Class<?> clazz) |
void |
newInstance(Object o) |
Object |
newInstance(String className) |
Object |
newInstance(String className,
ClassLoader classLoader) |
protected void |
populateAnnotationsCache(Class<?> clazz,
Map<String,String> injections)
Make sure that the annotations cache has been populated for the provided
class.
|
protected void |
postConstruct(Object instance,
Class<?> clazz)
Call postConstruct method on the specified instance recursively from
deepest superclass to actual class.
|
protected void |
preDestroy(Object instance,
Class<?> clazz)
Call preDestroy method on the specified instance recursively from deepest
superclass to actual class.
|
protected void |
processAnnotations(Object instance,
Map<String,String> injections)
Inject resources in specified instance.
|
protected static final StringManager sm
protected final ClassLoader classLoader
protected final ClassLoader containerClassLoader
protected final boolean privileged
protected final boolean ignoreAnnotations
public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException
newInstance
in interface InstanceManager
IllegalAccessException
InvocationTargetException
NamingException
InstantiationException
public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException
newInstance
in interface InstanceManager
IllegalAccessException
InvocationTargetException
NamingException
InstantiationException
ClassNotFoundException
public Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, NamingException, InvocationTargetException, InstantiationException, ClassNotFoundException
newInstance
in interface InstanceManager
IllegalAccessException
NamingException
InvocationTargetException
InstantiationException
ClassNotFoundException
public void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException
newInstance
in interface InstanceManager
IllegalAccessException
InvocationTargetException
NamingException
public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException
destroyInstance
in interface InstanceManager
IllegalAccessException
InvocationTargetException
protected void postConstruct(Object instance, Class<?> clazz) throws IllegalAccessException, InvocationTargetException
instance
- object to call postconstruct methods onclazz
- (super) class to examine for postConstruct annotation.IllegalAccessException
- if postConstruct method is inaccessible.InvocationTargetException
- if call failsprotected void preDestroy(Object instance, Class<?> clazz) throws IllegalAccessException, InvocationTargetException
instance
- object to call preDestroy methods onclazz
- (super) class to examine for preDestroy annotation.IllegalAccessException
- if preDestroy method is inaccessible.InvocationTargetException
- if call failsprotected void populateAnnotationsCache(Class<?> clazz, Map<String,String> injections) throws IllegalAccessException, InvocationTargetException, NamingException
clazz
- clazz to populate annotations forinjections
- map of injections for this class from xml deployment
descriptorIllegalAccessException
- if injection target is inaccessibleNamingException
- if value cannot be looked up in jndiInvocationTargetException
- if injection failsprotected void processAnnotations(Object instance, Map<String,String> injections) throws IllegalAccessException, InvocationTargetException, NamingException
instance
- instance to inject intoinjections
- map of injections for this class from xml deployment descriptorIllegalAccessException
- if injection target is inaccessibleNamingException
- if value cannot be looked up in jndiInvocationTargetException
- if injection failsprotected int getAnnotationCacheSize()
protected Class<?> loadClassMaybePrivileged(String className, ClassLoader classLoader) throws ClassNotFoundException
ClassNotFoundException
protected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException
ClassNotFoundException
protected static void lookupFieldResource(Context context, Object instance, Field field, String name, Class<?> clazz) throws NamingException, IllegalAccessException
context
- jndi context to extract value frominstance
- object to inject intofield
- field target for injectionname
- jndi name value is bound underclazz
- class annotation is defined inIllegalAccessException
- if field is inaccessibleNamingException
- if value is not accessible in naming contextprotected static void lookupMethodResource(Context context, Object instance, Method method, String name, Class<?> clazz) throws NamingException, IllegalAccessException, InvocationTargetException
context
- jndi context to extract value frominstance
- object to inject intomethod
- field target for injectionname
- jndi name value is bound underclazz
- class annotation is defined inIllegalAccessException
- if method is inaccessibleNamingException
- if value is not accessible in naming contextInvocationTargetException
- if setter call failsCopyright © 2000-2014 Apache Software Foundation. All Rights Reserved.