Class SynapseConfigUtils


  • public class SynapseConfigUtils
    extends Object
    • Constructor Detail

      • SynapseConfigUtils

        public SynapseConfigUtils()
    • Method Detail

      • getStreamSource

        public static StreamSource getStreamSource​(Object o)
        Return a StreamSource for the given Object
        Parameters:
        o - the object
        Returns:
        the StreamSource
      • 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 resource
        properties - 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 string
        synapseHome - 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 URL
        synapseHome - 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)
      • addSynapseConfiguration

        public static void addSynapseConfiguration​(String tenantDomain,
                                                   SynapseConfiguration synapseConfiguration)