Package org.apache.catalina.core
Class DefaultInstanceManager
java.lang.Object
org.apache.catalina.core.DefaultInstanceManager
- All Implemented Interfaces:
- InstanceManager
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final ClassLoaderprotected final ClassLoaderprotected final booleanprotected final booleanprotected static final StringManagerThe string manager for this package.
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultInstanceManager(Context context, Map<String, Map<String, String>> injectionMap, Context catalinaContext, ClassLoader containerClassLoader) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidCalled by the component using the InstanceManager periodically to perform any regular maintenance that might be required.voiddestroyInstance(Object instance) protected intMakes cache size available to unit tests.protected Class<?>loadClass(String className, ClassLoader classLoader) protected Class<?>loadClassMaybePrivileged(String className, ClassLoader classLoader) protected static voidInject resources in specified field.protected static voidInject resources in specified method.newInstance(Class<?> clazz) voidnewInstance(String className) newInstance(String className, ClassLoader classLoader) protected voidpopulateAnnotationsCache(Class<?> clazz, Map<String, String> injections) Make sure that the annotations cache has been populated for the provided class.protected voidpostConstruct(Object instance, Class<?> clazz) Call postConstruct method on the specified instance recursively from deepest superclass to actual class.protected voidpreDestroy(Object instance, Class<?> clazz) Call preDestroy method on the specified instance recursively from deepest superclass to actual class.protected voidprocessAnnotations(Object instance, Map<String, String> injections) Inject resources in specified instance.
- 
Field Details- 
smThe string manager for this package.
- 
classLoader
- 
containerClassLoader
- 
privilegedprotected final boolean privileged
- 
ignoreAnnotationsprotected final boolean ignoreAnnotations
 
- 
- 
Constructor Details- 
DefaultInstanceManager
 
- 
- 
Method Details- 
newInstancepublic Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, IllegalArgumentException, NoSuchMethodException, SecurityException - Specified by:
- newInstancein interface- InstanceManager
- Throws:
- IllegalAccessException
- InvocationTargetException
- NamingException
- InstantiationException
- IllegalArgumentException
- NoSuchMethodException
- SecurityException
 
- 
newInstancepublic Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException 
- 
newInstancepublic Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, NamingException, InvocationTargetException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException 
- 
newInstancepublic void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException - Specified by:
- newInstancein interface- InstanceManager
- Throws:
- IllegalAccessException
- InvocationTargetException
- NamingException
 
- 
destroyInstancepublic void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException - Specified by:
- destroyInstancein interface- InstanceManager
- Throws:
- IllegalAccessException
- InvocationTargetException
 
- 
postConstructprotected void postConstruct(Object instance, Class<?> clazz) throws IllegalAccessException, InvocationTargetException Call 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:
- IllegalAccessException- if postConstruct method is inaccessible.
- InvocationTargetException- if call fails
 
- 
preDestroyprotected void preDestroy(Object instance, Class<?> clazz) throws IllegalAccessException, InvocationTargetException Call 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:
- IllegalAccessException- if preDestroy method is inaccessible.
- 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(Class<?> clazz, Map<String, String> injections) throws IllegalAccessException, InvocationTargetException, 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:
- IllegalAccessException- if injection target is inaccessible
- NamingException- if value cannot be looked up in jndi
- InvocationTargetException- if injection fails
 
- 
processAnnotationsprotected void processAnnotations(Object instance, Map<String, String> injections) throws IllegalAccessException, InvocationTargetException, NamingExceptionInject resources in specified instance.- Parameters:
- instance- instance to inject into
- injections- map of injections for this class from xml deployment descriptor
- Throws:
- IllegalAccessException- if injection target is inaccessible
- NamingException- if value cannot be looked up in jndi
- InvocationTargetException- if injection fails
 
- 
getAnnotationCacheSizeprotected int getAnnotationCacheSize()Makes cache size available to unit tests.- Returns:
- the cache size
 
- 
loadClassMaybePrivilegedprotected Class<?> loadClassMaybePrivileged(String className, ClassLoader classLoader) throws ClassNotFoundException - Throws:
- ClassNotFoundException
 
- 
loadClassprotected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException - Throws:
- ClassNotFoundException
 
- 
lookupFieldResourceprotected static void lookupFieldResource(Context context, Object instance, Field field, String name, Class<?> clazz) throws NamingException, IllegalAccessException Inject 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:
- IllegalAccessException- if field is inaccessible
- NamingException- if value is not accessible in naming context
 
- 
lookupMethodResourceprotected static void lookupMethodResource(Context context, Object instance, Method method, String name, Class<?> clazz) throws NamingException, IllegalAccessException, InvocationTargetException Inject 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:
- IllegalAccessException- if method is inaccessible
- NamingException- if value is not accessible in naming context
- InvocationTargetException- if setter call fails
 
 
-