Package org.apache.synapse.config
Class SynapseConfigUtils
- java.lang.Object
-
- org.apache.synapse.config.SynapseConfigUtils
-
public class SynapseConfigUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description SynapseConfigUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addSynapseConfiguration(String tenantDomain, SynapseConfiguration synapseConfiguration)
static int
getConnectTimeout()
static long
getGlobalTimeoutInterval()
static InputSource
getInputSourceFormURI(URI uri)
static InputStream
getInputStream(Object o)
static Object
getObject(URL url, Properties properties)
Get an object from a given URL.static org.apache.axiom.om.OMNode
getOMElementFromURL(String urlStr, String synapseHome)
Return an OMElement from a URL sourcestatic int
getReadTimeout()
static StreamSource
getStreamSource(Object o)
Return a StreamSource for the given Objectstatic SynapseConfiguration
getSynapseConfiguration(String tenantDomain)
static SynapseEnvironment
getSynapseEnvironment(org.apache.axis2.engine.AxisConfiguration axisCfg)
static long
getTimeoutHandlerInterval()
static URLConnection
getURLConnection(URL url)
Returns a URLCOnnection for given URL.static URL
getURLFromPath(String path, String synapseHome)
Utility method to resolve url(only If need) path using synapse home system propertystatic XMLToObjectMapper
getXmlToObjectMapper(String contentType)
Return a suitable XMLToObjectMapper for the given content type if one is available, else return null;static boolean
isFailSafeEnabled(String componentName)
static SynapseConfiguration
newConfiguration()
Construct a fresh SynapseConfiguration instance and registers the observers with it as specified in the synapse.properties file.static org.apache.axiom.om.OMNode
readNonXML(URL url)
Helper method to handle non-XMl resourcesstatic String
resolveRelativeURI(String parentLocation, String relativeLocation)
static void
setDefaultFaultSequence(SynapseConfiguration config)
Return the fault sequence if one is not defined.static void
setDefaultMainSequence(SynapseConfiguration config)
Return the main sequence if one is not defined.static org.apache.axiom.om.OMElement
stringToOM(String xml)
-
-
-
Method Detail
-
getStreamSource
public static StreamSource getStreamSource(Object o)
Return a StreamSource for the given Object- Parameters:
o
- the object- Returns:
- the StreamSource
-
getInputStream
public static InputStream getInputStream(Object o)
-
getObject
public static Object getObject(URL url, Properties properties)
Get an object from a given URL. Will first fetch the content from the URL and depending on the content-type, a suitable XMLToObjectMapper (if available) would be used to transform this content into an Object. If a suitable XMLToObjectMapper cannot be found, the content would be treated as XML and an OMNode would be returned- Parameters:
url
- the URL to the resourceproperties
- bag of properties to pass in any information to the factory- Returns:
- an Object created from the given URL
-
readNonXML
public static org.apache.axiom.om.OMNode readNonXML(URL url)
Helper method to handle non-XMl resources- Parameters:
url
- The resource url- Returns:
- The content as an OMNode
-
getOMElementFromURL
public static org.apache.axiom.om.OMNode getOMElementFromURL(String urlStr, String synapseHome) throws IOException
Return an OMElement from a URL source- Parameters:
urlStr
- a URL stringsynapseHome
- synapse home parameter to be used- Returns:
- an OMElement of the resource
- Throws:
IOException
- for invalid URL's or IO errors
-
getInputSourceFormURI
public static InputSource getInputSourceFormURI(URI uri)
-
getURLConnection
public static URLConnection getURLConnection(URL url)
Returns a URLCOnnection for given URL. If the URL is https one , then URLConnectin is a HttpsURLCOnnection and it is configured with KeyStores given in the synapse.properties file- Parameters:
url
- URL- Returns:
- URLConnection for given URL
-
getXmlToObjectMapper
public static XMLToObjectMapper getXmlToObjectMapper(String contentType)
Return a suitable XMLToObjectMapper for the given content type if one is available, else return null;- Parameters:
contentType
- the content type for which a mapper is required- Returns:
- a suitable XMLToObjectMapper or null if none can be found
-
getURLFromPath
public static URL getURLFromPath(String path, String synapseHome)
Utility method to resolve url(only If need) path using synapse home system property- Parameters:
path
- Path to the URLsynapseHome
- synapse home parameter value to be used- Returns:
- Valid URL instance or null(if it is invalid or can not open a connection to it )
-
resolveRelativeURI
public static String resolveRelativeURI(String parentLocation, String relativeLocation)
-
getConnectTimeout
public static int getConnectTimeout()
-
getReadTimeout
public static int getReadTimeout()
-
getTimeoutHandlerInterval
public static long getTimeoutHandlerInterval()
-
getGlobalTimeoutInterval
public static long getGlobalTimeoutInterval()
-
getSynapseEnvironment
public static SynapseEnvironment getSynapseEnvironment(org.apache.axis2.engine.AxisConfiguration axisCfg)
-
stringToOM
public static org.apache.axiom.om.OMElement stringToOM(String xml)
-
newConfiguration
public static SynapseConfiguration newConfiguration()
Construct a fresh SynapseConfiguration instance and registers the observers with it as specified in the synapse.properties file. Use the initial.observers property in the synapse.properties file to specify observers as a comma separated list.- Returns:
- a SynapseConfiguration instance
-
setDefaultMainSequence
public static void setDefaultMainSequence(SynapseConfiguration config)
Return the main sequence if one is not defined. This implementation defaults to a simple sequence with a- Parameters:
config
- the configuration to be updated
-
setDefaultFaultSequence
public static void setDefaultFaultSequence(SynapseConfiguration config)
Return the fault sequence if one is not defined. This implementation defaults to a simple sequence :- Parameters:
config
- the configuration to be updated
-
isFailSafeEnabled
public static boolean isFailSafeEnabled(String componentName)
-
getSynapseConfiguration
public static SynapseConfiguration getSynapseConfiguration(String tenantDomain)
-
addSynapseConfiguration
public static void addSynapseConfiguration(String tenantDomain, SynapseConfiguration synapseConfiguration)
-
-