Class AbstractPropertyInvoker

  • Direct Known Subclasses:
    LdapConfigPropertyInvoker, SimplePropertyInvoker

    public abstract class AbstractPropertyInvoker
    extends java.lang.Object
    AbstractPropertyInvoker provides methods common to property invokers.
    Version:
    $Revision: 1616 $ $Date: 2010-09-21 19:22:27 +0200 (Tue, 21 Sep 2010) $
    Author:
    Middleware Services
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Class<?> clazz
      Class to invoke methods on.
      protected org.apache.commons.logging.Log logger
      Log for this class.
      protected java.util.Map<java.lang.String,​java.lang.reflect.Method[]> properties
      Map of all properties to their getter and setter methods.
      protected static java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.reflect.Method[]>> PROPERTIES_CACHE
      Cache of properties.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract java.lang.Object convertValue​(java.lang.Class<?> type, java.lang.String value)
      This converts the supplied string value into an Object of the appropriate supplied type.
      static java.lang.Class<?> createClass​(java.lang.String className)
      Creates the class with the supplied name.
      java.util.Set<java.lang.String> getProperties()
      This returns the property keys.
      boolean hasProperty​(java.lang.String name)
      This returns whether the supplied property exists.
      protected void initialize​(java.lang.Class<?> c, java.lang.String domain)
      Initializes the properties map with the supplied class.
      static <T> T instantiateType​(T type, java.lang.String className)
      Creates an instance of the supplied type.
      static java.lang.Object invokeMethod​(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object arg)
      Invokes the supplied method on the supplied object with the supplied argument.
      void setProperty​(java.lang.Object object, java.lang.String name, java.lang.String value)
      This invokes the setter method for the supplied property name with the supplied value.
      • Methods inherited from class java.lang.Object

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

      • PROPERTIES_CACHE

        protected static final java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.reflect.Method[]>> PROPERTIES_CACHE
        Cache of properties.
      • logger

        protected final org.apache.commons.logging.Log logger
        Log for this class.
      • clazz

        protected java.lang.Class<?> clazz
        Class to invoke methods on.
      • properties

        protected java.util.Map<java.lang.String,​java.lang.reflect.Method[]> properties
        Map of all properties to their getter and setter methods.
    • Constructor Detail

      • AbstractPropertyInvoker

        public AbstractPropertyInvoker()
    • Method Detail

      • initialize

        protected void initialize​(java.lang.Class<?> c,
                                  java.lang.String domain)
        Initializes the properties map with the supplied class.
        Parameters:
        c - to read methods from
        domain - optional domain that properties are in
      • setProperty

        public void setProperty​(java.lang.Object object,
                                java.lang.String name,
                                java.lang.String value)
        This invokes the setter method for the supplied property name with the supplied value. If name or value is null, then this method does nothing.
        Parameters:
        object - Object to invoke method on
        name - String property name
        value - String property value
        Throws:
        java.lang.IllegalArgumentException - if an invocation exception occurs
      • convertValue

        protected abstract java.lang.Object convertValue​(java.lang.Class<?> type,
                                                         java.lang.String value)
        This converts the supplied string value into an Object of the appropriate supplied type. If value cannot be converted it is returned as is.
        Parameters:
        type - of object to convert value into
        value - to parse
        Returns:
        object of the supplied type
      • hasProperty

        public boolean hasProperty​(java.lang.String name)
        This returns whether the supplied property exists.
        Parameters:
        name - String to check
        Returns:
        boolean whether the supplied property exists
      • getProperties

        public java.util.Set<java.lang.String> getProperties()
        This returns the property keys.
        Returns:
        Set of property names
      • instantiateType

        public static <T> T instantiateType​(T type,
                                            java.lang.String className)
        Creates an instance of the supplied type.
        Type Parameters:
        T - type of class returned
        Parameters:
        type - of class to create
        className - to create
        Returns:
        class of type T
        Throws:
        java.lang.IllegalArgumentException - if the supplied class name cannot create a new instance of T
      • createClass

        public static java.lang.Class<?> createClass​(java.lang.String className)
        Creates the class with the supplied name.
        Parameters:
        className - to create
        Returns:
        class
        Throws:
        java.lang.IllegalArgumentException - if the supplied class name cannot be created
      • invokeMethod

        public static java.lang.Object invokeMethod​(java.lang.reflect.Method method,
                                                    java.lang.Object object,
                                                    java.lang.Object arg)
        Invokes the supplied method on the supplied object with the supplied argument.
        Parameters:
        method - Method to invoke
        object - Object to invoke method on
        arg - Object to invoke method with
        Returns:
        Object produced by the invocation
        Throws:
        java.lang.IllegalArgumentException - if an error occurs invoking the method