Interface InstanceManager
- All Known Implementing Classes:
DefaultInstanceManager, SimpleInstanceManager
public interface InstanceManager
Interface for creating and managing instances of objects.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidCalled by the component using the InstanceManager periodically to perform any regular maintenance that might be required.voidDestroy the given instance, performing pre-destroy callbacks.newInstance(Class<?> clazz) Create a new instance of the given class.voidPerform dependency injection on the given object.newInstance(String className) Create a new instance of the class with the given name.newInstance(String fqcn, ClassLoader classLoader) Create a new instance of the class with the given name using the specified class loader.
-
Method Details
-
newInstance
Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, IllegalArgumentException, NoSuchMethodException, SecurityException Create a new instance of the given class.- Parameters:
clazz- The class to instantiate- Returns:
- the new instance
- Throws:
IllegalAccessException- if the class or its nullary constructor is not accessibleInvocationTargetException- if the nullary constructor throws an exceptionNamingException- if a naming exception is encounteredInstantiationException- if this Class represents an abstract class, an interface, an array class, a primitive type, or voidIllegalArgumentException- if this method is invoked with illegal argumentsNoSuchMethodException- if the nullary method cannot be foundSecurityException- if a security manager, s, is present
-
newInstance
Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException Create a new instance of the class with the given name.- Parameters:
className- The name of the class to instantiate- Returns:
- the new instance
- Throws:
IllegalAccessException- if the class or its nullary constructor is not accessibleInvocationTargetException- if the nullary constructor throws an exceptionNamingException- if a naming exception is encounteredInstantiationException- if this Class represents an abstract class, an interface, an array class, a primitive type, or voidClassNotFoundException- if the class cannot be foundIllegalArgumentException- if this method is invoked with illegal argumentsNoSuchMethodException- if the nullary method cannot be foundSecurityException- if a security manager, s, is present
-
newInstance
Object newInstance(String fqcn, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException Create 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:
IllegalAccessException- if the class or its nullary constructor is not accessibleInvocationTargetException- if the nullary constructor throws an exceptionNamingException- if a naming exception is encounteredInstantiationException- if this Class represents an abstract class, an interface, an array class, a primitive type, or voidClassNotFoundException- if the class cannot be foundIllegalArgumentException- if this method is invoked with illegal argumentsNoSuchMethodException- if the nullary method cannot be foundSecurityException- if a security manager, s, is present
-
newInstance
void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException Perform dependency injection on the given object.- Parameters:
o- The object to inject dependencies into- Throws:
IllegalAccessException- if the class or its nullary constructor is not accessibleInvocationTargetException- if the nullary constructor throws an exceptionNamingException- if a naming exception is encountered
-
destroyInstance
Destroy the given instance, performing pre-destroy callbacks.- Parameters:
o- The object to destroy- Throws:
IllegalAccessException- if the class or its nullary constructor is not accessibleInvocationTargetException- 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.
-