com.espertech.esperio.db.config
Class ConfigurationDBAdapter

java.lang.Object
  extended by com.espertech.esperio.db.config.ConfigurationDBAdapter

public class ConfigurationDBAdapter
extends java.lang.Object


Constructor Summary
ConfigurationDBAdapter()
           
 
Method Summary
 ConfigurationDBAdapter configure()
          Use the configuration specified in an application resource named esper.cfg.xml.
 ConfigurationDBAdapter configure(java.io.File configFile)
          Use the ConfigurationDBAdapter specified in the given application file.
 ConfigurationDBAdapter configure(java.lang.String resource)
          Use the ConfigurationDBAdapter specified in the given application resource.
 ConfigurationDBAdapter configure(java.net.URL url)
          Use the ConfigurationDBAdapter specified by the given URL.
 ConfigurationDBAdapter configureFromString(java.lang.String xml)
          Use the ConfigurationDBAdapter specified by the given XML String.
protected static java.io.InputStream getConfigurationInputStream(java.lang.String resource)
          Get the ConfigurationDBAdapter file as an InputStream.
 java.util.List<DMLQuery> getDmlQueries()
           
 java.util.Map<java.lang.String,Executor> getExecutors()
           
 java.util.Map<java.lang.String,com.espertech.esper.client.ConfigurationDBRef> getJdbcConnections()
           
protected static java.io.InputStream getResourceAsStream(java.lang.String resource)
          Returns an input stream from an application resource in the classpath.
 java.util.List<UpsertQuery> getUpsertQueries()
           
 void setDmlQueries(java.util.List<DMLQuery> dmlQueries)
           
 void setExecutors(java.util.Map<java.lang.String,Executor> executors)
           
 void setJdbcConnections(java.util.Map<java.lang.String,com.espertech.esper.client.ConfigurationDBRef> jdbcConnections)
           
 void setUpsertQueries(java.util.List<UpsertQuery> upsertQueries)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationDBAdapter

public ConfigurationDBAdapter()
Method Detail

getJdbcConnections

public java.util.Map<java.lang.String,com.espertech.esper.client.ConfigurationDBRef> getJdbcConnections()

setJdbcConnections

public void setJdbcConnections(java.util.Map<java.lang.String,com.espertech.esper.client.ConfigurationDBRef> jdbcConnections)

getDmlQueries

public java.util.List<DMLQuery> getDmlQueries()

setDmlQueries

public void setDmlQueries(java.util.List<DMLQuery> dmlQueries)

getUpsertQueries

public java.util.List<UpsertQuery> getUpsertQueries()

setUpsertQueries

public void setUpsertQueries(java.util.List<UpsertQuery> upsertQueries)

getExecutors

public java.util.Map<java.lang.String,Executor> getExecutors()

setExecutors

public void setExecutors(java.util.Map<java.lang.String,Executor> executors)

configure

public ConfigurationDBAdapter configure()
                                 throws java.lang.RuntimeException
Use the configuration specified in an application resource named esper.cfg.xml.

Returns:
Configuration initialized from the resource
Throws:
java.lang.RuntimeException - thrown to indicate error reading configuration

configure

public ConfigurationDBAdapter configure(java.lang.String resource)
                                 throws java.lang.RuntimeException
Use the ConfigurationDBAdapter specified in the given application resource. The format of the resource is defined in esper-configuration-2.0.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:
ConfigurationDBAdapter initialized from the resource
Throws:
java.lang.RuntimeException - thrown to indicate error reading configuration

getConfigurationInputStream

protected static java.io.InputStream getConfigurationInputStream(java.lang.String resource)
                                                          throws java.lang.RuntimeException
Get the ConfigurationDBAdapter file as an InputStream. Might be overridden by subclasses to allow the ConfigurationDBAdapter 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:
java.lang.RuntimeException - thrown to indicate error reading configuration

configureFromString

public ConfigurationDBAdapter configureFromString(java.lang.String xml)
                                           throws java.lang.RuntimeException
Use the ConfigurationDBAdapter specified by the given XML String. The format of the document obtained from the URL is defined in esper-configuration-2.0.xsd.

Parameters:
xml - XML string
Returns:
A ConfigurationDBAdapter configured via the file
Throws:
java.lang.RuntimeException - is thrown when the URL could not be access

configure

public ConfigurationDBAdapter configure(java.net.URL url)
                                 throws java.lang.RuntimeException
Use the ConfigurationDBAdapter specified by the given URL. The format of the document obtained from the URL is defined in esper-configuration-2.0.xsd.

Parameters:
url - URL from which you wish to load the configuration
Returns:
A ConfigurationDBAdapter configured via the file
Throws:
java.lang.RuntimeException - is thrown when the URL could not be access

getResourceAsStream

protected static java.io.InputStream getResourceAsStream(java.lang.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 ConfigurationDBAdapter configure(java.io.File configFile)
                                 throws java.lang.RuntimeException
Use the ConfigurationDBAdapter specified in the given application file. The format of the file is defined in esper-configuration-2.0.xsd.

Parameters:
configFile - File from which you wish to load the configuration
Returns:
A ConfigurationDBAdapter configured via the file
Throws:
java.lang.RuntimeException - when the file could not be found

© 2006-2016 EsperTech Inc.
All rights reserved.
Visit us at espertech.com