Developing Apama Applications > Apama EPL Reference > Types > Reference data types > context
context
Values of the context type are references to contexts. A context lets EPL applications organize work into threads that the correlator can concurrently execute.
Usage
Use one of the following constructors to create a context reference:
context(string name)
context(string name, boolean receivesInput)
The optional receivesInput Boolean flag controls whether the context is public or private:
*A public context can receive external, enqueued, and routed events.
*A private context cannot receive events from external components sent to the correlator. A private context can receive enqueued events from other contexts, and enqueued events and routed events from monitor instances in that context. The default is that a context is private.
When you create a context reference, the context might or might not already exist. You use the context reference to spawn to the context or enqueue an event to the context. When you spawn to a context, the correlator creates the context if it does not already exist.
When you start a correlator it has a single main context. You can then create additional contexts. Context objects are lightweight and creating one only creates a stub object and allocates an ID. In other words, when you create a context, you are actually creating a context reference.
Methods
After you create a context, you can call the following instance methods on that context:
ContextMethods
*current() — Returns a context object that is a reference to the current context. The current context is the context that contains the monitor instance or event instance that is calling this method.
*getId() — Returns an integer that is the ID of the context.
*getName() — Returns a string that is the name of the context.
*isPublic() — Returns a Boolean that indicates whether the context is public. If the context was created as a public context then the return value is true.
*toString() — Returns a string that contains the properties of the context. For example, for a public context whose name is test, the content of the returned string would be something like this:
context(1, “test”, true)
In addition, the current() static method returns a reference to the current context.
See also Contexts.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.