Package org.apache.tomcat
Interface InstanceManager
-
- All Known Implementing Classes:
DefaultInstanceManager,SimpleInstanceManager
public interface InstanceManagerInterface for creating and managing instances of objects.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidbackgroundProcess()Called by the component using the InstanceManager periodically to perform any regular maintenance that might be required.voiddestroyInstance(java.lang.Object o)Destroy the given instance, performing pre-destroy callbacks.java.lang.ObjectnewInstance(java.lang.Class<?> clazz)Create a new instance of the given class.voidnewInstance(java.lang.Object o)Perform dependency injection on the given object.java.lang.ObjectnewInstance(java.lang.String className)Create a new instance of the class with the given name.java.lang.ObjectnewInstance(java.lang.String fqcn, java.lang.ClassLoader classLoader)Create a new instance of the class with the given name using the specified class loader.
-
-
-
Method Detail
-
newInstance
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.SecurityExceptionCreate a new instance of the given class.- Parameters:
clazz- The class to instantiate- Returns:
- the new instance
- Throws:
java.lang.IllegalAccessException- if the class or its nullary constructor is not accessiblejava.lang.reflect.InvocationTargetException- if the nullary constructor throws an exceptionjavax.naming.NamingException- if a naming exception is encounteredjava.lang.InstantiationException- if this Class represents an abstract class, an interface, an array class, a primitive type, or voidjava.lang.IllegalArgumentException- if this method is invoked with illegal argumentsjava.lang.NoSuchMethodException- if the nullary method cannot be foundjava.lang.SecurityException- if a security manager, s, is present
-
newInstance
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.SecurityExceptionCreate a new instance of the class with the given name.- Parameters:
className- The name of the class to instantiate- Returns:
- the new instance
- Throws:
java.lang.IllegalAccessException- if the class or its nullary constructor is not accessiblejava.lang.reflect.InvocationTargetException- if the nullary constructor throws an exceptionjavax.naming.NamingException- if a naming exception is encounteredjava.lang.InstantiationException- if this Class represents an abstract class, an interface, an array class, a primitive type, or voidjava.lang.ClassNotFoundException- if the class cannot be foundjava.lang.IllegalArgumentException- if this method is invoked with illegal argumentsjava.lang.NoSuchMethodException- if the nullary method cannot be foundjava.lang.SecurityException- if a security manager, s, is present
-
newInstance
java.lang.Object newInstance(java.lang.String fqcn, java.lang.ClassLoader classLoader) 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.SecurityExceptionCreate a new instance of the class with the given name using the specified class loader.- Parameters:
fqcn- The fully qualified class nameclassLoader- The class loader to use for loading the class- Returns:
- the new instance
- Throws:
java.lang.IllegalAccessException- if the class or its nullary constructor is not accessiblejava.lang.reflect.InvocationTargetException- if the nullary constructor throws an exceptionjavax.naming.NamingException- if a naming exception is encounteredjava.lang.InstantiationException- if this Class represents an abstract class, an interface, an array class, a primitive type, or voidjava.lang.ClassNotFoundException- if the class cannot be foundjava.lang.IllegalArgumentException- if this method is invoked with illegal argumentsjava.lang.NoSuchMethodException- if the nullary method cannot be foundjava.lang.SecurityException- if a security manager, s, is present
-
newInstance
void newInstance(java.lang.Object o) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, javax.naming.NamingExceptionPerform dependency injection on the given object.- Parameters:
o- The object to inject dependencies into- Throws:
java.lang.IllegalAccessException- if the class or its nullary constructor is not accessiblejava.lang.reflect.InvocationTargetException- if the nullary constructor throws an exceptionjavax.naming.NamingException- if a naming exception is encountered
-
destroyInstance
void destroyInstance(java.lang.Object o) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionDestroy the given instance, performing pre-destroy callbacks.- Parameters:
o- The object to destroy- Throws:
java.lang.IllegalAccessException- if the class or its nullary constructor is not accessiblejava.lang.reflect.InvocationTargetException- if the nullary constructor throws an exception
-
backgroundProcess
default void 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.
-
-