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 |
backgroundProcess() |
void |
destroyInstance(Object instance) |
protected int |
getAnnotationCacheSize()
Makes cache size available to unit tests.
|
static String |
getName(Method setter)
Deprecated.
|
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 boolean privileged
protected boolean ignoreAnnotations
public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, IllegalArgumentException, NoSuchMethodException, SecurityException
newInstance
in interface InstanceManager
IllegalAccessException
InvocationTargetException
NamingException
InstantiationException
IllegalArgumentException
NoSuchMethodException
SecurityException
public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException
public Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, NamingException, InvocationTargetException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException
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 failspublic void backgroundProcess()
protected 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 fails@Deprecated public static String getName(Method setter)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.