Package com.j_spaces.kernel.log
Class JProperties
java.lang.Object
com.j_spaces.kernel.log.JProperties
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 Summary
Modifier and TypeMethodDescriptionstatic booleancontainsSpaceProperty(String fullSpaceName, String key) static voidconvertCustomSpacePropsToJProperties(String spaceName, Properties customProps, JSpaceAttributes spaceAttrib) Convert space attributes according to custom propertiesstatic PropertiesConvert XML file toPropertiesobject.static JSpaceAttributesconvertXML(InputStream is, boolean isConvertToSystemProperty, Properties customProps) Convert XML file toPropertiesobject.static JSpaceAttributesconvertXML(String uri, boolean isConvertToSystemProperty) Convert XML file toPropertiesobject.static Stringstatic PropertiesgetContainerProperties(String containerName) Returns currentPropertiesobject.static StringgetContainerPropertiesDump(String containerName) static StringgetContainerProperty(String containerName, String key, String defaultValue) Searches for the property with the specified key in this property list of container.static StringgetContainerProperty(String containerName, String key, String defaultValue, boolean convert) Retrieve container properties according to its name.static <T> TgetObjectSpaceProperty(String fullSpaceName, String key) static StringgetPropertyFromSystem(String propertyValue) Replace the XML propertyValue with System property value if contains.static StringgetPropertyFromSystem(String propertyValue, String defValue) Replace the XML propertyValue with System property value if contains.static StringgetPropertyFromSystemForComplicatedValue(String propertyValue, String defValue) static PropertiesgetSpaceProperties(String fullSpaceName) Returns Properties of certain space.static StringgetSpaceProperty(String fullSpaceName, String key, String defaultValue) static StringgetSpaceProperty(String fullSpaceName, String key, String defaultValue, boolean convert) static StringgetURL()Returns current URL name of container XML file.static StringReturns current URL name of space XML file.static booleanisSystemProp(String propertyValue) This method checks if value has format of system propertystatic JSpaceAttributesloadConfigDCache(String fileName) Returns the DCache configuration as specified in the file.static SpaceConfigReaderloadDCacheConfig(ISpaceProxy remoteSpace, Properties customProperties, String dcacheSuffix) static voidstatic voidremoveSpaceProperties(String fullSpaceName) RemovePropertiesobject of space from JProperties.static StringresolveSystemPropertyName(String propertyValue) static voidsetInputStream(String containerName, InputStream is, Properties customProps) Set the InputStream to the config file for resolving the xml file.static voidsetSpaceProperties(String fullSpaceName, Properties properties) static voidsetSpaceProperty(String fullSpaceName, String key, String value) static voidSet URL name of property file for opening input stream.static voidsetUrlWithoutSchema(String fullSpaceName, Properties customProperties, String urlName) static voidsetUrlWithSchema(String fullSpaceName, Properties customProperties, InputStream is) Convert XML file of specific space toPropertiesobject and store in public table.
-
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 applicationParserConfigurationException- Parser Configuration ExceptionIOException- 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 applicationParserConfigurationException- Parser Configuration ExceptionIOException- If an error occurred during reading from this input stream.
-
loadConfigDCache
public static JSpaceAttributes loadConfigDCache(String fileName) throws SpaceConfigurationException, IOException, SAXException, ParserConfigurationException 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:
SpaceConfigurationExceptionIOExceptionSAXExceptionParserConfigurationException
-
setUrlWithSchema
public static void setUrlWithSchema(String fullSpaceName, Properties customProperties, InputStream is) throws SAXException, ParserConfigurationException, IOException Convert XML file of specific space toPropertiesobject and store in public table. -
setUrlWithoutSchema
public static void setUrlWithoutSchema(String fullSpaceName, Properties customProperties, String urlName) throws SAXException, ParserConfigurationException, IOException -
getAllSpacesPropertiesDump
- Returns:
- All Spaces xml file configuration Xpath representation and theirs values.
-
getContainerPropertiesDump
- 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 propertiesspaceAttrib- space attributes
-
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
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
RemovePropertiesobject of space from JProperties.- Parameters:
fullSpaceName- Full space name::
-
getContainerProperties
Returns currentPropertiesobject.- Returns:
- This
Propertiesobject.
-
getContainerProperty
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 nameconvert- indicates if convert with system property- Returns:
- container property value
-
containsSpaceProperty
-
getSpaceProperties
Returns Properties of certain space.- Parameters:
fullSpaceName- Full space name::
-
setSpaceProperties
-
loadDCacheConfig
public static SpaceConfigReader loadDCacheConfig(ISpaceProxy remoteSpace, Properties customProperties, String dcacheSuffix) throws SpaceInitializationException - Throws:
SpaceInitializationException
-
getSpaceProperty
-
getSpaceProperty
-
getObjectSpaceProperty
-
setSpaceProperty
-
convertXML
public static JSpaceAttributes convertXML(String uri, boolean isConvertToSystemProperty) throws SAXException, ParserConfigurationException, IOException Convert XML file toPropertiesobject.- Parameters:
uri-URIof XML file for conversion.isConvertToSystemProperty- Is convert xml properties from System properties.- Returns:
- Property
Propertiesobject that converted from XML file. - Throws:
SAXExceptionParserConfigurationExceptionIOException
-
convertXML
public static Properties convertXML(InputStream is) throws SAXException, ParserConfigurationException, IOException Convert XML file toPropertiesobject.- Parameters:
is-InputStreamof XML file for conversion. By default converts xml properties from System properties.- Returns:
- Property
Propertiesobject that was converted from XML file. - Throws:
SAXExceptionParserConfigurationExceptionIOException
-
convertXML
public static JSpaceAttributes convertXML(InputStream is, boolean isConvertToSystemProperty, Properties customProps) throws SAXException, ParserConfigurationException, IOException Convert XML file toPropertiesobject.- Parameters:
is-InputStreamof XML file for conversion.isConvertToSystemProperty- Is convert xml properties from System properties.- Returns:
- Property
Propertiesobject that was converted from XML file. - Throws:
SAXExceptionParserConfigurationExceptionIOException
-
getPropertyFromSystem
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
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
-
main
-
getPropertyFromSystemForComplicatedValue
-
isSystemProp
This method checks if value has format of system property- Returns:
- true if this is system variable i.e. of type ${somekey}
-