Developing Apama Applications > Developing Apama Applications in Java > Overview of Apama Java Applications > Parallel processing in Java applications > Descriptions of methods on the Context class
Descriptions of methods on the Context class
You can call the following methods on a Context object. For more information, see context in the Types section of the Apama EPL Reference.
*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 Java 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.
For details about public and private contexts, see Developing Apama Applications in EPL, Implementing Parallel Processing, Creating contexts.
*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 Java applications in the main correlator context. Consequently, this method always returns a a Context instance that references the main correlator context.
During execution, Apama Java 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.
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.