Class 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 EsperEvent or HasEsperEvent. 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:

    1. Implement Component, Scope, and define the scope as ConfigurableBeanFactory.SCOPE_PROTOTYPE. This will cause the event to be automatically registered on start. Subsequent events can be instantiated either directly or with the Spring ApplicationContext. It doesn't matter which, for this purpose.
    2. 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
    • 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 runtimeName
        allows the default MATP runtime to have a custom name
    • Constructor Detail

      • EsperEngine

        public EsperEngine()
    • 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 - a String value, separated by ';' as necessary for multiple statements
        Returns:
        an EsperQueryMetaData value
        Throws:
        com.espertech.esper.runtime.client.EPRuntimeDestroyedException - if the Esper engine is no longer available
        com.espertech.esper.runtime.client.EPDeployException - if the compiled Esper statement(s) cannot be deployed
        com.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 - an EsperQueryMetaData value
        Throws:
        com.espertech.esper.runtime.client.EPRuntimeDestroyedException - if the Esper engine is no longer available
        com.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 EPRuntime value
      • getConfiguration

        public com.espertech.esper.common.client.configuration.Configuration getConfiguration()
        Get the configuration value.
        Returns:
        a Configuration value