Class JProperties

java.lang.Object
com.j_spaces.kernel.log.JProperties

public class JProperties extends Object
This is a JProperties utility class that can be used by opening an input stream from a XML property file using a URL path that receives as parameter in setURL() function. setURL() function converting XML property file to standard property list. initMessageID() function load standard property file to property list.

To use this class, first the user should care to call the following method setURL() with certain URL name, else the user will get NullPointerException. Each key and its corresponding value in the property list is a string.

Version:
1.0
Author:
Igor Goldenberg
  • Method Details

    • setURL

      public static void setURL(String containerName, String uriName) throws SAXException, ParserConfigurationException, IOException
      Set URL name of property file for opening input stream. param containerName
      Parameters:
      uriName - URI name where stored property file.
      Throws:
      SAXException - This Exception can contain basic error or warning information from either the XML parser or the application
      ParserConfigurationException - Parser Configuration Exception
      IOException - If an error occurred during reading from this input stream.
      See Also:
    • setInputStream

      public static void setInputStream(String containerName, InputStream is, Properties customProps) throws SAXException, ParserConfigurationException, IOException
      Set the InputStream to the config file for resolving the xml file. This method is used when we just call getResourceAsStream() without actually writing it to disk.
      Parameters:
      is - The InputStream to the prop file where the property file is stored.
      Throws:
      SAXException - This Exception can contain basic error or warning information from either the XML parser or the application
      ParserConfigurationException - Parser Configuration Exception
      IOException - If an error occurred during reading from this input stream.
    • loadConfigDCache

      Returns the DCache configuration as specified in the file. Changes on the returned Properties object will not affect the original data.
      Parameters:
      fileName - the name of the configuration file
      Throws:
      SpaceConfigurationException
      IOException
      SAXException
      ParserConfigurationException
    • setUrlWithSchema

      public static void setUrlWithSchema(String fullSpaceName, Properties customProperties, InputStream is) throws SAXException, ParserConfigurationException, IOException
      Convert XML file of specific space to Properties object and store in public table.
      Throws:
      SAXException
      ParserConfigurationException
      IOException
    • setUrlWithoutSchema

      public static void setUrlWithoutSchema(String fullSpaceName, Properties customProperties, String urlName) throws SAXException, ParserConfigurationException, IOException
      Throws:
      SAXException
      ParserConfigurationException
      IOException
    • getAllSpacesPropertiesDump

      public static String getAllSpacesPropertiesDump()
      Returns:
      All Spaces xml file configuration Xpath representation and theirs values.
    • getContainerPropertiesDump

      public static String getContainerPropertiesDump(String containerName)
      Returns:
      Container xml file configuration Xpath representation and theirs values. if the value is a system prop var e.g. ${xxx} and it is NOT been set we show the default value behind that property key as defined in the system constants.
    • convertCustomSpacePropsToJProperties

      public static void convertCustomSpacePropsToJProperties(String spaceName, Properties customProps, JSpaceAttributes spaceAttrib)
      Convert space attributes according to custom properties
      Parameters:
      spaceName - if space name is null then use XPath as key (i.e in the case of DCache config)
      customProps - custom properties
      spaceAttrib - space attributes
    • getURL

      public static String getURL()
      Returns current URL name of container XML file.
      Returns:
      Current URL name.
      See Also:
      • com.j_spaces.kernel.JProperties#setURL(java.lang.String)
    • getURL

      public static String getURL(String fullSpaceName)
      Returns current URL name of space XML file.
      Parameters:
      fullSpaceName - Full space name: :
      Returns:
      Current URL name.
      See Also:
      • com.j_spaces.kernel.JProperties#setURL(String spaceName, String urlName)
    • removeSpaceProperties

      public static void removeSpaceProperties(String fullSpaceName)
      Remove Properties object of space from JProperties.
      Parameters:
      fullSpaceName - Full space name: :
    • getContainerProperties

      public static Properties getContainerProperties(String containerName)
      Returns current Properties object.
      Returns:
      This Properties object.
    • getContainerProperty

      public static String getContainerProperty(String containerName, String key, String defaultValue)
      Searches for the property with the specified key in this property list of container. If the key is not found in this property list the method returns the default value argument.
      Parameters:
      key - Certain key.
      defaultValue - A default value.
      Returns:
      the value from the property list with the specified key value.
    • getContainerProperty

      public static String getContainerProperty(String containerName, String key, String defaultValue, boolean convert)
      Retrieve container properties according to its name.
      Parameters:
      containerName - if name is null any container will be taken. That is done only for system time property.
      key - container property name
      convert - indicates if convert with system property
      Returns:
      container property value
    • containsSpaceProperty

      public static boolean containsSpaceProperty(String fullSpaceName, String key)
    • getSpaceProperties

      public static Properties getSpaceProperties(String fullSpaceName)
      Returns Properties of certain space.
      Parameters:
      fullSpaceName - Full space name: :
    • setSpaceProperties

      public static void setSpaceProperties(String fullSpaceName, Properties properties)
    • loadDCacheConfig

      public static SpaceConfigReader loadDCacheConfig(ISpaceProxy remoteSpace, Properties customProperties, String dcacheSuffix) throws SpaceInitializationException
      Throws:
      SpaceInitializationException
    • getSpaceProperty

      public static String getSpaceProperty(String fullSpaceName, String key, String defaultValue)
    • getSpaceProperty

      public static String getSpaceProperty(String fullSpaceName, String key, String defaultValue, boolean convert)
    • getObjectSpaceProperty

      public static <T> T getObjectSpaceProperty(String fullSpaceName, String key)
    • setSpaceProperty

      public static void setSpaceProperty(String fullSpaceName, String key, String value)
    • convertXML

      public static JSpaceAttributes convertXML(String uri, boolean isConvertToSystemProperty) throws SAXException, ParserConfigurationException, IOException
      Convert XML file to Properties object.
      Parameters:
      uri - URI of XML file for conversion.
      isConvertToSystemProperty - Is convert xml properties from System properties.
      Returns:
      Property Properties object that converted from XML file.
      Throws:
      SAXException
      ParserConfigurationException
      IOException
    • convertXML

      Convert XML file to Properties object.
      Parameters:
      is - InputStream of XML file for conversion. By default converts xml properties from System properties.
      Returns:
      Property Properties object that was converted from XML file.
      Throws:
      SAXException
      ParserConfigurationException
      IOException
    • convertXML

      public static JSpaceAttributes convertXML(InputStream is, boolean isConvertToSystemProperty, Properties customProps) throws SAXException, ParserConfigurationException, IOException
      Convert XML file to Properties object.
      Parameters:
      is - InputStream of XML file for conversion.
      isConvertToSystemProperty - Is convert xml properties from System properties.
      Returns:
      Property Properties object that was converted from XML file.
      Throws:
      SAXException
      ParserConfigurationException
      IOException
    • getPropertyFromSystem

      public static String getPropertyFromSystem(String propertyValue)
      Replace the XML propertyValue with System property value if contains. For example the value is: ${com.gs.home}/logs/services/pc-igor-rmid.log This method will check if the following System property defined in JVM -Dcom.gs.home if yes, the system property will be replaced in propertyValue: c:/gigaspaces2.5/logs/services/pc-igor-rmid.log, otherwise will return the propertyValue without changes. If the property was not found as system property we try to get it from the custom properties object passed by the client. If still none, the XML propertyValue is returned.
      Parameters:
      propertyValue - The XML property value.
      Returns:
      Converted propertyValue with System property.
      Since:
      version 5.0
      See Also:
    • getPropertyFromSystem

      public static String getPropertyFromSystem(String propertyValue, String defValue)
      Replace the XML propertyValue with System property value if contains. For example the value is: ${com.gs.home}/logs/services/pc-igor-rmid.log This method will check if the following System property defined in JVM -Dcom.gs.home if yes, the system property will be replaced in propertyValue: c:/gigaspaces2.5/logs/services/pc-igor-rmid.log, otherwise will return the propertyValue without changes. If the property was not found as system property we try to get it from the custom properties object passed by the client. If still none, and no default value, the XML propertyValue is returned.
      Parameters:
      propertyValue - The XML property value.
      defValue - Default value, When null default value is ignored.
      Returns:
      Converted propertyValue with System property.
      Since:
      version 2.5
    • resolveSystemPropertyName

      public static String resolveSystemPropertyName(String propertyValue)
    • main

      public static void main(String[] args)
    • getPropertyFromSystemForComplicatedValue

      public static String getPropertyFromSystemForComplicatedValue(String propertyValue, String defValue)
    • isSystemProp

      public static boolean isSystemProp(String propertyValue)
      This method checks if value has format of system property
      Returns:
      true if this is system variable i.e. of type ${somekey}