public class ConfigurationSocketAdapter extends Object
Constructor and Description |
---|
ConfigurationSocketAdapter() |
Modifier and Type | Method and Description |
---|---|
ConfigurationSocketAdapter |
configure()
Use the configuration specified in an application
resource named esper.cfg.xml.
|
ConfigurationSocketAdapter |
configure(File configFile)
Use the ConfigurationSocketAdapter specified in the given application
file.
|
ConfigurationSocketAdapter |
configure(String resource)
Use the ConfigurationSocketAdapter specified in the given application
resource.
|
ConfigurationSocketAdapter |
configure(URL url)
Use the ConfigurationSocketAdapter specified by the given URL.
|
ConfigurationSocketAdapter |
configureFromString(String xml)
Use the ConfigurationSocketAdapter specified by the given XML String.
|
protected static InputStream |
getConfigurationInputStream(String resource)
Get the ConfigurationSocketAdapter file as an InputStream.
|
protected static InputStream |
getResourceAsStream(String resource)
Returns an input stream from an application resource in the classpath.
|
Map<String,SocketConfig> |
getSockets() |
void |
setSockets(Map<String,SocketConfig> sockets) |
public Map<String,SocketConfig> getSockets()
public void setSockets(Map<String,SocketConfig> sockets)
public ConfigurationSocketAdapter configure() throws RuntimeException
RuntimeException
- thrown to indicate error reading configurationpublic ConfigurationSocketAdapter configure(String resource) throws RuntimeException
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.resource
- if the file name of the resourceRuntimeException
- thrown to indicate error reading configurationprotected static InputStream getConfigurationInputStream(String resource) throws RuntimeException
See getResourceAsStream for information on how the resource name is resolved.
resource
- is the resource nameRuntimeException
- thrown to indicate error reading configurationpublic ConfigurationSocketAdapter configureFromString(String xml) throws RuntimeException
xml
- XML stringRuntimeException
- is thrown when the URL could not be accesspublic ConfigurationSocketAdapter configure(URL url) throws RuntimeException
url
- URL from which you wish to load the configurationRuntimeException
- is thrown when the URL could not be accessprotected static InputStream getResourceAsStream(String resource)
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.
resource
- to get input stream forpublic ConfigurationSocketAdapter configure(File configFile) throws RuntimeException
configFile
- File from which you wish to load the configurationRuntimeException
- when the file could not be found