# Interface InstanceManager

All Known Implementing Classes:
  `DefaultInstanceManager, SimpleInstanceManager`

public interface InstanceManager
Interface for creating and managing instances of objects.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `backgroundProcess()`
  Called by the component using the InstanceManager periodically to perform any regular maintenance that might be required.
  `void`
  `destroyInstance(Object o)`
  Destroy the given instance, performing pre-destroy callbacks.
  `Object`
  `newInstance(Class<?> clazz)`
  Create a new instance of the given class.
  `void`
  `newInstance(Object o)`
  Perform dependency injection on the given object.
  `Object`
  `newInstance(String className)`
  Create a new instance of the class with the given name.
  `Object`
  `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 accessible
      `InvocationTargetException` - if the nullary constructor throws an exception
      `NamingException` - if a naming exception is encountered
      `InstantiationException` - if this Class represents an abstract class, an interface, an array class, a primitive type, or void
      `IllegalArgumentException` - if this method is invoked with illegal arguments
      `NoSuchMethodException` - if the nullary method cannot be found
      `SecurityException` - 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 accessible
      `InvocationTargetException` - if the nullary constructor throws an exception
      `NamingException` - if a naming exception is encountered
      `InstantiationException` - if this Class represents an abstract class, an interface, an array class, a primitive type, or void
      `ClassNotFoundException` - if the class cannot be found
      `IllegalArgumentException` - if this method is invoked with illegal arguments
      `NoSuchMethodException` - if the nullary method cannot be found
      `SecurityException` - 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 name
      `classLoader` - The class loader to use for loading the class
    Returns:
      the new instance
    Throws:
      `IllegalAccessException` - if the class or its nullary constructor is not accessible
      `InvocationTargetException` - if the nullary constructor throws an exception
      `NamingException` - if a naming exception is encountered
      `InstantiationException` - if this Class represents an abstract class, an interface, an array class, a primitive type, or void
      `ClassNotFoundException` - if the class cannot be found
      `IllegalArgumentException` - if this method is invoked with illegal arguments
      `NoSuchMethodException` - if the nullary method cannot be found
      `SecurityException` - 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 accessible
      `InvocationTargetException` - if the nullary constructor throws an exception
      `NamingException` - if a naming exception is encountered

  - ### destroyInstance

    void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException
    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 accessible
      `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.