/** * Use the mappings and properties specified in the given XML document. * The format of the file is defined in * <tt>esper-configuration-2.0.xsd</tt>. * * @param document an XML document from which you wish to load the configuration * @return A configuration configured via the <tt>Document</tt> * @throws EPException if there is problem in accessing the document. */ public Configuration configure(Document document) throws EPException { if (log.isDebugEnabled()) { log.debug( "configuring from XML document" ); } ConfigurationParser.doConfigure(this, document); return this; }
/** * Use the configuration specified in the given input stream. * @param configuration is the configuration object to populate * @param stream Inputstream to be read from * @param resourceName The name to use in warning/error messages * @throws EPException is thrown when the configuration could not be parsed */ protected static void doConfigure(Configuration configuration, InputStream stream, String resourceName) throws EPException { Document document = getDocument(stream, resourceName); doConfigure(configuration, document); }
/** * Use the configuration specified in the given application * resource. The format of the resource is defined in * <tt>esper-configuration-2.0.xsd</tt>. * <p/> * The resource is found via <tt>getConfigurationInputStream(resource)</tt>. * That method can be overridden to implement an arbitrary lookup strategy. * <p/> * See <tt>getResourceAsStream</tt> for information on how the resource name is resolved. * @param resource if the file name of the resource * @return Configuration initialized from the resource * @throws EPException thrown to indicate error reading configuration */ public Configuration configure(String resource) throws EPException { if (log.isDebugEnabled()) { log.debug( "Configuring from resource: " + resource ); } InputStream stream = getConfigurationInputStream(resource ); ConfigurationParser.doConfigure(this, stream, resource ); return this; }
/** * Use the configuration specified in the given application * file. The format of the file is defined in * <tt>esper-configuration-2.0.xsd</tt>. * * @param configFile <tt>File</tt> from which you wish to load the configuration * @return A configuration configured via the file * @throws EPException when the file could not be found */ public Configuration configure(File configFile) throws EPException { if (log.isDebugEnabled()) { log.debug( "configuring from file: " + configFile.getName() ); } try { ConfigurationParser.doConfigure(this, new FileInputStream(configFile), configFile.toString()); } catch (FileNotFoundException fnfe) { throw new EPException( "could not find file: " + configFile, fnfe ); } return this; }
/** * Use the configuration specified by the given URL. * The format of the document obtained from the URL is defined in * <tt>esper-configuration-2.0.xsd</tt>. * * @param url URL from which you wish to load the configuration * @return A configuration configured via the file * @throws EPException is thrown when the URL could not be access */ public Configuration configure(URL url) throws EPException { if (log.isDebugEnabled()) { log.debug( "configuring from url: " + url.toString() ); } try { ConfigurationParser.doConfigure(this, url.openStream(), url.toString()); return this; } catch (IOException ioe) { throw new EPException("could not configure from URL: " + url, ioe ); } }