Class ToolInfo

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    OldToolInfo

    public class ToolInfo
    extends java.lang.Object
    implements java.io.Serializable
    Manages data needed to create instances of a tool. New instances are returned for every call to create(obj).
    Version:
    $Id: ToolInfo.java 511959 2007-02-26 19:24:39Z nbubna $
    Author:
    Nathan Bubna, Henning P. Schmiedehausen
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ToolInfo​(java.lang.String key, java.lang.Class clazz)
      Creates a new instance using the minimum required info necessary for a tool.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addProperties​(java.util.Map<java.lang.String,​java.lang.Object> parentProps)
      Adds a map of properties from a parent scope to the properties for this tool.
      protected java.util.Map<java.lang.String,​java.lang.Object> combine​(java.util.Map<java.lang.String,​java.lang.Object>... maps)  
      protected void configure​(java.lang.Object tool, java.util.Map<java.lang.String,​java.lang.Object> configuration)
      Actually performs configuration of the newly instantiated tool using the combined final set of configuration properties.
      java.lang.Object create​(java.util.Map<java.lang.String,​java.lang.Object> dynamicProperties)
      Returns a new instance of the tool.
      java.lang.String getClassname()  
      protected java.lang.reflect.Method getConfigure()  
      java.lang.String getKey()
      Accessors
      java.util.Map<java.lang.String,​java.lang.Object> getProperties()  
      protected java.util.Map<java.lang.String,​java.lang.Object> getProps()  
      java.lang.Class getToolClass()  
      boolean hasConfigure()  
      boolean hasPermission​(java.lang.String path)  
      protected void invoke​(java.lang.reflect.Method method, java.lang.Object tool, java.lang.Object param)  
      boolean isSkipSetters()  
      protected java.lang.Object newInstance()  
      java.lang.Object putProperty​(java.lang.String name, java.lang.Object value)
      Puts a new property for this tool.
      void restrictTo​(java.lang.String path)  
      void setClass​(java.lang.Class clazz)
      Tries to create an instance of the specified Class, then looks for a configure(Map) method.
      void setKey​(java.lang.String key)
      Mutators
      protected void setProperty​(java.lang.Object tool, java.lang.String name, java.lang.Object value)  
      void setSkipSetters​(boolean cfgOnly)  
      • Methods inherited from class java.lang.Object

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

      • CONFIGURE_METHOD_NAME

        public static final java.lang.String CONFIGURE_METHOD_NAME
        See Also:
        Constant Field Values
      • key

        private java.lang.String key
      • clazz

        private java.lang.Class clazz
      • restrictToIsExact

        private boolean restrictToIsExact
      • restrictTo

        private java.lang.String restrictTo
      • properties

        private java.util.Map<java.lang.String,​java.lang.Object> properties
      • skipSetters

        private java.lang.Boolean skipSetters
      • configure

        private transient java.lang.reflect.Method configure
    • Constructor Detail

      • ToolInfo

        public ToolInfo​(java.lang.String key,
                        java.lang.Class clazz)
        Creates a new instance using the minimum required info necessary for a tool.
    • Method Detail

      • setKey

        public void setKey​(java.lang.String key)
        Mutators
      • setClass

        public void setClass​(java.lang.Class clazz)
        Tries to create an instance of the specified Class, then looks for a configure(Map) method.
        Parameters:
        clazz - the java.lang.Class of the tool
      • restrictTo

        public void restrictTo​(java.lang.String path)
        Parameters:
        path - the full or partial request path restriction of the tool
      • setSkipSetters

        public void setSkipSetters​(boolean cfgOnly)
      • addProperties

        public void addProperties​(java.util.Map<java.lang.String,​java.lang.Object> parentProps)
        Adds a map of properties from a parent scope to the properties for this tool. Only new properties will be added; any that are already set for this tool will be ignored.
      • putProperty

        public java.lang.Object putProperty​(java.lang.String name,
                                            java.lang.Object value)
        Puts a new property for this tool.
      • getProps

        protected java.util.Map<java.lang.String,​java.lang.Object> getProps()
      • getKey

        public java.lang.String getKey()
        Accessors
      • getClassname

        public java.lang.String getClassname()
      • getToolClass

        public java.lang.Class getToolClass()
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.Object> getProperties()
      • hasConfigure

        public boolean hasConfigure()
      • isSkipSetters

        public boolean isSkipSetters()
      • hasPermission

        public boolean hasPermission​(java.lang.String path)
        Parameters:
        path - the path of a template requesting this tool
        Returns:
        true if the specified request path matches the restrictions of this tool. If there is no request path restriction for this tool, it will always return true.
      • create

        public java.lang.Object create​(java.util.Map<java.lang.String,​java.lang.Object> dynamicProperties)
        Returns a new instance of the tool. If the tool has an configure(Map) method, the new instance will be initialized using the given properties combined with whatever "constant" properties have been put into this ToolInfo.
      • configure

        protected void configure​(java.lang.Object tool,
                                 java.util.Map<java.lang.String,​java.lang.Object> configuration)
        Actually performs configuration of the newly instantiated tool using the combined final set of configuration properties. First, if the class lacks the SkipSetters annotation, then any specific setters matching the configuration keys are called, then the general configure(Map) method (if any) is called.
      • getConfigure

        protected java.lang.reflect.Method getConfigure()
      • newInstance

        protected java.lang.Object newInstance()
      • invoke

        protected void invoke​(java.lang.reflect.Method method,
                              java.lang.Object tool,
                              java.lang.Object param)
      • setProperty

        protected void setProperty​(java.lang.Object tool,
                                   java.lang.String name,
                                   java.lang.Object value)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • combine

        protected java.util.Map<java.lang.String,​java.lang.Object> combine​(java.util.Map<java.lang.String,​java.lang.Object>... maps)