Package org.apache.synapse.commons.util
Class MiscellaneousUtil
java.lang.Object
org.apache.synapse.commons.util.MiscellaneousUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]asBytes(InputStream in) static StringgetMessageProcessorName(String taskName) Provides the name of the corresponding message processor of a taskstatic StringgetProperty(Properties properties, String name, String defaultValue) Helper method to get the value of the property from a given property bagstatic <T> TgetProperty(Properties properties, String name, T defaultValue, Class<? extends T> type) Helper method to get the value of the property from a given property bag This method will return a value with the type equal to the type given by the Class type parameter.static booleanisTaskOfMessageProcessor(String taskName) Checks if the task belongs to a message processorstatic PropertiesloadProperties(String filePath) Loads the properties from a given property file pathstatic org.apache.axiom.om.OMElementloadXMLConfig(String filePath) Load xml configstatic org.apache.axiom.om.OMElementloadXMLConfig(String filePath, boolean isMandatory) Load a xml configuration filestatic byte[]Helper method to serialize object into a byte array
-
Method Details
-
getProperty
Helper method to get the value of the property from a given property bag- Parameters:
properties- The property collectionname- The name of the propertydefaultValue- The default value for the property- Returns:
- The value of the property if it is found , otherwise , default value
-
getProperty
public static <T> T getProperty(Properties properties, String name, T defaultValue, Class<? extends T> type) Helper method to get the value of the property from a given property bag This method will return a value with the type equal to the type given by the Class type parameter. Therefore, The user of this method can ensure that he is get what he request- Parameters:
properties- Properties bagname- Name of the propertydefaultValue- Default valuetype- Expected Type using Class- Returns:
- Value corresponding to the given property name
-
loadProperties
Loads the properties from a given property file path- Parameters:
filePath- Path of the property file- Returns:
- Properties loaded from given file
-
loadXMLConfig
Load xml config- Parameters:
filePath- file path- Returns:
- OMElement of build from the config file
-
loadXMLConfig
Load a xml configuration file- Parameters:
filePath- file pathisMandatory- whether this is a mandatory config- Returns:
- OMElement of build from the config file
-
serialize
Helper method to serialize object into a byte array- Parameters:
data- The object to be serialized- Returns:
- The byte array representation of the provided object
-
asBytes
-
isTaskOfMessageProcessor
Checks if the task belongs to a message processor- Parameters:
taskName- task name- Returns:
- true if task belongs to a message processor
-
getMessageProcessorName
Provides the name of the corresponding message processor of a task- Parameters:
taskName- task name- Returns:
- message processor name
-