Developing Apama Applications > Apama EPL Reference > Types > Reference 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:
*true — A public context can receive external events on the default channel, which is the empty string (""). There is no requirement for a monitor instance in this context to subscribe to the default channel.
*false — A private context does not receive external events on the default channel. This is the default.
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 send 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.
A context is subscribed to the union of the channels each of the monitor instances in that context is subscribed to. This is a property of the monitor instances running in a context and is not accessible by means of the context reference object.
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 © Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its Subsidiaries and or/its Affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.