Descriptions of methods on the Context class
You can call the following methods on a
Context object. For more information, see the description of the
context type in the
API Reference for EPL (ApamaDoc) .
public long getId() Returns the unique identifier for the context. For a Context instance that would return the following toString() result: "context(2,"context_name",false)", the getId() method returns the value 2. This method returns 0 for a Context instance created with the default constructor.
public String getName() Returns the name of the context. For example, suppose you create a context with the following EPL code:
context c := context("test");
If you transfer a reference to this context into your JMon application, a call to the getName() method on this context instance returns "test".
This method returns an empty string for a Context instance created with the default constructor.
public String toString() Returns a string representation of the context instance. This method produces a string that is identical to the string that EPL produces. For example: "context(2,"context_name",false)". The first item in the string, 2 in this example, is the context's unique identifier. The second item in the string, "context_name", is the name of the context. The third item in the string is the value of the receivesInput boolean flag, which indicates whether the context is public or private.
This method returns "context(0,"",false)" for a Context instance created with the default constructor.
public static Context getCurrent() Returns a Context instance that corresponds to the current correlator context. This is the context that contains the code that you are calling. Apama executes single-threaded JMon applications in the main correlator context. Consequently, this method always returns a Context instance that references the main correlator context.
During execution, JMon applications can create new Java threads. Do not confuse new threads with correlator contexts. The Context.getCurrent() method returns null when you call it inside newly created Java threads.