Package org.apache.catalina.core
Class DefaultInstanceManager
- java.lang.Object
- 
- org.apache.catalina.core.DefaultInstanceManager
 
- 
- All Implemented Interfaces:
- InstanceManager
 
 public class DefaultInstanceManager extends java.lang.Object implements InstanceManager 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.lang.ClassLoaderclassLoaderprotected java.lang.ClassLoadercontainerClassLoaderprotected booleanignoreAnnotationsprotected booleanprivilegedprotected static StringManagersmThe string manager for this package.
 - 
Constructor SummaryConstructors Constructor Description DefaultInstanceManager(javax.naming.Context context, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> injectionMap, Context catalinaContext, java.lang.ClassLoader containerClassLoader)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbackgroundProcess()Called by the component using the InstanceManager periodically to perform any regular maintenance that might be required.voiddestroyInstance(java.lang.Object instance)protected intgetAnnotationCacheSize()Makes cache size available to unit tests.protected java.lang.Class<?>loadClass(java.lang.String className, java.lang.ClassLoader classLoader)protected java.lang.Class<?>loadClassMaybePrivileged(java.lang.String className, java.lang.ClassLoader classLoader)protected static voidlookupFieldResource(javax.naming.Context context, java.lang.Object instance, java.lang.reflect.Field field, java.lang.String name, java.lang.Class<?> clazz)Inject resources in specified field.protected static voidlookupMethodResource(javax.naming.Context context, java.lang.Object instance, java.lang.reflect.Method method, java.lang.String name, java.lang.Class<?> clazz)Inject resources in specified method.java.lang.ObjectnewInstance(java.lang.Class<?> clazz)voidnewInstance(java.lang.Object o)java.lang.ObjectnewInstance(java.lang.String className)java.lang.ObjectnewInstance(java.lang.String className, java.lang.ClassLoader classLoader)protected voidpopulateAnnotationsCache(java.lang.Class<?> clazz, java.util.Map<java.lang.String,java.lang.String> injections)Make sure that the annotations cache has been populated for the provided class.protected voidpostConstruct(java.lang.Object instance, java.lang.Class<?> clazz)Call postConstruct method on the specified instance recursively from deepest superclass to actual class.protected voidpreDestroy(java.lang.Object instance, java.lang.Class<?> clazz)Call preDestroy method on the specified instance recursively from deepest superclass to actual class.protected voidprocessAnnotations(java.lang.Object instance, java.util.Map<java.lang.String,java.lang.String> injections)Inject resources in specified instance.
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm The string manager for this package.
 - 
classLoaderprotected final java.lang.ClassLoader classLoader 
 - 
containerClassLoaderprotected final java.lang.ClassLoader containerClassLoader 
 - 
privilegedprotected final boolean privileged 
 - 
ignoreAnnotationsprotected final boolean ignoreAnnotations 
 
- 
 - 
Constructor Detail- 
DefaultInstanceManagerpublic DefaultInstanceManager(javax.naming.Context context, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> injectionMap, Context catalinaContext, java.lang.ClassLoader containerClassLoader)
 
- 
 - 
Method Detail- 
newInstancepublic java.lang.Object newInstance(java.lang.Class<?> clazz) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, javax.naming.NamingException, java.lang.InstantiationException, java.lang.IllegalArgumentException, java.lang.NoSuchMethodException, java.lang.SecurityException- Specified by:
- newInstancein interface- InstanceManager
- Throws:
- java.lang.IllegalAccessException
- java.lang.reflect.InvocationTargetException
- javax.naming.NamingException
- java.lang.InstantiationException
- java.lang.IllegalArgumentException
- java.lang.NoSuchMethodException
- java.lang.SecurityException
 
 - 
newInstancepublic java.lang.Object newInstance(java.lang.String className) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, javax.naming.NamingException, java.lang.InstantiationException, java.lang.ClassNotFoundException, java.lang.IllegalArgumentException, java.lang.NoSuchMethodException, java.lang.SecurityException- Specified by:
- newInstancein interface- InstanceManager
- Throws:
- java.lang.IllegalAccessException
- java.lang.reflect.InvocationTargetException
- javax.naming.NamingException
- java.lang.InstantiationException
- java.lang.ClassNotFoundException
- java.lang.IllegalArgumentException
- java.lang.NoSuchMethodException
- java.lang.SecurityException
 
 - 
newInstancepublic java.lang.Object newInstance(java.lang.String className, java.lang.ClassLoader classLoader) throws java.lang.IllegalAccessException, javax.naming.NamingException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException, java.lang.ClassNotFoundException, java.lang.IllegalArgumentException, java.lang.NoSuchMethodException, java.lang.SecurityException- Specified by:
- newInstancein interface- InstanceManager
- Throws:
- java.lang.IllegalAccessException
- javax.naming.NamingException
- java.lang.reflect.InvocationTargetException
- java.lang.InstantiationException
- java.lang.ClassNotFoundException
- java.lang.IllegalArgumentException
- java.lang.NoSuchMethodException
- java.lang.SecurityException
 
 - 
newInstancepublic void newInstance(java.lang.Object o) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, javax.naming.NamingException- Specified by:
- newInstancein interface- InstanceManager
- Throws:
- java.lang.IllegalAccessException
- java.lang.reflect.InvocationTargetException
- javax.naming.NamingException
 
 - 
destroyInstancepublic void destroyInstance(java.lang.Object instance) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException- Specified by:
- destroyInstancein interface- InstanceManager
- Throws:
- java.lang.IllegalAccessException
- java.lang.reflect.InvocationTargetException
 
 - 
postConstructprotected void postConstruct(java.lang.Object instance, java.lang.Class<?> clazz) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionCall postConstruct method on the specified instance recursively from deepest superclass to actual class.- Parameters:
- instance- object to call postconstruct methods on
- clazz- (super) class to examine for postConstruct annotation.
- Throws:
- java.lang.IllegalAccessException- if postConstruct method is inaccessible.
- java.lang.reflect.InvocationTargetException- if call fails
 
 - 
preDestroyprotected void preDestroy(java.lang.Object instance, java.lang.Class<?> clazz) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionCall preDestroy method on the specified instance recursively from deepest superclass to actual class.- Parameters:
- instance- object to call preDestroy methods on
- clazz- (super) class to examine for preDestroy annotation.
- Throws:
- java.lang.IllegalAccessException- if preDestroy method is inaccessible.
- java.lang.reflect.InvocationTargetException- if call fails
 
 - 
backgroundProcesspublic void backgroundProcess() Description copied from interface:InstanceManagerCalled by the component using the InstanceManager periodically to perform any regular maintenance that might be required. By default, this method is a NO-OP.- Specified by:
- backgroundProcessin interface- InstanceManager
 
 - 
populateAnnotationsCacheprotected void populateAnnotationsCache(java.lang.Class<?> clazz, java.util.Map<java.lang.String,java.lang.String> injections) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, javax.naming.NamingExceptionMake sure that the annotations cache has been populated for the provided class.- Parameters:
- clazz- clazz to populate annotations for
- injections- map of injections for this class from xml deployment descriptor
- Throws:
- java.lang.IllegalAccessException- if injection target is inaccessible
- javax.naming.NamingException- if value cannot be looked up in jndi
- java.lang.reflect.InvocationTargetException- if injection fails
 
 - 
processAnnotationsprotected void processAnnotations(java.lang.Object instance, java.util.Map<java.lang.String,java.lang.String> injections) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, javax.naming.NamingExceptionInject resources in specified instance.- Parameters:
- instance- instance to inject into
- injections- map of injections for this class from xml deployment descriptor
- Throws:
- java.lang.IllegalAccessException- if injection target is inaccessible
- javax.naming.NamingException- if value cannot be looked up in jndi
- java.lang.reflect.InvocationTargetException- if injection fails
 
 - 
getAnnotationCacheSizeprotected int getAnnotationCacheSize() Makes cache size available to unit tests.- Returns:
- the cache size
 
 - 
loadClassMaybePrivilegedprotected java.lang.Class<?> loadClassMaybePrivileged(java.lang.String className, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException- Throws:
- java.lang.ClassNotFoundException
 
 - 
loadClassprotected java.lang.Class<?> loadClass(java.lang.String className, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException- Throws:
- java.lang.ClassNotFoundException
 
 - 
lookupFieldResourceprotected static void lookupFieldResource(javax.naming.Context context, java.lang.Object instance, java.lang.reflect.Field field, java.lang.String name, java.lang.Class<?> clazz) throws javax.naming.NamingException, java.lang.IllegalAccessExceptionInject resources in specified field.- Parameters:
- context- jndi context to extract value from
- instance- object to inject into
- field- field target for injection
- name- jndi name value is bound under
- clazz- class annotation is defined in
- Throws:
- java.lang.IllegalAccessException- if field is inaccessible
- javax.naming.NamingException- if value is not accessible in naming context
 
 - 
lookupMethodResourceprotected static void lookupMethodResource(javax.naming.Context context, java.lang.Object instance, java.lang.reflect.Method method, java.lang.String name, java.lang.Class<?> clazz) throws javax.naming.NamingException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionInject resources in specified method.- Parameters:
- context- jndi context to extract value from
- instance- object to inject into
- method- field target for injection
- name- jndi name value is bound under
- clazz- class annotation is defined in
- Throws:
- java.lang.IllegalAccessException- if method is inaccessible
- javax.naming.NamingException- if value is not accessible in naming context
- java.lang.reflect.InvocationTargetException- if setter call fails
 
 
- 
 
-