Top Inners Fields Constructors Methods
org.apache.catalina.core

public Class DefaultInstanceManager

extends Object
implements InstanceManager
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.InstanceManager
Imports
java.io.IOException, .InputStream, java.lang.annotation.Annotation, java.lang.reflect.Field, .InvocationTargetException, .Method, java.security.AccessController, .PrivilegedAction, .PrivilegedActionException, .PrivilegedExceptionAction, java.util.ArrayList, .Collections, .HashMap, .HashSet, .List, .Map, .Properties, .Set, javax.naming.Context, .NamingException, jakarta.annotation.PostConstruct, .PreDestroy, .Resource, jakarta.ejb.EJB, jakarta.persistence.PersistenceContext, .PersistenceUnit, jakarta.xml.ws.WebServiceRef, org.apache.catalina.ContainerServlet, .Globals, org.apache.catalina.security.SecurityUtil, org.apache.catalina.util.Introspection, org.apache.juli.logging.Log, org.apache.tomcat.InstanceManager, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.collections.ManagedConcurrentWeakHashMap, org.apache.tomcat.util.res.StringManager

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static enum
private static class
private static class
private class

Field Summary

Modifier and TypeField and Description
private final ManagedConcurrentWeakHashMap<Class<?>, DefaultInstanceManager.AnnotationCacheEntry[]>
private static final DefaultInstanceManager.AnnotationCacheEntry[]
protected final ClassLoader
protected final ClassLoader
private final Context
private static final boolean
protected final boolean
private final Map<String, Map<String, String>>
private static final boolean
private final Map<String, String>
private final Map<String, String>
protected final boolean
private final Set<String>
protected static final StringManager
sm

The string manager for this package.

private static final boolean

Constructor Summary

AccessConstructor and Description
public
DefaultInstanceManager(Context context, Map<String, Map<String, String>> injectionMap, Context catalinaContext, ClassLoader containerClassLoader)

Method Summary

Modifier and TypeMethod and Description
private Map<String, String>
public void
backgroundProcess()

Overrides default org.apache.tomcat.InstanceManager.backgroundProcess.

Called by the component using the InstanceManager periodically to perform any regular maintenance that might be required.

private void
checkAccess(Class<?> clazz)

public void
private static Method
findLifecycleCallback(Method currentMethod, String methodNameFromXml, Method method, Class<? extends Annotation> annotation)

private static Method
findPostConstruct(Method currentPostConstruct, String postConstructFromXml, Method method)

private static Method
findPreDestroy(Method currentPreDestroy, String preDestroyFromXml, Method method)

protected int

Returns:

the cache size
getAnnotationCacheSize
()

Makes cache size available to unit tests.

private static Field
private static Method
protected Class<?>
loadClass(String className, ClassLoader classLoader)

protected Class<?>
loadClassMaybePrivileged(final String className, final ClassLoader classLoader)

private static void
loadProperties(Set<String> classNames, String resourceName, String messageKey, Log log)

protected static void
lookupFieldResource(Context
jndi context to extract value from
context
,
Object
object to inject into
instance
,
Field
field target for injection
field
,
String
jndi name value is bound under
name
,
Class<?>
class annotation is defined in
clazz
)

Inject resources in specified field.

protected static void
lookupMethodResource(Context
jndi context to extract value from
context
,
Object
object to inject into
instance
,
Method
field target for injection
method
,
String
jndi name value is bound under
name
,
Class<?>
class annotation is defined in
clazz
)

Inject resources in specified method.

public Object
public Object
public Object
newInstance(final String className, final ClassLoader classLoader)

Implements org.apache.tomcat.InstanceManager.newInstance.

public void
private Object
newInstance(Object instance, Class<?> clazz)

private static String
normalize(String jndiName)

protected void
populateAnnotationsCache(Class<?>
clazz to populate annotations for
clazz
,
Map<String, String>
map of injections for this class from xml deployment descriptor
injections
)

Make sure that the annotations cache has been populated for the provided class.

protected void
postConstruct(Object
object to call postconstruct methods on
instance
,
final Class<?>
(super) class to examine for postConstruct annotation.
clazz
)

Call postConstruct method on the specified instance recursively from deepest superclass to actual class.

protected void
preDestroy(Object
object to call preDestroy methods on
instance
,
final Class<?>
(super) class to examine for preDestroy annotation.
clazz
)

Call preDestroy method on the specified instance recursively from deepest superclass to actual class.

protected void
processAnnotations(Object
instance to inject into
instance
,
Map<String, String>
map of injections for this class from xml deployment descriptor
injections
)

Inject resources in specified instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationCacheback to summary
private final ManagedConcurrentWeakHashMap<Class<?>, DefaultInstanceManager.AnnotationCacheEntry[]> annotationCache
ANNOTATIONS_EMPTYback to summary
private static final DefaultInstanceManager.AnnotationCacheEntry[] ANNOTATIONS_EMPTY
classLoaderback to summary
protected final ClassLoader classLoader
containerClassLoaderback to summary
protected final ClassLoader containerClassLoader
contextback to summary
private final Context context
EJB_PRESENTback to summary
private static final boolean EJB_PRESENT
ignoreAnnotationsback to summary
protected final boolean ignoreAnnotations
injectionMapback to summary
private final Map<String, Map<String, String>> injectionMap
JPA_PRESENTback to summary
private static final boolean JPA_PRESENT
postConstructMethodsback to summary
private final Map<String, String> postConstructMethods
preDestroyMethodsback to summary
private final Map<String, String> preDestroyMethods
privilegedback to summary
protected final boolean privileged
restrictedClassesback to summary
private final Set<String> restrictedClasses
smback to summary
protected static final StringManager sm

The string manager for this package.

WS_PRESENTback to summary
private static final boolean WS_PRESENT

Constructor Detail

DefaultInstanceManagerback to summary
public DefaultInstanceManager(Context context, Map<String, Map<String, String>> injectionMap, Context catalinaContext, ClassLoader containerClassLoader)

Method Detail

assembleInjectionsFromClassHierarchyback to summary
private Map<String, String> assembleInjectionsFromClassHierarchy(Class<?> clazz)
backgroundProcessback to summary
public void backgroundProcess()

Overrides default org.apache.tomcat.InstanceManager.backgroundProcess.

Doc from org.apache.tomcat.InstanceManager.backgroundProcess.

Called by the component using the InstanceManager periodically to perform any regular maintenance that might be required. By default, this method is a NO-OP.

Annotations
@Override
checkAccessback to summary
private void checkAccess(Class<?> clazz)
destroyInstanceback to summary
public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException

Implements org.apache.tomcat.InstanceManager.destroyInstance.

Annotations
@Override
findLifecycleCallbackback to summary
private static Method findLifecycleCallback(Method currentMethod, String methodNameFromXml, Method method, Class<? extends Annotation> annotation)
findPostConstructback to summary
private static Method findPostConstruct(Method currentPostConstruct, String postConstructFromXml, Method method)
findPreDestroyback to summary
private static Method findPreDestroy(Method currentPreDestroy, String preDestroyFromXml, Method method)
getAnnotationCacheSizeback to summary
protected int getAnnotationCacheSize()

Makes cache size available to unit tests.

Returns:int

the cache size

getFieldback to summary
private static Field getField(final Class<?> clazz, final DefaultInstanceManager.AnnotationCacheEntry entry)
getMethodback to summary
private static Method getMethod(final Class<?> clazz, final DefaultInstanceManager.AnnotationCacheEntry entry)
loadClassback to summary
protected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException
loadClassMaybePrivilegedback to summary
protected Class<?> loadClassMaybePrivileged(final String className, final ClassLoader classLoader) throws ClassNotFoundException
loadPropertiesback to summary
private static void loadProperties(Set<String> classNames, String resourceName, String messageKey, Log log)
lookupFieldResourceback to summary
protected static void lookupFieldResource(Context context, Object instance, Field field, String name, Class<?> clazz) throws NamingException, IllegalAccessException

Inject resources in specified field.

Parameters
context:Context

jndi context to extract value from

instance:Object

object to inject into

field:Field

field target for injection

name:String

jndi name value is bound under

clazz:Class<?>

class annotation is defined in

Exceptions
NamingException:
if value is not accessible in naming context
IllegalAccessException:
if field is inaccessible
lookupMethodResourceback to summary
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:Context

jndi context to extract value from

instance:Object

object to inject into

method:Method

field target for injection

name:String

jndi name value is bound under

clazz:Class<?>

class annotation is defined in

Exceptions
NamingException:
if value is not accessible in naming context
IllegalAccessException:
if method is inaccessible
InvocationTargetException:
if setter call fails
newInstanceback to summary
public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, IllegalArgumentException, NoSuchMethodException, SecurityException

Implements org.apache.tomcat.InstanceManager.newInstance.

Annotations
@Override
newInstanceback to summary
public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException

Implements org.apache.tomcat.InstanceManager.newInstance.

Annotations
@Override
newInstanceback to summary
public Object newInstance(final String className, final ClassLoader classLoader) throws IllegalAccessException, NamingException, InvocationTargetException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException

Implements org.apache.tomcat.InstanceManager.newInstance.

Annotations
@Override
newInstanceback to summary
public void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException

Implements org.apache.tomcat.InstanceManager.newInstance.

Annotations
@Override
newInstanceback to summary
private Object newInstance(Object instance, Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException
normalizeback to summary
private static String normalize(String jndiName)
populateAnnotationsCacheback to summary
protected void populateAnnotationsCache(Class<?> clazz, Map<String, String> injections) throws IllegalAccessException, InvocationTargetException, NamingException

Make sure that the annotations cache has been populated for the provided class.

Parameters
clazz:Class<?>

clazz to populate annotations for

injections:Map<String, String>

map of injections for this class from xml deployment descriptor

Exceptions
IllegalAccessException:
if injection target is inaccessible
InvocationTargetException:
if injection fails
NamingException:
if value cannot be looked up in jndi
postConstructback to summary
protected void postConstruct(Object instance, final Class<?> clazz) throws IllegalAccessException, InvocationTargetException

Call postConstruct method on the specified instance recursively from deepest superclass to actual class.

Parameters
instance:Object

object to call postconstruct methods on

clazz:Class<?>

(super) class to examine for postConstruct annotation.

Exceptions
IllegalAccessException:
if postConstruct method is inaccessible.
InvocationTargetException:
if call fails
preDestroyback to summary
protected void preDestroy(Object instance, final Class<?> clazz) throws IllegalAccessException, InvocationTargetException

Call preDestroy method on the specified instance recursively from deepest superclass to actual class.

Parameters
instance:Object

object to call preDestroy methods on

clazz:Class<?>

(super) class to examine for preDestroy annotation.

Exceptions
IllegalAccessException:
if preDestroy method is inaccessible.
InvocationTargetException:
if call fails
processAnnotationsback to summary
protected void processAnnotations(Object instance, Map<String, String> injections) throws IllegalAccessException, InvocationTargetException, NamingException

Inject resources in specified instance.

Parameters
instance:Object

instance to inject into

injections:Map<String, String>

map of injections for this class from xml deployment descriptor

Exceptions
IllegalAccessException:
if injection target is inaccessible
InvocationTargetException:
if injection fails
NamingException:
if value cannot be looked up in jndi
org.apache.catalina.core back to summary

private final Class DefaultInstanceManager.AnnotationCacheEntry

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.catalina.core.DefaultInstanceManager.AnnotationCacheEntry

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final Class<?>[]
private final DefaultInstanceManager.AnnotationCacheEntryType

Constructor Summary

AccessConstructor and Description
pack-priv
AnnotationCacheEntry(String accessibleObjectName, Class<?>[] paramTypes, String name, DefaultInstanceManager.AnnotationCacheEntryType type)

Method Summary

Modifier and TypeMethod and Description
public String
public String
public Class<?>[]
public DefaultInstanceManager.AnnotationCacheEntryType
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessibleObjectNameback to summary
private final String accessibleObjectName
nameback to summary
private final String name
paramTypesback to summary
private final Class<?>[] paramTypes
typeback to summary
private final DefaultInstanceManager.AnnotationCacheEntryType type

Constructor Detail

AnnotationCacheEntryback to summary
pack-priv AnnotationCacheEntry(String accessibleObjectName, Class<?>[] paramTypes, String name, DefaultInstanceManager.AnnotationCacheEntryType type)

Method Detail

getAccessibleObjectNameback to summary
public String getAccessibleObjectName()
getNameback to summary
public String getName()
getParamTypesback to summary
public Class<?>[] getParamTypes()
getTypeback to summary
public DefaultInstanceManager.AnnotationCacheEntryType getType()
org.apache.catalina.core back to summary

private final Enum DefaultInstanceManager.AnnotationCacheEntryType

extends Enum<DefaultInstanceManager.AnnotationCacheEntryType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final DefaultInstanceManager.AnnotationCacheEntryType
public static final DefaultInstanceManager.AnnotationCacheEntryType
public static final DefaultInstanceManager.AnnotationCacheEntryType
public static final DefaultInstanceManager.AnnotationCacheEntryType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static DefaultInstanceManager.AnnotationCacheEntryType
public static DefaultInstanceManager.AnnotationCacheEntryType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FIELDback to summary
public static final DefaultInstanceManager.AnnotationCacheEntryType FIELD
POST_CONSTRUCTback to summary
public static final DefaultInstanceManager.AnnotationCacheEntryType POST_CONSTRUCT
PRE_DESTROYback to summary
public static final DefaultInstanceManager.AnnotationCacheEntryType PRE_DESTROY
SETTERback to summary
public static final DefaultInstanceManager.AnnotationCacheEntryType SETTER

Constructor Detail

AnnotationCacheEntryTypeback to summary
private AnnotationCacheEntryType()

Method Detail

valueOfback to summary
public static DefaultInstanceManager.AnnotationCacheEntryType valueOf(String name)
valuesback to summary
public static DefaultInstanceManager.AnnotationCacheEntryType[] values()
org.apache.catalina.core back to summary

private Class DefaultInstanceManager.PrivilegedGetField

extends Object
implements PrivilegedAction<Field>
Class Inheritance
  • java.lang.Object
  • org.apache.catalina.core.DefaultInstanceManager.PrivilegedGetField
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final DefaultInstanceManager.AnnotationCacheEntry

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Field
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
private final Class<?> clazz
entryback to summary
private final DefaultInstanceManager.AnnotationCacheEntry entry

Constructor Detail

PrivilegedGetFieldback to summary
pack-priv PrivilegedGetField(Class<?> clazz, DefaultInstanceManager.AnnotationCacheEntry entry)

Method Detail

runback to summary
public Field run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Field

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override
org.apache.catalina.core back to summary

private Class DefaultInstanceManager.PrivilegedGetMethod

extends Object
implements PrivilegedAction<Method>
Class Inheritance
  • java.lang.Object
  • org.apache.catalina.core.DefaultInstanceManager.PrivilegedGetMethod
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final DefaultInstanceManager.AnnotationCacheEntry

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Method
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
private final Class<?> clazz
entryback to summary
private final DefaultInstanceManager.AnnotationCacheEntry entry

Constructor Detail

PrivilegedGetMethodback to summary
pack-priv PrivilegedGetMethod(Class<?> clazz, DefaultInstanceManager.AnnotationCacheEntry entry)

Method Detail

runback to summary
public Method run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Method

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override
org.apache.catalina.core back to summary

private Class DefaultInstanceManager.PrivilegedLoadClass

extends Object
implements PrivilegedExceptionAction<Class<?>>
Class Inheritance
  • java.lang.Object
  • org.apache.catalina.core.DefaultInstanceManager.PrivilegedLoadClass
All Implemented Interfaces
java.security.PrivilegedExceptionAction

Field Summary

Modifier and TypeField and Description
private final ClassLoader
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
PrivilegedLoadClass(String className, ClassLoader classLoader)

Method Summary

Modifier and TypeMethod and Description
public Class<?>
run()

Implements java.security.PrivilegedExceptionAction.run.

Performs the computation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderback to summary
private final ClassLoader classLoader
classNameback to summary
private final String className

Constructor Detail

PrivilegedLoadClassback to summary
pack-priv PrivilegedLoadClass(String className, ClassLoader classLoader)

Method Detail

runback to summary
public Class<?> run() throws Exception

Implements java.security.PrivilegedExceptionAction.run.

Doc from java.security.PrivilegedExceptionAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Class<?>

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedExceptionAction should document what (if anything) this value represents.

Annotations
@Override
Exceptions
Exception:
an exceptional condition has occurred. Each class that implements PrivilegedExceptionAction should document the exceptions that its run method can throw.