Package com.saperion.config
Class SaJMXConfiguration
- java.lang.Object
-
- com.saperion.config.SaJMXConfiguration
-
- All Implemented Interfaces:
javax.management.DynamicMBean
public final class SaJMXConfiguration extends java.lang.Object implements javax.management.DynamicMBean
ADynamicMBean
implementation for the JMX system configuration.- Author:
- rbo
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CFG_TAG
Config tag.static java.lang.String
CONFIG_DIR
Configuration directory.static java.lang.String
ROOT_TAG
Root entry for Saperion.static java.lang.String
SYSTEM_CONFIG
System configuration name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNewProperties(java.lang.String name, SaAbstractJMXProperties props)
Add new property set.boolean
configureLog4j(SaJMXConstants.ConfigKey section)
Configures the Log4J system from the given section key.boolean
configureLog4j(java.lang.String section)
Configures the Log4J system from the given section.java.lang.String
getAbsoluteConfigPath(java.lang.String fileName)
returns an absolute path for the specified file name.java.lang.Object
getAttribute(java.lang.String attributeName)
javax.management.AttributeList
getAttributes(java.lang.String[] attributeNames)
boolean
getBooleanProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, boolean defaultValue)
Reads boolean property with default value.boolean
getBooleanProperty(java.lang.String name, boolean defaultValue)
Reads boolean property in dotted name format with default value.java.lang.String
getConfigDir()
SaJMXConstants.ConfigVariant
getConfigType()
Reads the configuration type.double
getDoubleProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, double defaultValue)
Reads double property with default value.double
getDoubleProperty(java.lang.String name, double defaultValue)
Reads double property in dotted name format with default value.java.io.File
getFileProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name)
Reads file property.java.lang.String
getFirstToken(java.lang.String value, java.lang.String delimiter)
Returns the first token of the given value, separated by the given delimiter.static SaJMXConfiguration
getInstance()
Get instance.int
getIntProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, int defaultValue)
Reads integer property with default value.int
getIntProperty(java.lang.String name, int defaultValue)
Reads integer property in dotted name format with default value.java.io.File
getLinkProperty(SaJMXConstants.ConfigKey configKey)
Reads linked file property.javax.management.MBeanInfo
getMBeanInfo()
int
getNumberOfTokens(SaJMXConstants.ConfigKey configKey, java.lang.String propertyName, java.lang.String delimiter)
Reads a multivalue property and returns the number of tokens separated by the given delimiter.java.util.Properties
getProperties(SaJMXConstants.ConfigKey key)
Reads a property set.java.util.Properties
getProperties(java.lang.String name)
Reads a property set.java.lang.String
getProperty(SaJMXConstants.ConfigKey configKey, java.lang.String key)
Returns the value for a given key from the given configuration.java.lang.String
getProperty(SaJMXConstants.ConfigKey configKey, java.lang.String key, java.lang.String defaultValue)
Returns the value for a given key from the given configuration with default value.java.lang.String
getProperty(java.lang.String name)
Reads property in dotted name format.java.lang.String
getProperty(java.lang.String name, java.lang.String defaultValue)
Reads property in dotted name format with default value.int
getSecondIntToken(java.lang.String value, java.lang.String delimiter, int defaultValue)
Returns the second token of the given value and converts it to int.java.lang.String[]
getTokens(SaJMXConstants.ConfigKey configKey, java.lang.String propertyName, java.lang.String delimiter)
Reads a multivalue property separated by the given delimiter and returns the values as String[].boolean
hasProperty(SaJMXConstants.ConfigKey configKey, java.lang.String propertyName)
Returns true if the property with the given name exists within the given configuration.boolean
hasSection(SaJMXConstants.ConfigKey key)
Checks, if the given section exists.boolean
hasSection(java.lang.String section)
Checks, if the given section exists.java.lang.Object
invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
boolean
isLog4jConfigured()
void
newBackendProperties(SaRMISystemCommand cmd, java.util.Properties sysprops)
Adds the backend properties to configuration.void
newFeatureProperties(SaRMISystemCommand cmd)
Adds the backend features to configuration.void
newLink(java.lang.String name, java.lang.String configFile)
Add a new property set to the configuration.void
newProperties(java.lang.String name, java.io.InputStream in)
Add a new stream property set to the configuration.void
newProperties(java.lang.String name, java.lang.String configFile)
Add a new property set to the configuration.void
newProperties(java.lang.String name, java.lang.String configFile, boolean isClassPathResource)
Add a new property set to the configuration.void
newXMLProperties(java.lang.String name, java.io.InputStream in)
Add a new XML property set to the configuration.void
newXMLProperties(java.lang.String name, java.lang.String configFile)
Add a new XML property set to the configuration.void
registerBean(java.lang.String name, java.lang.Object bean)
Register a new bean.void
registerBean(java.lang.String name, java.lang.Object bean, int port)
Register a new bean.void
setAttribute(javax.management.Attribute attribute)
javax.management.AttributeList
setAttributes(javax.management.AttributeList attributes)
void
setConfigType(SaJMXConstants.ConfigVariant type, java.lang.String mainFile)
Set the configuration type and main file.void
setConfigType(SaJMXConstants.ConfigVariant type, java.util.Properties configuration)
Set the configuration type and properties.void
setConfigTypeAndConfigDirectory(SaJMXConstants.ConfigVariant type, java.lang.String configurationDir)
Set the configuration type and configuration directory.void
setProperties(SaJMXConstants.ConfigKey key, java.util.Properties props)
sets a property set to the already existing configuration.
-
-
-
Field Detail
-
ROOT_TAG
public static final java.lang.String ROOT_TAG
Root entry for Saperion.- See Also:
- Constant Field Values
-
CFG_TAG
public static final java.lang.String CFG_TAG
Config tag.- See Also:
- Constant Field Values
-
SYSTEM_CONFIG
public static final java.lang.String SYSTEM_CONFIG
System configuration name.
-
CONFIG_DIR
public static final java.lang.String CONFIG_DIR
Configuration directory.
-
-
Method Detail
-
getInstance
public static SaJMXConfiguration getInstance()
Get instance.- Returns:
- Instance
-
getConfigDir
public java.lang.String getConfigDir()
-
getAbsoluteConfigPath
public java.lang.String getAbsoluteConfigPath(java.lang.String fileName)
returns an absolute path for the specified file name.- Parameters:
fileName
- the name of configuration file- Returns:
- the absolute path.
-
hasSection
public boolean hasSection(java.lang.String section)
Checks, if the given section exists.- Parameters:
section
- Section name- Returns:
- True, if exists
-
hasSection
public boolean hasSection(SaJMXConstants.ConfigKey key)
Checks, if the given section exists.- Parameters:
key
- Section key- Returns:
- True, if exists
-
addNewProperties
public void addNewProperties(java.lang.String name, SaAbstractJMXProperties props)
Add new property set.- Parameters:
name
- Nameprops
- Properties
-
registerBean
public void registerBean(java.lang.String name, java.lang.Object bean)
Register a new bean.- Parameters:
name
- Namebean
-
-
registerBean
public void registerBean(java.lang.String name, java.lang.Object bean, int port)
Register a new bean.- Parameters:
name
- Namebean
-port
-
-
configureLog4j
public boolean configureLog4j(java.lang.String section)
Configures the Log4J system from the given section.- Parameters:
section
- Section- Returns:
- Success
-
isLog4jConfigured
public boolean isLog4jConfigured()
- Returns:
- log4j configured
-
configureLog4j
public boolean configureLog4j(SaJMXConstants.ConfigKey section)
Configures the Log4J system from the given section key.- Parameters:
section
- Section key- Returns:
- Success
-
setConfigType
public void setConfigType(SaJMXConstants.ConfigVariant type, java.lang.String mainFile) throws java.io.FileNotFoundException
Set the configuration type and main file.- Parameters:
type
- Configuration typemainFile
- Main file name- Throws:
java.io.FileNotFoundException
- File not found.
-
setConfigType
public void setConfigType(SaJMXConstants.ConfigVariant type, java.util.Properties configuration)
Set the configuration type and properties.- Parameters:
type
- Configuration typeconfiguration
- Configuration properties
-
setConfigTypeAndConfigDirectory
public void setConfigTypeAndConfigDirectory(SaJMXConstants.ConfigVariant type, java.lang.String configurationDir) throws java.io.FileNotFoundException
Set the configuration type and configuration directory.- Parameters:
type
- Configuration typeconfigurationDir
- Configuration directory- Throws:
java.io.FileNotFoundException
- File not found.
-
getConfigType
public SaJMXConstants.ConfigVariant getConfigType()
Reads the configuration type.- Returns:
- Configuration type
-
newProperties
public void newProperties(java.lang.String name, java.lang.String configFile) throws java.io.IOException
Add a new property set to the configuration.- Parameters:
name
- Configuration nameconfigFile
- Configuration file name- Throws:
java.io.IOException
- Exception
-
newProperties
public void newProperties(java.lang.String name, java.lang.String configFile, boolean isClassPathResource) throws java.io.IOException
Add a new property set to the configuration.- Parameters:
name
- Configuration nameconfigFile
- Configuration file nameisClassPathResource
- true if configFile is a classpath related resource- Throws:
java.io.IOException
- Exception
-
newLink
public void newLink(java.lang.String name, java.lang.String configFile) throws java.io.IOException
Add a new property set to the configuration.- Parameters:
name
- Configuration nameconfigFile
- Configuration file name- Throws:
java.io.IOException
- Exception
-
newProperties
public void newProperties(java.lang.String name, java.io.InputStream in) throws java.io.IOException
Add a new stream property set to the configuration.- Parameters:
name
- Configuration namein
- Configuration stream- Throws:
java.io.IOException
- Exception
-
newXMLProperties
public void newXMLProperties(java.lang.String name, java.io.InputStream in) throws java.io.IOException
Add a new XML property set to the configuration.- Parameters:
name
- Configuration namein
- Configuration stream- Throws:
java.io.IOException
- Exception
-
newXMLProperties
public void newXMLProperties(java.lang.String name, java.lang.String configFile) throws java.io.IOException
Add a new XML property set to the configuration.- Parameters:
name
- Configuration nameconfigFile
- Configuration file name- Throws:
java.io.IOException
- Exception
-
newBackendProperties
public void newBackendProperties(SaRMISystemCommand cmd, java.util.Properties sysprops) throws java.rmi.RemoteException
Adds the backend properties to configuration.- Parameters:
cmd
- System commandssysprops
- Properties of section ApplicationServer- Throws:
java.rmi.RemoteException
- Exception
-
newFeatureProperties
public void newFeatureProperties(SaRMISystemCommand cmd) throws java.rmi.RemoteException
Adds the backend features to configuration.- Parameters:
cmd
- System commands- Throws:
java.rmi.RemoteException
- Exception
-
getProperties
public java.util.Properties getProperties(java.lang.String name)
Reads a property set.- Parameters:
name
- Name- Returns:
- Property set or NULL, if set of this name don't exists
-
getProperties
public java.util.Properties getProperties(SaJMXConstants.ConfigKey key)
Reads a property set.- Parameters:
key
- ConfigKey- Returns:
- Property set or NULL, if set of this name don't exists
-
setProperties
public void setProperties(SaJMXConstants.ConfigKey key, java.util.Properties props)
sets a property set to the already existing configuration.- Parameters:
key
- ConfigKeyprops
- Properties
-
getProperty
public java.lang.String getProperty(SaJMXConstants.ConfigKey configKey, java.lang.String key)
Returns the value for a given key from the given configuration.- Parameters:
configKey
- Configuration keykey
- Key- Returns:
- Value
-
hasProperty
public boolean hasProperty(SaJMXConstants.ConfigKey configKey, java.lang.String propertyName)
Returns true if the property with the given name exists within the given configuration.- Parameters:
configKey
- Configuration keypropertyName
- property name- Returns:
- Value
-
getProperty
public java.lang.String getProperty(SaJMXConstants.ConfigKey configKey, java.lang.String key, java.lang.String defaultValue)
Returns the value for a given key from the given configuration with default value.- Parameters:
configKey
- Configuration keykey
- KeydefaultValue
- Default value- Returns:
- Value
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Reads property in dotted name format.- Parameters:
name
- Name- Returns:
- Value
-
getProperty
public java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
Reads property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getIntProperty
public int getIntProperty(java.lang.String name, int defaultValue)
Reads integer property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getIntProperty
public int getIntProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, int defaultValue)
Reads integer property with default value.- Parameters:
configKey
- Configuration keyname
- NamedefaultValue
- Default value- Returns:
- Value
-
getDoubleProperty
public double getDoubleProperty(java.lang.String name, double defaultValue)
Reads double property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getDoubleProperty
public double getDoubleProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, double defaultValue)
Reads double property with default value.- Parameters:
configKey
- Configuration keyname
- NamedefaultValue
- Default value- Returns:
- Value
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
Reads boolean property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getBooleanProperty
public boolean getBooleanProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, boolean defaultValue)
Reads boolean property with default value.- Parameters:
configKey
- Configuration keyname
- NamedefaultValue
- Default value- Returns:
- Value
-
getFileProperty
public java.io.File getFileProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name) throws java.io.FileNotFoundException
Reads file property.- Parameters:
configKey
- Configuration keyname
- Name- Returns:
- Value
- Throws:
java.io.FileNotFoundException
- File not found
-
getLinkProperty
public java.io.File getLinkProperty(SaJMXConstants.ConfigKey configKey) throws java.io.FileNotFoundException
Reads linked file property.- Parameters:
configKey
- Configuration key- Returns:
- Value
- Throws:
java.io.FileNotFoundException
- File not found
-
getNumberOfTokens
public int getNumberOfTokens(SaJMXConstants.ConfigKey configKey, java.lang.String propertyName, java.lang.String delimiter)
Reads a multivalue property and returns the number of tokens separated by the given delimiter.- Parameters:
configKey
- configuration keypropertyName
- the name of the propertydelimiter
- the delimiter separating the tokens- Returns:
- number of tokens
-
getTokens
public java.lang.String[] getTokens(SaJMXConstants.ConfigKey configKey, java.lang.String propertyName, java.lang.String delimiter)
Reads a multivalue property separated by the given delimiter and returns the values as String[]. Note that all whitespaces are removed.- Parameters:
configKey
- configuration keypropertyName
- the name of the propertydelimiter
- the delimiter separating the tokens- Returns:
- values as String[]
-
getFirstToken
public java.lang.String getFirstToken(java.lang.String value, java.lang.String delimiter)
Returns the first token of the given value, separated by the given delimiter. Example: if value = host:port (delimiter is ":") host will be returned.- Parameters:
value
- given string to splitdelimiter
- the delimiter separating the tokens- Returns:
- first token
-
getSecondIntToken
public int getSecondIntToken(java.lang.String value, java.lang.String delimiter, int defaultValue)
Returns the second token of the given value and converts it to int. Both tokens has to be separated by the given delimiter. Example: if value = host:port (delimiter is ":") port will be returned. If aNumberFormatException
occurs, the given defaultValue is returned.- Parameters:
value
- given string to splitdelimiter
- the delimiter separating the tokensdefaultValue
- if the second token is undefined or may not be converted to int the defaultValue will be returned.- Returns:
- second token as int
-
getAttribute
public java.lang.Object getAttribute(java.lang.String attributeName) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionException
- Specified by:
getAttribute
in interfacejavax.management.DynamicMBean
- Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException
- See Also:
DynamicMBean.getAttribute(java.lang.String)
-
getAttributes
public javax.management.AttributeList getAttributes(java.lang.String[] attributeNames)
- Specified by:
getAttributes
in interfacejavax.management.DynamicMBean
- See Also:
DynamicMBean.getAttributes(java.lang.String[])
-
getMBeanInfo
public javax.management.MBeanInfo getMBeanInfo()
- Specified by:
getMBeanInfo
in interfacejavax.management.DynamicMBean
- See Also:
DynamicMBean.getMBeanInfo()
-
invoke
public java.lang.Object invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature) throws javax.management.MBeanException, javax.management.ReflectionException
- Specified by:
invoke
in interfacejavax.management.DynamicMBean
- Throws:
javax.management.MBeanException
javax.management.ReflectionException
- See Also:
DynamicMBean.invoke(java.lang.String, java.lang.Object[], java.lang.String[])
-
setAttribute
public void setAttribute(javax.management.Attribute attribute) throws javax.management.AttributeNotFoundException, javax.management.InvalidAttributeValueException, javax.management.MBeanException, javax.management.ReflectionException
- Specified by:
setAttribute
in interfacejavax.management.DynamicMBean
- Throws:
javax.management.AttributeNotFoundException
javax.management.InvalidAttributeValueException
javax.management.MBeanException
javax.management.ReflectionException
- See Also:
DynamicMBean.setAttribute(javax.management.Attribute)
-
setAttributes
public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
- Specified by:
setAttributes
in interfacejavax.management.DynamicMBean
- See Also:
DynamicMBean.setAttributes(javax.management.AttributeList)
-
-