
com.fluxtion.runtime.EventProcessorContext Maven / Gradle / Ivy
package com.fluxtion.runtime;
import com.fluxtion.runtime.callback.DirtyStateMonitor;
import com.fluxtion.runtime.callback.EventDispatcher;
import com.fluxtion.runtime.input.SubscriptionManager;
import com.fluxtion.runtime.node.NodeNameLookup;
import com.fluxtion.runtime.time.Clock;
/**
* Runtime access to various services in the running EventProcessor instance.
*/
public interface EventProcessorContext {
String DEFAULT_NODE_NAME = "context";
NodeNameLookup getNodeNameLookup();
EventDispatcher getEventDispatcher();
DirtyStateMonitor getDirtyStateMonitor();
SubscriptionManager getSubscriptionManager();
Clock getClock();
T getExportedService(Class exportedServiceClass);
T getExportedService();
/**
* Retrieves an injected instance at runtime. Fails with {@link RuntimeException} if no instance is found
*
* see {@link StaticEventProcessor#injectInstance(Object)}
*
* @param instanceClass The class of the instance to retrieve
* @param The type of the returned class
* @return The instance injected.
*/
T getInjectedInstance(Class instanceClass);
/**
* Retrieves an injected instance at runtime. Fails with {@link RuntimeException} if no instance is found
*
* see {@link StaticEventProcessor#injectNamedInstance(Object, String)}
*
* @param instanceClass The class of the instance to retrieve
* @param The type of the returned class
* @return The instance injected.
*/
T getInjectedInstance(Class instanceClass, String name);
/**
* Retrieves an injected instance at runtime.
*
* see {@link StaticEventProcessor#injectInstance(Object)}
*
* @param instanceClass The class of the instance to retrieve
* @param The type of the returned class
* @return The instance injected.
*/
T getInjectedInstanceAllowNull(Class instanceClass);
/**
* Retrieves an injected instance at runtime.
*
* see {@link StaticEventProcessor#injectNamedInstance(Object, String)}
*
* @param instanceClass The class of the instance to retrieve
* @param The type of the returned class
* @return The instance injected.
*/
T getInjectedInstanceAllowNull(Class instanceClass, String name);
V getContextProperty(K key);
/**
* The public {@link StaticEventProcessor} instance for this context
*
* @return Encapsulating StaticEventProcessor
*/
default StaticEventProcessor getStaticEventProcessor() {
return getExportedService(StaticEventProcessor.class);
}
/**
* Helper method for {@link EventDispatcher#processReentrantEvent(Object)}
*
* @param event to dispatch to this {@link StaticEventProcessor}
*/
default void processReentrantEvent(Object event) {
getEventDispatcher().processReentrantEvent(event);
}
/**
* Helper method for {@link EventDispatcher#processAsNewEventCycle(Object)} (Object)}
*
* @param event to dispatch to this {@link StaticEventProcessor}
*/
default void processAsNewEventCycle(Object event) {
getEventDispatcher().processAsNewEventCycle(event);
}
/**
* Helper method for {@link EventDispatcher#processReentrantEvents(Iterable)}
*
* @param iterable to dispatch to this {@link StaticEventProcessor}
*/
default void processAsNewEventCycle(Iterable