Package com.saperion.config
Class SaJMXConfiguration
java.lang.Object
com.saperion.config.SaJMXConfiguration
- All Implemented Interfaces:
DynamicMBean
A
DynamicMBean
implementation for the JMX system configuration.- Author:
- rbo
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNewProperties
(String name, SaAbstractJMXProperties props) Add new property set.boolean
configureLog4j
(SaJMXConstants.ConfigKey section) Configures the Log4J system from the given section key.boolean
configureLog4j
(String section) Configures the Log4J system from the given section.getAbsoluteConfigPath
(String fileName) returns an absolute path for the specified file name.getAttribute
(String attributeName) getAttributes
(String[] attributeNames) boolean
getBooleanProperty
(SaJMXConstants.ConfigKey configKey, String name, boolean defaultValue) Reads boolean property with default value.boolean
getBooleanProperty
(String name, boolean defaultValue) Reads boolean property in dotted name format with default value.Reads the configuration type.double
getDoubleProperty
(SaJMXConstants.ConfigKey configKey, String name, double defaultValue) Reads double property with default value.double
getDoubleProperty
(String name, double defaultValue) Reads double property in dotted name format with default value.getFileProperty
(SaJMXConstants.ConfigKey configKey, String name) Reads file property.getFirstToken
(String value, String delimiter) Returns the first token of the given value, separated by the given delimiter.static SaJMXConfiguration
Get instance.int
getIntProperty
(SaJMXConstants.ConfigKey configKey, String name, int defaultValue) Reads integer property with default value.int
getIntProperty
(String name, int defaultValue) Reads integer property in dotted name format with default value.getLinkProperty
(SaJMXConstants.ConfigKey configKey) Reads linked file property.int
getNumberOfTokens
(SaJMXConstants.ConfigKey configKey, String propertyName, String delimiter) Reads a multivalue property and returns the number of tokens separated by the given delimiter.Reads a property set.getProperties
(String name) Reads a property set.getProperty
(SaJMXConstants.ConfigKey configKey, String key) Returns the value for a given key from the given configuration.getProperty
(SaJMXConstants.ConfigKey configKey, String key, String defaultValue) Returns the value for a given key from the given configuration with default value.getProperty
(String name) Reads property in dotted name format.getProperty
(String name, String defaultValue) Reads property in dotted name format with default value.int
getSecondIntToken
(String value, String delimiter, int defaultValue) Returns the second token of the given value and converts it to int.String[]
getTokens
(SaJMXConstants.ConfigKey configKey, String propertyName, String delimiter) Reads a multivalue property separated by the given delimiter and returns the values as String[].boolean
hasProperty
(SaJMXConstants.ConfigKey configKey, String propertyName) Returns true if the property with the given name exists within the given configuration.boolean
Checks, if the given section exists.boolean
hasSection
(String section) Checks, if the given section exists.boolean
void
newBackendProperties
(SaRMISystemCommand cmd, Properties sysprops) Adds the backend properties to configuration.void
Adds the backend features to configuration.void
Add a new property set to the configuration.void
newProperties
(String name, InputStream in) Add a new stream property set to the configuration.void
newProperties
(String name, String configFile) Add a new property set to the configuration.void
newProperties
(String name, String configFile, boolean isClassPathResource) Add a new property set to the configuration.void
newXMLProperties
(String name, InputStream in) Add a new XML property set to the configuration.void
newXMLProperties
(String name, String configFile) Add a new XML property set to the configuration.void
registerBean
(String name, Object bean) Register a new bean.void
registerBean
(String name, Object bean, int port) Register a new bean.void
setAttribute
(Attribute attribute) setAttributes
(AttributeList attributes) void
setConfigType
(SaJMXConstants.ConfigVariant type, String mainFile) Set the configuration type and main file.void
setConfigType
(SaJMXConstants.ConfigVariant type, Properties configuration) Set the configuration type and properties.void
setConfigTypeAndConfigDirectory
(SaJMXConstants.ConfigVariant type, String configurationDir) Set the configuration type and configuration directory.void
setProperties
(SaJMXConstants.ConfigKey key, Properties props) sets a property set to the already existing configuration.
-
Field Details
-
ROOT_TAG
Root entry for Saperion.- See Also:
-
CFG_TAG
Config tag.- See Also:
-
SYSTEM_CONFIG
System configuration name. -
CONFIG_DIR
Configuration directory.
-
-
Method Details
-
getInstance
Get instance.- Returns:
- Instance
-
getConfigDir
-
getAbsoluteConfigPath
returns an absolute path for the specified file name.- Parameters:
fileName
- the name of configuration file- Returns:
- the absolute path.
-
hasSection
Checks, if the given section exists.- Parameters:
section
- Section name- Returns:
- True, if exists
-
hasSection
Checks, if the given section exists.- Parameters:
key
- Section key- Returns:
- True, if exists
-
addNewProperties
Add new property set.- Parameters:
name
- Nameprops
- Properties
-
registerBean
Register a new bean.- Parameters:
name
- Namebean
-
-
registerBean
Register a new bean.- Parameters:
name
- Namebean
-port
-
-
configureLog4j
Configures the Log4J system from the given section.- Parameters:
section
- Section- Returns:
- Success
-
isLog4jConfigured
public boolean isLog4jConfigured()- Returns:
- log4j configured
-
configureLog4j
Configures the Log4J system from the given section key.- Parameters:
section
- Section key- Returns:
- Success
-
setConfigType
public void setConfigType(SaJMXConstants.ConfigVariant type, String mainFile) throws FileNotFoundException Set the configuration type and main file.- Parameters:
type
- Configuration typemainFile
- Main file name- Throws:
FileNotFoundException
- File not found.
-
setConfigType
Set the configuration type and properties.- Parameters:
type
- Configuration typeconfiguration
- Configuration properties
-
setConfigTypeAndConfigDirectory
public void setConfigTypeAndConfigDirectory(SaJMXConstants.ConfigVariant type, String configurationDir) throws FileNotFoundException Set the configuration type and configuration directory.- Parameters:
type
- Configuration typeconfigurationDir
- Configuration directory- Throws:
FileNotFoundException
- File not found.
-
getConfigType
Reads the configuration type.- Returns:
- Configuration type
-
newProperties
Add a new property set to the configuration.- Parameters:
name
- Configuration nameconfigFile
- Configuration file name- Throws:
IOException
- Exception
-
newProperties
public void newProperties(String name, String configFile, boolean isClassPathResource) throws 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:
IOException
- Exception
-
newLink
Add a new property set to the configuration.- Parameters:
name
- Configuration nameconfigFile
- Configuration file name- Throws:
IOException
- Exception
-
newProperties
Add a new stream property set to the configuration.- Parameters:
name
- Configuration namein
- Configuration stream- Throws:
IOException
- Exception
-
newXMLProperties
Add a new XML property set to the configuration.- Parameters:
name
- Configuration namein
- Configuration stream- Throws:
IOException
- Exception
-
newXMLProperties
Add a new XML property set to the configuration.- Parameters:
name
- Configuration nameconfigFile
- Configuration file name- Throws:
IOException
- Exception
-
newBackendProperties
public void newBackendProperties(SaRMISystemCommand cmd, Properties sysprops) throws RemoteException Adds the backend properties to configuration.- Parameters:
cmd
- System commandssysprops
- Properties of section ApplicationServer- Throws:
RemoteException
- Exception
-
newFeatureProperties
Adds the backend features to configuration.- Parameters:
cmd
- System commands- Throws:
RemoteException
- Exception
-
getProperties
Reads a property set.- Parameters:
name
- Name- Returns:
- Property set or NULL, if set of this name don't exists
-
getProperties
Reads a property set.- Parameters:
key
- ConfigKey- Returns:
- Property set or NULL, if set of this name don't exists
-
setProperties
sets a property set to the already existing configuration.- Parameters:
key
- ConfigKeyprops
- Properties
-
getProperty
Returns the value for a given key from the given configuration.- Parameters:
configKey
- Configuration keykey
- Key- Returns:
- Value
-
hasProperty
Returns true if the property with the given name exists within the given configuration.- Parameters:
configKey
- Configuration keypropertyName
- property name- Returns:
- Value
-
getProperty
Returns the value for a given key from the given configuration with default value.- Parameters:
configKey
- Configuration keykey
- KeydefaultValue
- Default value- Returns:
- Value
-
getProperty
Reads property in dotted name format.- Parameters:
name
- Name- Returns:
- Value
-
getProperty
Reads property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getIntProperty
Reads integer property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getIntProperty
Reads integer property with default value.- Parameters:
configKey
- Configuration keyname
- NamedefaultValue
- Default value- Returns:
- Value
-
getDoubleProperty
Reads double property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getDoubleProperty
public double getDoubleProperty(SaJMXConstants.ConfigKey configKey, String name, double defaultValue) Reads double property with default value.- Parameters:
configKey
- Configuration keyname
- NamedefaultValue
- Default value- Returns:
- Value
-
getBooleanProperty
Reads boolean property in dotted name format with default value.- Parameters:
name
- NamedefaultValue
- Default value- Returns:
- Value
-
getBooleanProperty
public boolean getBooleanProperty(SaJMXConstants.ConfigKey configKey, String name, boolean defaultValue) Reads boolean property with default value.- Parameters:
configKey
- Configuration keyname
- NamedefaultValue
- Default value- Returns:
- Value
-
getFileProperty
public File getFileProperty(SaJMXConstants.ConfigKey configKey, String name) throws FileNotFoundException Reads file property.- Parameters:
configKey
- Configuration keyname
- Name- Returns:
- Value
- Throws:
FileNotFoundException
- File not found
-
getLinkProperty
Reads linked file property.- Parameters:
configKey
- Configuration key- Returns:
- Value
- Throws:
FileNotFoundException
- File not found
-
getNumberOfTokens
public int getNumberOfTokens(SaJMXConstants.ConfigKey configKey, String propertyName, 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 String[] getTokens(SaJMXConstants.ConfigKey configKey, String propertyName, 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
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
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 Object getAttribute(String attributeName) throws AttributeNotFoundException, MBeanException, ReflectionException - Specified by:
getAttribute
in interfaceDynamicMBean
- Throws:
AttributeNotFoundException
MBeanException
ReflectionException
- See Also:
-
getAttributes
- Specified by:
getAttributes
in interfaceDynamicMBean
- See Also:
-
getMBeanInfo
- Specified by:
getMBeanInfo
in interfaceDynamicMBean
- See Also:
-
invoke
public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException - Specified by:
invoke
in interfaceDynamicMBean
- Throws:
MBeanException
ReflectionException
- See Also:
-
setAttribute
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException - Specified by:
setAttribute
in interfaceDynamicMBean
- Throws:
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException
- See Also:
-
setAttributes
- Specified by:
setAttributes
in interfaceDynamicMBean
- See Also:
-