Package org.apache.catalina.core
Class DefaultInstanceManager
java.lang.Object
org.apache.catalina.core.DefaultInstanceManager
- All Implemented Interfaces:
InstanceManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClassLoaderprotected final ClassLoaderprotected final booleanprotected final booleanprotected static final StringManagerThe string manager for this package. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultInstanceManager(Context context, Map<String, Map<String, String>> injectionMap, Context catalinaContext, ClassLoader containerClassLoader) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddestroyInstance(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
-
sm
The string manager for this package. -
classLoader
-
containerClassLoader
-
privileged
protected final boolean privileged -
ignoreAnnotations
protected final boolean ignoreAnnotations
-
-
Constructor Details
-
DefaultInstanceManager
-
-
Method Details
-
newInstance
public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, IllegalArgumentException, NoSuchMethodException, SecurityException - Specified by:
newInstancein interfaceInstanceManager- Throws:
IllegalAccessExceptionInvocationTargetExceptionNamingExceptionInstantiationExceptionIllegalArgumentExceptionNoSuchMethodExceptionSecurityException
-
newInstance
public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException -
newInstance
public Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, NamingException, InvocationTargetException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException -
newInstance
public void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException - Specified by:
newInstancein interfaceInstanceManager- Throws:
IllegalAccessExceptionInvocationTargetExceptionNamingException
-
destroyInstance
public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException - Specified by:
destroyInstancein interfaceInstanceManager- Throws:
IllegalAccessExceptionInvocationTargetException
-
postConstruct
protected 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 onclazz- (super) class to examine for postConstruct annotation.- Throws:
IllegalAccessException- if postConstruct method is inaccessible.InvocationTargetException- if call fails
-
preDestroy
protected 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 onclazz- (super) class to examine for preDestroy annotation.- Throws:
IllegalAccessException- if preDestroy method is inaccessible.InvocationTargetException- if call fails
-
backgroundProcess
public void backgroundProcess() -
populateAnnotationsCache
protected 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 forinjections- map of injections for this class from xml deployment descriptor- Throws:
IllegalAccessException- if injection target is inaccessibleNamingException- if value cannot be looked up in jndiInvocationTargetException- if injection fails
-
processAnnotations
protected void processAnnotations(Object instance, Map<String, String> injections) throws IllegalAccessException, InvocationTargetException, NamingExceptionInject resources in specified instance.- Parameters:
instance- instance to inject intoinjections- map of injections for this class from xml deployment descriptor- Throws:
IllegalAccessException- if injection target is inaccessibleNamingException- if value cannot be looked up in jndiInvocationTargetException- if injection fails
-
getAnnotationCacheSize
protected int getAnnotationCacheSize()Makes cache size available to unit tests.- Returns:
- the cache size
-
loadClassMaybePrivileged
protected Class<?> loadClassMaybePrivileged(String className, ClassLoader classLoader) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
loadClass
protected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
lookupFieldResource
protected 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 frominstance- object to inject intofield- field target for injectionname- jndi name value is bound underclazz- class annotation is defined in- Throws:
IllegalAccessException- if field is inaccessibleNamingException- if value is not accessible in naming context
-
lookupMethodResource
protected 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 frominstance- object to inject intomethod- field target for injectionname- jndi name value is bound underclazz- class annotation is defined in- Throws:
IllegalAccessException- if method is inaccessibleNamingException- if value is not accessible in naming contextInvocationTargetException- if setter call fails
-