Package org.marketcetera.eventbus.server
Class EsperEngine
- java.lang.Object
-
- org.marketcetera.eventbus.server.EsperEngine
-
@EnableAutoConfiguration public class EsperEngine extends Object
Provides a default Esper workspace.Events need to be registered with the Esper runtime in order to be added. In the Marketcetera Automated Trading Platform, it is expected that events for the Esper runtime will implement either
EsperEventorHasEsperEvent. This is not explicitly required, but is the recommended process in order to allow as much automated behavior as possible.For events that implement
EsperEvent, in order to complete registration, one of two things must be done:- Implement
Component,Scope, and define the scope asConfigurableBeanFactory.SCOPE_PROTOTYPE. This will cause the event to be automatically registered on start. Subsequent events can be instantiated either directly or with the SpringApplicationContext. It doesn't matter which, for this purpose. - Explicitly register the event class with this bean in your application configuration. Add the event class to
getEventTypes().
Once these steps have been followed, any events passed to the default event bus will automatically be added to the MATP Esper runtime by this object.
Inject this bean if you want to use the "default" MATP runtime.
- Since:
- $Release$
- Version:
- $Id$
- Author:
- Colin DuPlantis
- Implement
-
-
Field Summary
Fields Modifier and Type Field Description private org.springframework.context.ApplicationContextapplicationContextprovides access to the Spring application contextprivate com.espertech.esper.common.client.configuration.ConfigurationconfigurationEsper configuration valueprivate Collection<Class<?>>eventTypesevent types provided by configurationprivate com.espertech.esper.runtime.client.EPRuntimeruntimeEsper main runtime objectprivate StringruntimeNameallows the default MATP runtime to have a custom name
-
Constructor Summary
Constructors Constructor Description EsperEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EsperQueryMetaDatadeployStatement(String inStatement)Deploy the given statement to the Esper engine.com.espertech.esper.common.client.configuration.ConfigurationgetConfiguration()Get the configuration value.Collection<Class<?>>getEventTypes()Get the eventTypes value.com.espertech.esper.runtime.client.EPRuntimegetRuntime()Get the runtime value.voidstart()Validate and start the object.voidstop()Stop the object.voidundeployStatement(EsperQueryMetaData inQueryMetaData)Undeploy the Esper statement associated with the given query data.
-
-
-
Field Detail
-
configuration
private com.espertech.esper.common.client.configuration.Configuration configuration
Esper configuration value
-
runtime
private com.espertech.esper.runtime.client.EPRuntime runtime
Esper main runtime object
-
eventTypes
private final Collection<Class<?>> eventTypes
event types provided by configuration
-
applicationContext
@Autowired private org.springframework.context.ApplicationContext applicationContext
provides access to the Spring application context
-
runtimeName
@Value("${metc.esper.runtime.name:MATP}") private String runtimeNameallows the default MATP runtime to have a custom name
-
-
Method Detail
-
start
@PostConstruct public void start()
Validate and start the object.
-
stop
@PreDestroy public void stop()
Stop the object.
-
deployStatement
public EsperQueryMetaData deployStatement(String inStatement) throws com.espertech.esper.runtime.client.EPRuntimeDestroyedException, com.espertech.esper.runtime.client.EPDeployException, com.espertech.esper.compiler.client.EPCompileException
Deploy the given statement to the Esper engine.- Parameters:
inStatement- aStringvalue, separated by ';' as necessary for multiple statements- Returns:
- an
EsperQueryMetaDatavalue - Throws:
com.espertech.esper.runtime.client.EPRuntimeDestroyedException- if the Esper engine is no longer availablecom.espertech.esper.runtime.client.EPDeployException- if the compiled Esper statement(s) cannot be deployedcom.espertech.esper.compiler.client.EPCompileException- if the Esper statement(s) cannot be compiled
-
undeployStatement
public void undeployStatement(EsperQueryMetaData inQueryMetaData) throws com.espertech.esper.runtime.client.EPRuntimeDestroyedException, com.espertech.esper.runtime.client.EPUndeployException
Undeploy the Esper statement associated with the given query data.- Parameters:
inQueryMetaData- anEsperQueryMetaDatavalue- Throws:
com.espertech.esper.runtime.client.EPRuntimeDestroyedException- if the Esper engine is no longer availablecom.espertech.esper.runtime.client.EPUndeployException- if the statement associated with the given meta data cannot be undeployed
-
getEventTypes
public Collection<Class<?>> getEventTypes()
Get the eventTypes value.- Returns:
- a
Collection<Class<?>>value
-
getRuntime
public com.espertech.esper.runtime.client.EPRuntime getRuntime()
Get the runtime value.- Returns:
- an
EPRuntimevalue
-
getConfiguration
public com.espertech.esper.common.client.configuration.Configuration getConfiguration()
Get the configuration value.- Returns:
- a
Configurationvalue
-
-