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.DynamicMBeanADynamicMBeanimplementation for the JMX system configuration.- Author:
- rbo
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCFG_TAGConfig tag.static java.lang.StringCONFIG_DIRConfiguration directory.static java.lang.StringROOT_TAGRoot entry for Saperion.static java.lang.StringSYSTEM_CONFIGSystem configuration name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNewProperties(java.lang.String name, SaAbstractJMXProperties props)Add new property set.booleanconfigureLog4j(SaJMXConstants.ConfigKey section)Configures the Log4J system from the given section key.booleanconfigureLog4j(java.lang.String section)Configures the Log4J system from the given section.java.lang.StringgetAbsoluteConfigPath(java.lang.String fileName)returns an absolute path for the specified file name.java.lang.ObjectgetAttribute(java.lang.String attributeName)javax.management.AttributeListgetAttributes(java.lang.String[] attributeNames)booleangetBooleanProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, boolean defaultValue)Reads boolean property with default value.booleangetBooleanProperty(java.lang.String name, boolean defaultValue)Reads boolean property in dotted name format with default value.java.lang.StringgetConfigDir()SaJMXConstants.ConfigVariantgetConfigType()Reads the configuration type.doublegetDoubleProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, double defaultValue)Reads double property with default value.doublegetDoubleProperty(java.lang.String name, double defaultValue)Reads double property in dotted name format with default value.java.io.FilegetFileProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name)Reads file property.java.lang.StringgetFirstToken(java.lang.String value, java.lang.String delimiter)Returns the first token of the given value, separated by the given delimiter.static SaJMXConfigurationgetInstance()Get instance.intgetIntProperty(SaJMXConstants.ConfigKey configKey, java.lang.String name, int defaultValue)Reads integer property with default value.intgetIntProperty(java.lang.String name, int defaultValue)Reads integer property in dotted name format with default value.java.io.FilegetLinkProperty(SaJMXConstants.ConfigKey configKey)Reads linked file property.javax.management.MBeanInfogetMBeanInfo()intgetNumberOfTokens(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.PropertiesgetProperties(SaJMXConstants.ConfigKey key)Reads a property set.java.util.PropertiesgetProperties(java.lang.String name)Reads a property set.java.lang.StringgetProperty(SaJMXConstants.ConfigKey configKey, java.lang.String key)Returns the value for a given key from the given configuration.java.lang.StringgetProperty(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.StringgetProperty(java.lang.String name)Reads property in dotted name format.java.lang.StringgetProperty(java.lang.String name, java.lang.String defaultValue)Reads property in dotted name format with default value.intgetSecondIntToken(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[].booleanhasProperty(SaJMXConstants.ConfigKey configKey, java.lang.String propertyName)Returns true if the property with the given name exists within the given configuration.booleanhasSection(SaJMXConstants.ConfigKey key)Checks, if the given section exists.booleanhasSection(java.lang.String section)Checks, if the given section exists.java.lang.Objectinvoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)booleanisLog4jConfigured()voidnewBackendProperties(SaRMISystemCommand cmd, java.util.Properties sysprops)Adds the backend properties to configuration.voidnewFeatureProperties(SaRMISystemCommand cmd)Adds the backend features to configuration.voidnewLink(java.lang.String name, java.lang.String configFile)Add a new property set to the configuration.voidnewProperties(java.lang.String name, java.io.InputStream in)Add a new stream property set to the configuration.voidnewProperties(java.lang.String name, java.lang.String configFile)Add a new property set to the configuration.voidnewProperties(java.lang.String name, java.lang.String configFile, boolean isClassPathResource)Add a new property set to the configuration.voidnewXMLProperties(java.lang.String name, java.io.InputStream in)Add a new XML property set to the configuration.voidnewXMLProperties(java.lang.String name, java.lang.String configFile)Add a new XML property set to the configuration.voidregisterBean(java.lang.String name, java.lang.Object bean)Register a new bean.voidregisterBean(java.lang.String name, java.lang.Object bean, int port)Register a new bean.voidsetAttribute(javax.management.Attribute attribute)javax.management.AttributeListsetAttributes(javax.management.AttributeList attributes)voidsetConfigType(SaJMXConstants.ConfigVariant type, java.lang.String mainFile)Set the configuration type and main file.voidsetConfigType(SaJMXConstants.ConfigVariant type, java.util.Properties configuration)Set the configuration type and properties.voidsetConfigTypeAndConfigDirectory(SaJMXConstants.ConfigVariant type, java.lang.String configurationDir)Set the configuration type and configuration directory.voidsetProperties(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.IOExceptionAdd 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.IOExceptionAdd 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.IOExceptionAdd 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.IOExceptionAdd 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.IOExceptionAdd 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.IOExceptionAdd 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 aNumberFormatExceptionoccurs, 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:
getAttributein interfacejavax.management.DynamicMBean- Throws:
javax.management.AttributeNotFoundExceptionjavax.management.MBeanExceptionjavax.management.ReflectionException- See Also:
DynamicMBean.getAttribute(java.lang.String)
-
getAttributes
public javax.management.AttributeList getAttributes(java.lang.String[] attributeNames)
- Specified by:
getAttributesin interfacejavax.management.DynamicMBean- See Also:
DynamicMBean.getAttributes(java.lang.String[])
-
getMBeanInfo
public javax.management.MBeanInfo getMBeanInfo()
- Specified by:
getMBeanInfoin 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:
invokein interfacejavax.management.DynamicMBean- Throws:
javax.management.MBeanExceptionjavax.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:
setAttributein interfacejavax.management.DynamicMBean- Throws:
javax.management.AttributeNotFoundExceptionjavax.management.InvalidAttributeValueExceptionjavax.management.MBeanExceptionjavax.management.ReflectionException- See Also:
DynamicMBean.setAttribute(javax.management.Attribute)
-
setAttributes
public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
- Specified by:
setAttributesin interfacejavax.management.DynamicMBean- See Also:
DynamicMBean.setAttributes(javax.management.AttributeList)
-
-