/** * Use the configuration specified in an application * resource named <tt>esper.cfg.xml</tt>. * @return Configuration initialized from the resource * @throws EPException thrown to indicate error reading configuration */ public Configuration configure() throws EPException { configure('/' + ESPER_DEFAULT_CONFIG); return this; }
/** * Configure the Esper Service Provider to create the appropriate Esper * Runtime. * * @throws IOException * @throws EPException */ private void configureEPServiceProvider() throws EPException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Configuring the Esper Service Provider with name: " + name); } if (this.configuration != null && this.configuration.exists()) { Configuration esperConfiguration = new Configuration(); esperConfiguration = esperConfiguration.configure(this.configuration.getFile()); epServiceProvider = EPServiceProviderManager.getProvider(name, esperConfiguration); LOG.info("Esper configured with a user-provided configuration", esperConfiguration); } else { epServiceProvider = EPServiceProviderManager.getProvider(name); } if (LOG.isDebugEnabled()) { LOG.debug("Completed configuring the Esper Service Provider with name: " + name); } } }
/** * Contributes bindings and other configurations for this module to {@code binder}. * <p/> * <p><strong>Do not invoke this method directly</strong> to install submodules. Instead use * {@link com.google.inject.Binder#install(com.google.inject.Module)}, which ensures that {@link com.google.inject.Provides provider methods} are * discovered. */ @Override public void configure(final Binder binder) { // JMX binder.bind(MBeanServer.class).toInstance(ManagementFactory.getPlatformMBeanServer()); // Jetty/Jersey stuff binder.bind(JacksonJsonProvider.class).asEagerSingleton(); // Main configuration file final RealtimeSystemConfig config = new ConfigurationObjectFactory(System.getProperties()).build(RealtimeSystemConfig.class); binder.bind(RealtimeSystemConfig.class).toInstance(config); // Configure Esper final Configuration configuration = new Configuration(); if (!config.getEsperConfigurationFile().equals("")) { configuration.configure(new File(config.getEsperConfigurationFile())); } binder.bind(EPServiceProvider.class).toInstance(EPServiceProviderManager.getDefaultProvider(configuration)); // Configure the routes configureFromFile(binder, config.getConfigurationFile()); }
/** * Returns the event processing service provider. If the provider is null an * instance will be created via the EPServiceProviderManager. * * @return event processing service provider */ public EPServiceProvider getEsperService(boolean configured) { if (esperService == null) { if (configured) { Configuration configuration = new Configuration(); configuration.configure(); esperService = EPServiceProviderManager.getProvider("DefaultConfiguredProvider", configuration); } else { esperService = EPServiceProviderManager.getDefaultProvider(); } } return esperService; }
epConfig.configure("cointrader-esper.cfg.xml");