Class TagHandlerPool


  • public class TagHandlerPool
    extends java.lang.Object
    Pool of tag handlers that can be reused.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected InstanceManager instanceManager
      The instance manager used for tag handler creation.
      static java.lang.String OPTION_MAXSIZE
      Option name for the maximum pool size.
      static java.lang.String OPTION_TAGPOOL
      Option name for the tag pool class name.
      static java.lang.String OPTION_USEIMFORTAGS
      Option name for using InstanceManager for tag creation.
      protected boolean useInstanceManagerForTags
      Whether to use the instance manager for tag handler creation.
    • Constructor Summary

      Constructors 
      Constructor Description
      TagHandlerPool()
      Constructs a tag handler pool with the default capacity.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Tag get​(java.lang.Class<? extends Tag> handlerClass)
      Gets the next available tag handler from this tag handler pool, instantiating one if this tag handler pool is empty.
      protected static java.lang.String getOption​(ServletConfig config, java.lang.String name, java.lang.String defaultV)
      Retrieves a configuration option from the given servlet config, falling back to the servlet context init parameter, then to the default value.
      static TagHandlerPool getTagHandlerPool​(ServletConfig config)
      Creates or retrieves a TagHandlerPool for the given servlet configuration.
      protected void init​(ServletConfig config)
      Initializes this pool with settings from the given servlet configuration.
      void release()
      Calls the release() method of all available tag handlers in this tag handler pool.
      void reuse​(Tag handler)
      Adds the given tag handler to this tag handler pool, unless this tag handler pool has already reached its capacity, in which case the tag handler's release() method is called.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • OPTION_TAGPOOL

        public static final java.lang.String OPTION_TAGPOOL
        Option name for the tag pool class name.
        See Also:
        Constant Field Values
      • OPTION_MAXSIZE

        public static final java.lang.String OPTION_MAXSIZE
        Option name for the maximum pool size.
        See Also:
        Constant Field Values
      • OPTION_USEIMFORTAGS

        public static final java.lang.String OPTION_USEIMFORTAGS
        Option name for using InstanceManager for tag creation.
        See Also:
        Constant Field Values
      • instanceManager

        protected InstanceManager instanceManager
        The instance manager used for tag handler creation.
      • useInstanceManagerForTags

        protected boolean useInstanceManagerForTags
        Whether to use the instance manager for tag handler creation.
    • Constructor Detail

      • TagHandlerPool

        public TagHandlerPool()
        Constructs a tag handler pool with the default capacity.
    • Method Detail

      • getTagHandlerPool

        public static TagHandlerPool getTagHandlerPool​(ServletConfig config)
        Creates or retrieves a TagHandlerPool for the given servlet configuration.
        Parameters:
        config - the servlet configuration
        Returns:
        the tag handler pool instance
      • init

        protected void init​(ServletConfig config)
        Initializes this pool with settings from the given servlet configuration.
        Parameters:
        config - the servlet configuration
      • get

        public Tag get​(java.lang.Class<? extends Tag> handlerClass)
                throws JspException
        Gets the next available tag handler from this tag handler pool, instantiating one if this tag handler pool is empty.
        Parameters:
        handlerClass - Tag handler class
        Returns:
        Reused or newly instantiated tag handler
        Throws:
        JspException - if a tag handler cannot be instantiated
      • reuse

        public void reuse​(Tag handler)
        Adds the given tag handler to this tag handler pool, unless this tag handler pool has already reached its capacity, in which case the tag handler's release() method is called.
        Parameters:
        handler - Tag handler to add to this tag handler pool
      • release

        public void release()
        Calls the release() method of all available tag handlers in this tag handler pool.
      • getOption

        protected static java.lang.String getOption​(ServletConfig config,
                                                    java.lang.String name,
                                                    java.lang.String defaultV)
        Retrieves a configuration option from the given servlet config, falling back to the servlet context init parameter, then to the default value.
        Parameters:
        config - the servlet configuration
        name - the option name
        defaultV - the default value if not found
        Returns:
        the option value or the default