Package de.businesscode.bcdui.toolbox
Class Configuration
java.lang.Object
de.businesscode.bcdui.toolbox.Configuration
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> void
addConfigurationParameter
(String id, T value) void
closeAllConnections
(boolean rollback) static <T> T
getClassInstance
(Configuration.OPT_CLASSES name, Class<?>[] types, Object... params) likegetClassoption(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.static <T> T
getClassInstance
(Class<?> clazz, Class<?>[] types, Object... params) 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.static Class<?>
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 platformsretrieve client propertiesretrieve a (mandatory) parameter or throw exception, also seeConfigurationProvider.getConfigurationParameterOrNull(String)
<T> T
getConfigurationParameter
(String id, T defaultValue) getter for configuration parameter including downcastretrieve parameterstatic Configuration
getManagedConnection
(String dbSourceName) getManagedConnection
(String dbSourceName, boolean closedByRequestLifeCycleFilter) getUnmanagedConnection
(String dbSourceName) getUnmanagedDataSource
(String dbSourceName) convenience getter forgetUnmanagedDataSource(String)
static boolean
-
Field Details
-
CONFIG_FILE_PATH_KEY
- See Also:
-
DISABLE_CACHE
- See Also:
-
VFS_CATALOG_KEY
- See Also:
-
CONFIG_DB_RELOAD_SEC
- See Also:
-
DEFAULT_DB_CONTEXT_ID
- See Also:
-
-
Constructor Details
-
Configuration
protected Configuration()
-
-
Method Details
-
getInstance
-
getConfigurationParameter
Description copied from interface:ConfigurationProvider
retrieve a (mandatory) parameter or throw exception, also seeConfigurationProvider.getConfigurationParameterOrNull(String)
- Specified by:
getConfigurationParameter
in interfaceConfigurationProvider
- Returns:
- configuration parameter instance
-
getConfigurationParameter
Description copied from interface:ConfigurationProvider
getter for configuration parameter including downcast- Specified by:
getConfigurationParameter
in interfaceConfigurationProvider
- Returns:
- configuration parameter instance or defaultValue
-
getConfigurationParameterOrNull
Description copied from interface:ConfigurationProvider
retrieve parameter- Specified by:
getConfigurationParameterOrNull
in interfaceConfigurationProvider
- Returns:
- configuration parameter instance or NULL
-
getClientParameters
retrieve client properties- Returns:
- client properties OR null in case no are specified or DbProperties is not available
-
isCacheDisabled
public static boolean isCacheDisabled()- Returns:
-
getManagedConnection
- Parameters:
dbSourceName
-- Returns:
- Throws:
Exception
-
getManagedConnection
public Connection getManagedConnection(String dbSourceName, boolean closedByRequestLifeCycleFilter) throws Exception - Parameters:
dbSourceName
-- Returns:
- Throws:
Exception
-
getUnmanagedConnection
- Parameters:
dbSourceName
-- Returns:
- Throws:
Exception
-
addConfigurationParameter
- Parameters:
id
-value
-
-
closeAllConnections
- Parameters:
rollback
-- Throws:
SQLException
-
getUnmanagedDataSource
convenience getter forgetUnmanagedDataSource(String)
- Parameters:
dbSourceName
-- Returns:
- see
getUnmanagedDataSource(String)
- Throws:
Exception
-
getClassoption
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, Class<?>[] types, Object... params) throws RuntimeException likegetClassoption(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 bindingtypes
- to be accepted by constructorparams
- the params in exact order as types- Returns:
- the instance of matched class or null in case no such class could be found
- Throws:
RuntimeException
- in case the class is missing a constructor accepting given parameters or if the instantiation fails
-
getClassInstance
public static <T> T getClassInstance(Class<?> clazz, Class<?>[] types, Object... params) throws 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 instantiatetypes
- to be accepted by constructorparams
- the params in exact order as types- Returns:
- the instance of matched class
- Throws:
RuntimeException
- in case the class is missing a constructor accepting given parameters or if the instantiation fails
-