Class ConfigurationHTTPAdapter

java.lang.Object
com.espertech.esperio.http.config.ConfigurationHTTPAdapter

public class ConfigurationHTTPAdapter extends Object
  • Constructor Details

    • ConfigurationHTTPAdapter

      public ConfigurationHTTPAdapter()
  • Method Details

    • getServices

      public Map<String,Service> getServices()
    • setServices

      public void setServices(Map<String,Service> services)
    • getGetHandlers

      public List<GetHandler> getGetHandlers()
    • setGetHandlers

      public void setGetHandlers(List<GetHandler> getHandlers)
    • getRequests

      public List<Request> getRequests()
    • setRequests

      public void setRequests(List<Request> requests)
    • configure

      public ConfigurationHTTPAdapter configure() throws RuntimeException
      Use the configuration specified in an application resource named esper.cfg.xml.
      Returns:
      Configuration initialized from the resource
      Throws:
      RuntimeException - thrown to indicate error reading configuration
    • configure

      public ConfigurationHTTPAdapter configure(String resource) throws RuntimeException
      Use the ConfigurationHTTPAdapter specified in the given application resource. The format of the resource is defined in esper-configuration-(version).xsd.

      The resource is found via getConfigurationInputStream(resource). That method can be overridden to implement an arbitrary lookup strategy.

      See getResourceAsStream for information on how the resource name is resolved.
      Parameters:
      resource - if the file name of the resource
      Returns:
      ConfigurationHTTPAdapter initialized from the resource
      Throws:
      RuntimeException - thrown to indicate error reading configuration
    • getConfigurationInputStream

      protected static InputStream getConfigurationInputStream(String resource) throws RuntimeException
      Get the ConfigurationHTTPAdapter file as an InputStream. Might be overridden by subclasses to allow the ConfigurationHTTPAdapter to be located by some arbitrary mechanism.

      See getResourceAsStream for information on how the resource name is resolved.

      Parameters:
      resource - is the resource name
      Returns:
      input stream for resource
      Throws:
      RuntimeException - thrown to indicate error reading configuration
    • configureFromString

      public ConfigurationHTTPAdapter configureFromString(String xml) throws RuntimeException
      Use the ConfigurationHTTPAdapter specified by the given XML String. The format of the document obtained from the URL is defined in esper-configuration-(version).xsd.
      Parameters:
      xml - XML string
      Returns:
      A ConfigurationHTTPAdapter configured via the file
      Throws:
      RuntimeException - is thrown when the URL could not be access
    • configure

      public ConfigurationHTTPAdapter configure(URL url) throws RuntimeException
      Use the ConfigurationHTTPAdapter specified by the given URL. The format of the document obtained from the URL is defined in esper-configuration-(version).xsd.
      Parameters:
      url - URL from which you wish to load the configuration
      Returns:
      A ConfigurationHTTPAdapter configured via the file
      Throws:
      RuntimeException - is thrown when the URL could not be access
    • getResourceAsStream

      protected static InputStream getResourceAsStream(String resource)
      Returns an input stream from an application resource in the classpath.

      The method first removes the '/' character from the resource name if the first character is '/'.

      The lookup order is as follows:

      If a thread context class loader exists, use Thread.currentThread().getResourceAsStream to obtain an InputStream.

      If no input stream was returned, use the Configuration.class.getResourceAsStream. to obtain an InputStream.

      If no input stream was returned, use the Configuration.class.getClassLoader().getResourceAsStream. to obtain an InputStream.

      If no input stream was returned, throw an Exception.

      Parameters:
      resource - to get input stream for
      Returns:
      input stream for resource
    • configure

      public ConfigurationHTTPAdapter configure(File configFile) throws RuntimeException
      Use the ConfigurationHTTPAdapter specified in the given application file. The format of the file is defined in esper-configuration-(version).xsd.
      Parameters:
      configFile - File from which you wish to load the configuration
      Returns:
      A ConfigurationHTTPAdapter configured via the file
      Throws:
      RuntimeException - when the file could not be found