Class SaJMXConfiguration

java.lang.Object
com.saperion.config.SaJMXConfiguration
All Implemented Interfaces:
DynamicMBean

public final class SaJMXConfiguration extends Object implements DynamicMBean
A DynamicMBean implementation for the JMX system configuration.
Author:
rbo
  • Field Details

    • ROOT_TAG

      public static final String ROOT_TAG
      Root entry for Saperion.
      See Also:
    • CFG_TAG

      public static final String CFG_TAG
      Config tag.
      See Also:
    • SYSTEM_CONFIG

      public static final String SYSTEM_CONFIG
      System configuration name.
    • CONFIG_DIR

      public static final String CONFIG_DIR
      Configuration directory.
  • Method Details

    • getInstance

      public static SaJMXConfiguration getInstance()
      Get instance.
      Returns:
      Instance
    • getConfigDir

      public String getConfigDir()
    • getAbsoluteConfigPath

      public String getAbsoluteConfigPath(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(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(String name, SaAbstractJMXProperties props)
      Add new property set.
      Parameters:
      name - Name
      props - Properties
    • registerBean

      public void registerBean(String name, Object bean)
      Register a new bean.
      Parameters:
      name - Name
      bean -
    • registerBean

      public void registerBean(String name, Object bean, int port)
      Register a new bean.
      Parameters:
      name - Name
      bean -
      port -
    • configureLog4j

      public boolean configureLog4j(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, String mainFile) throws FileNotFoundException
      Set the configuration type and main file.
      Parameters:
      type - Configuration type
      mainFile - Main file name
      Throws:
      FileNotFoundException - File not found.
    • setConfigType

      public void setConfigType(SaJMXConstants.ConfigVariant type, Properties configuration)
      Set the configuration type and properties.
      Parameters:
      type - Configuration type
      configuration - Configuration properties
    • setConfigTypeAndConfigDirectory

      public void setConfigTypeAndConfigDirectory(SaJMXConstants.ConfigVariant type, String configurationDir) throws FileNotFoundException
      Set the configuration type and configuration directory.
      Parameters:
      type - Configuration type
      configurationDir - Configuration directory
      Throws:
      FileNotFoundException - File not found.
    • getConfigType

      public SaJMXConstants.ConfigVariant getConfigType()
      Reads the configuration type.
      Returns:
      Configuration type
    • newProperties

      public void newProperties(String name, String configFile) throws IOException
      Add a new property set to the configuration.
      Parameters:
      name - Configuration name
      configFile - 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 name
      configFile - Configuration file name
      isClassPathResource - true if configFile is a classpath related resource
      Throws:
      IOException - Exception
    • newLink

      public void newLink(String name, String configFile) throws IOException
      Add a new property set to the configuration.
      Parameters:
      name - Configuration name
      configFile - Configuration file name
      Throws:
      IOException - Exception
    • newProperties

      public void newProperties(String name, InputStream in) throws IOException
      Add a new stream property set to the configuration.
      Parameters:
      name - Configuration name
      in - Configuration stream
      Throws:
      IOException - Exception
    • newXMLProperties

      public void newXMLProperties(String name, InputStream in) throws IOException
      Add a new XML property set to the configuration.
      Parameters:
      name - Configuration name
      in - Configuration stream
      Throws:
      IOException - Exception
    • newXMLProperties

      public void newXMLProperties(String name, String configFile) throws IOException
      Add a new XML property set to the configuration.
      Parameters:
      name - Configuration name
      configFile - 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 commands
      sysprops - Properties of section ApplicationServer
      Throws:
      RemoteException - Exception
    • newFeatureProperties

      public void newFeatureProperties(SaRMISystemCommand cmd) throws RemoteException
      Adds the backend features to configuration.
      Parameters:
      cmd - System commands
      Throws:
      RemoteException - Exception
    • getProperties

      public Properties getProperties(String name)
      Reads a property set.
      Parameters:
      name - Name
      Returns:
      Property set or NULL, if set of this name don't exists
    • getProperties

      public 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, Properties props)
      sets a property set to the already existing configuration.
      Parameters:
      key - ConfigKey
      props - Properties
    • getProperty

      public String getProperty(SaJMXConstants.ConfigKey configKey, String key)
      Returns the value for a given key from the given configuration.
      Parameters:
      configKey - Configuration key
      key - Key
      Returns:
      Value
    • hasProperty

      public boolean hasProperty(SaJMXConstants.ConfigKey configKey, String propertyName)
      Returns true if the property with the given name exists within the given configuration.
      Parameters:
      configKey - Configuration key
      propertyName - property name
      Returns:
      Value
    • getProperty

      public String getProperty(SaJMXConstants.ConfigKey configKey, String key, String defaultValue)
      Returns the value for a given key from the given configuration with default value.
      Parameters:
      configKey - Configuration key
      key - Key
      defaultValue - Default value
      Returns:
      Value
    • getProperty

      public String getProperty(String name)
      Reads property in dotted name format.
      Parameters:
      name - Name
      Returns:
      Value
    • getProperty

      public String getProperty(String name, String defaultValue)
      Reads property in dotted name format with default value.
      Parameters:
      name - Name
      defaultValue - Default value
      Returns:
      Value
    • getIntProperty

      public int getIntProperty(String name, int defaultValue)
      Reads integer property in dotted name format with default value.
      Parameters:
      name - Name
      defaultValue - Default value
      Returns:
      Value
    • getIntProperty

      public int getIntProperty(SaJMXConstants.ConfigKey configKey, String name, int defaultValue)
      Reads integer property with default value.
      Parameters:
      configKey - Configuration key
      name - Name
      defaultValue - Default value
      Returns:
      Value
    • getDoubleProperty

      public double getDoubleProperty(String name, double defaultValue)
      Reads double property in dotted name format with default value.
      Parameters:
      name - Name
      defaultValue - Default value
      Returns:
      Value
    • getDoubleProperty

      public double getDoubleProperty(SaJMXConstants.ConfigKey configKey, String name, double defaultValue)
      Reads double property with default value.
      Parameters:
      configKey - Configuration key
      name - Name
      defaultValue - Default value
      Returns:
      Value
    • getBooleanProperty

      public boolean getBooleanProperty(String name, boolean defaultValue)
      Reads boolean property in dotted name format with default value.
      Parameters:
      name - Name
      defaultValue - Default value
      Returns:
      Value
    • getBooleanProperty

      public boolean getBooleanProperty(SaJMXConstants.ConfigKey configKey, String name, boolean defaultValue)
      Reads boolean property with default value.
      Parameters:
      configKey - Configuration key
      name - Name
      defaultValue - Default value
      Returns:
      Value
    • getFileProperty

      public File getFileProperty(SaJMXConstants.ConfigKey configKey, String name) throws FileNotFoundException
      Reads file property.
      Parameters:
      configKey - Configuration key
      name - Name
      Returns:
      Value
      Throws:
      FileNotFoundException - File not found
    • getLinkProperty

      public File getLinkProperty(SaJMXConstants.ConfigKey configKey) throws FileNotFoundException
      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 key
      propertyName - the name of the property
      delimiter - 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 key
      propertyName - the name of the property
      delimiter - the delimiter separating the tokens
      Returns:
      values as String[]
    • getFirstToken

      public String getFirstToken(String value, 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 split
      delimiter - the delimiter separating the tokens
      Returns:
      first token
    • getSecondIntToken

      public int getSecondIntToken(String value, 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 a NumberFormatException occurs, the given defaultValue is returned.
      Parameters:
      value - given string to split
      delimiter - the delimiter separating the tokens
      defaultValue - 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 interface DynamicMBean
      Throws:
      AttributeNotFoundException
      MBeanException
      ReflectionException
      See Also:
    • getAttributes

      public AttributeList getAttributes(String[] attributeNames)
      Specified by:
      getAttributes in interface DynamicMBean
      See Also:
    • getMBeanInfo

      public MBeanInfo getMBeanInfo()
      Specified by:
      getMBeanInfo in interface DynamicMBean
      See Also:
    • invoke

      public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException
      Specified by:
      invoke in interface DynamicMBean
      Throws:
      MBeanException
      ReflectionException
      See Also:
    • setAttribute

      Specified by:
      setAttribute in interface DynamicMBean
      Throws:
      AttributeNotFoundException
      InvalidAttributeValueException
      MBeanException
      ReflectionException
      See Also:
    • setAttributes

      public AttributeList setAttributes(AttributeList attributes)
      Specified by:
      setAttributes in interface DynamicMBean
      See Also: