Apache Tomcat 7.0.42

## org.apache.catalina.core
Class DefaultInstanceManager

    java.lang.Object
      org.apache.catalina.core.DefaultInstanceManager

All Implemented Interfaces:
  InstanceManager

    public class DefaultInstanceManager

extends Object
implements InstanceManager

Version:
  $Id: DefaultInstanceManager.java 1437338 2013-01-23 11:02:35Z markt $

Field Summary
`protected ClassLoader` `classLoader`
`protected ClassLoader` `containerClassLoader`
`protected boolean` `ignoreAnnotations`
`protected boolean` `privileged`
`protected static StringManager` `sm` The string manager for this package.

Constructor Summary
`DefaultInstanceManager(Context context, Map<String,Map<String,String>> injectionMap, Context catalinaContext, ClassLoader containerClassLoader)`

Method Summary
`void` `destroyInstance(Object instance)`
`protected int` `getAnnotationCacheSize()` Makes cache size available to unit tests.
`static String` `getName(Method setter)` Deprecated.
`protected Class<?>` `loadClass(String className, ClassLoader classLoader)`
`protected Class<?>` `loadClassMaybePrivileged(String className, ClassLoader classLoader)`
`protected static void` `lookupFieldResource(Context context, Object instance, Field field, String name, Class<?> clazz)` Inject resources in specified field.
`protected static void` `lookupMethodResource(Context context, Object instance, Method method, String name, Class<?> clazz)` Inject resources in specified method.
`void` `newInstance(Object o)`
`Object` `newInstance(String className)`
`Object` `newInstance(String className, ClassLoader classLoader)`
`protected void` `populateAnnotationsCache(Class<?> clazz, Map<String,String> injections)` Make sure that the annotations cache has been populated for the provided class.
`protected void` `postConstruct(Object instance, Class<?> clazz)` Call postConstruct method on the specified instance recursively from deepest superclass to actual class.
`protected void` `preDestroy(Object instance, Class<?> clazz)` Call preDestroy method on the specified instance recursively from deepest superclass to actual class.
`protected void` `processAnnotations(Object instance, Map<String,String> injections)` Inject resources in specified instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### sm

    protected static final StringManager sm

  The string manager for this package.

### classLoader

    protected final ClassLoader classLoader

### containerClassLoader

    protected final ClassLoader containerClassLoader

### privileged

    protected boolean privileged

### ignoreAnnotations

    protected boolean ignoreAnnotations

Constructor Detail

### DefaultInstanceManager

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

Method Detail

### newInstance

    public Object newInstance(String className)
                       throws IllegalAccessException,
                              InvocationTargetException,
                              NamingException,
                              InstantiationException,
                              ClassNotFoundException

  Specified by:
    `newInstance` in interface `InstanceManager`
  Throws:
    `IllegalAccessException`
    `InvocationTargetException`
    `NamingException`
    `InstantiationException`
    `ClassNotFoundException`

### newInstance

    public Object newInstance(String className,
                              ClassLoader classLoader)
                       throws IllegalAccessException,
                              NamingException,
                              InvocationTargetException,
                              InstantiationException,
                              ClassNotFoundException

  Specified by:
    `newInstance` in interface `InstanceManager`
  Throws:
    `IllegalAccessException`
    `NamingException`
    `InvocationTargetException`
    `InstantiationException`
    `ClassNotFoundException`

### newInstance

    public void newInstance(Object o)
                     throws IllegalAccessException,
                            InvocationTargetException,
                            NamingException

  Specified by:
    `newInstance` in interface `InstanceManager`
  Throws:
    `IllegalAccessException`
    `InvocationTargetException`
    `NamingException`

### destroyInstance

    public void destroyInstance(Object instance)
                         throws IllegalAccessException,
                                InvocationTargetException

  Specified by:
    `destroyInstance` in interface `InstanceManager`
  Throws:
    `IllegalAccessException`
    `InvocationTargetException`

### 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 on
    `clazz` - (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 on
    `clazz` - (super) class to examine for preDestroy annotation.
  Throws:
    `IllegalAccessException` - if preDestroy method is inaccessible.
    `InvocationTargetException` - if call fails

### populateAnnotationsCache

    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` - clazz to populate annotations for
    `injections` - map of injections for this class from xml deployment descriptor
  Throws:
    `IllegalAccessException` - if injection target is inaccessible
    `NamingException` - if value cannot be looked up in jndi
    `InvocationTargetException` - if injection fails

### processAnnotations

    protected void processAnnotations(Object instance,
                                      Map<String,String> injections)
                               throws IllegalAccessException,
                                      InvocationTargetException,
                                      NamingException

  Inject resources in specified instance.

  Parameters:
    `instance` - instance to inject into
    `injections` - map of injections for this class from xml deployment descriptor
  Throws:
    `IllegalAccessException` - if injection target is inaccessible
    `NamingException` - if value cannot be looked up in jndi
    `InvocationTargetException` - if injection fails

### getAnnotationCacheSize

    protected int getAnnotationCacheSize()

  Makes cache size available to unit tests.

### 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 from
    `instance` - object to inject into
    `field` - field target for injection
    `name` - jndi name value is bound under
    `clazz` - class annotation is defined in
  Throws:
    `IllegalAccessException` - if field is inaccessible
    `NamingException` - 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 from
    `instance` - object to inject into
    `method` - field target for injection
    `name` - jndi name value is bound under
    `clazz` - class annotation is defined in
  Throws:
    `IllegalAccessException` - if method is inaccessible
    `NamingException` - if value is not accessible in naming context
    `InvocationTargetException` - if setter call fails

### getName

    @Deprecated
    public static String getName(Method setter)

  Deprecated.

Apache Tomcat 7.0.42

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.