Class Configuration

  • All Implemented Interfaces:
    ConfigurationProvider

    public class Configuration
    extends java.lang.Object
    implements ConfigurationProvider
    This class extends the JNDIProvider and offers a common API to retrieve configuration parameter from JNDI context as specified by servlet spec, furthermore this class cascades the configuration via DbProperties allowing to manage dynamic properties from database. all API refer to "server" scope in sense of DbProperties scope, except of getClientParameters() which provides "client" scope configuration from database.
    • Constructor Detail

      • Configuration

        protected Configuration()
    • Method Detail

      • getConfigurationParameter

        public <T> T getConfigurationParameter​(java.lang.String id,
                                               T defaultValue)
        Description copied from interface: ConfigurationProvider
        getter for configuration parameter including downcast
        Specified by:
        getConfigurationParameter in interface ConfigurationProvider
        Returns:
        configuration parameter instance or defaultValue
      • getClientParameters

        public java.util.HashMap<java.lang.String,​java.lang.Object> getClientParameters()
        retrieve client properties
        Returns:
        client properties OR null in case no are specified or DbProperties is not available
      • getManagedConnection

        public java.sql.Connection getManagedConnection​(java.lang.String dbSourceName)
                                                 throws java.lang.Exception
        Parameters:
        dbSourceName -
        Returns:
        Throws:
        java.lang.Exception
      • getManagedConnection

        public java.sql.Connection getManagedConnection​(java.lang.String dbSourceName,
                                                        boolean closedByRequestLifeCycleFilter)
                                                 throws java.lang.Exception
        Parameters:
        dbSourceName -
        Returns:
        Throws:
        java.lang.Exception
      • getUnmanagedConnection

        public java.sql.Connection getUnmanagedConnection​(java.lang.String dbSourceName)
                                                   throws java.lang.Exception
        Parameters:
        dbSourceName -
        Returns:
        Throws:
        java.lang.Exception
      • getClassoption

        public static java.lang.Class<?> getClassoption​(Configuration.OPT_CLASSES name)
        Returns for a given token Configuration.OPT_CLASSES the 'best' class, or null if none 'Best' means the one with the highest priority according to optionalClassesPrio found in classpath Can be switched to CDI, once available on all platforms
        Parameters:
        name -
        Returns:
      • getClassInstance

        public static <T> T getClassInstance​(Configuration.OPT_CLASSES name,
                                             java.lang.Class<?>[] types,
                                             java.lang.Object... params)
                                      throws java.lang.RuntimeException
        like getClassoption(OPT_CLASSES) but looks for public constructor accepting given types and instantiates the class, with given params in case a class is not found this method returns null, in case a class is found but a constructor is missing, this method throws an exception.
        Parameters:
        name - of class binding
        types - to be accepted by constructor
        params - the params in exact order as types
        Returns:
        the instance of matched class or null in case no such class could be found
        Throws:
        java.lang.RuntimeException - in case the class is missing a constructor accepting given parameters or if the instantiation fails
      • getClassInstance

        public static <T> T getClassInstance​(java.lang.Class<?> clazz,
                                             java.lang.Class<?>[] types,
                                             java.lang.Object... params)
                                      throws java.lang.RuntimeException
        Looks for a public constructor accepting given types and instantiates the class, with given params. in case a class a constructor is missing, this method throws an exception.
        Parameters:
        clazz - to instantiate
        types - to be accepted by constructor
        params - the params in exact order as types
        Returns:
        the instance of matched class
        Throws:
        java.lang.RuntimeException - in case the class is missing a constructor accepting given parameters or if the instantiation fails