org.apache.struts2.jasper.runtime

## Class InstanceHelper

- java.lang.Object
- - org.apache.struts2.jasper.runtime.InstanceHelper

-     public class InstanceHelper
      extends Object

  A helper module for processing instance objects using InstanceManager instances. Since AnnotationProcessor was removed in Tomcat 7+, this module performs a similar purpose using InstanceManager processing (the effective replacement). This module's logic is a blending of the original Struts 2 AnnotationHelper and logic ideas from an old Geronimo update (https://issues.apache.org/jira/browse/GERONIMO-3010) Original AnnotationHelper: Verify the annotation and Process it (@author Fabien Carrion, @author Remy Maucherat)

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static org.apache.tomcat.InstanceManager` | `getClassLoaderInstanceManager(ClassLoader classLoader)` Get the ``InstanceManager`` instance manager for a given ``ClassLoader`` instance, stored within the ``InstanceHelper` `Map``.
    `static org.apache.tomcat.InstanceManager` | `getServletInstanceManager(javax.servlet.ServletConfig servletConfig)` Get the ``InstanceManager`` instance manager for a given ``ServletConfig``.
    `static void` | `postConstruct(org.apache.tomcat.InstanceManager instanceManager, Object instance)` Post-construct an instance of the specified ``Object`` using the provided ``InstanceManager``.
    `static void` | `preDestroy(org.apache.tomcat.InstanceManager instanceManager, Object instance)` Pre-destroy an instance ``Object`` previously post-constructed with the provided ``InstanceManager``.
    `protected static void` | `setClassLoaderInstanceManager(ClassLoader classLoader, org.apache.tomcat.InstanceManager instanceManager)` Set the ``InstanceManager`` instance manager for a given ``ClassLoader`` instance, stored within the ``InstanceHelper` `Map``.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getServletInstanceManager

          public static org.apache.tomcat.InstanceManager getServletInstanceManager(javax.servlet.ServletConfig servletConfig)

      Get the ``InstanceManager`` instance manager for a given ``ServletConfig``. For any non-null servletConfig with a non-null ``ServletContext``, if no instance manager is defined, this method will produce a ``SimpleInstanceManager`` and associate it with that ``ServletConfig`` and its ``ClassLoader``.
      Parameters:
        `servletConfig` -
      Returns:

    - #### getClassLoaderInstanceManager

          public static org.apache.tomcat.InstanceManager getClassLoaderInstanceManager(ClassLoader classLoader)

      Get the ``InstanceManager`` instance manager for a given ``ClassLoader`` instance, stored within the ``InstanceHelper` `Map``. For any non-null classLoader, if no instance manager is defined, this method will produce a ``SimpleInstanceManager`` and associate it with that ``ClassLoader``.
      Parameters:
        `classLoader` -
      Returns:

    - #### setClassLoaderInstanceManager

          protected static void setClassLoaderInstanceManager(ClassLoader classLoader,
                                                              org.apache.tomcat.InstanceManager instanceManager)

      Set the ``InstanceManager`` instance manager for a given ``ClassLoader`` instance, stored within the ``InstanceHelper` `Map``.
      Parameters:
        `classLoader` -
        `instanceManager` -

    - #### postConstruct

          public static void postConstruct(org.apache.tomcat.InstanceManager instanceManager,
                                           Object instance)
                                    throws IllegalAccessException,
                                           IllegalArgumentException,
                                           InvocationTargetException,
                                           NamingException

      Post-construct an instance of the specified ``Object`` using the provided ``InstanceManager``. Note: This method replaces the old postContruct method in the AnnotationHelper. Note: In Jasper, this calls naming resources injection as well.
      Parameters:
        `instanceManager` -
        `instance` -
      Throws:
        `IllegalAccessException`
        `IllegalArgumentException`
        `InvocationTargetException`
        `NamingException`

    - #### preDestroy

          public static void preDestroy(org.apache.tomcat.InstanceManager instanceManager,
                                        Object instance)
                                 throws IllegalAccessException,
                                        IllegalArgumentException,
                                        InvocationTargetException

      Pre-destroy an instance ``Object`` previously post-constructed with the provided ``InstanceManager``. Note: This method replaces the old preDestroy method in the AnnotationHelper.
      Parameters:
        `instanceManager` - instance manager
        `instance` - object instance
      Throws:
        `IllegalAccessException`
        `IllegalArgumentException`
        `InvocationTargetException`

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.