setContext()

Sets a particular execution context to be part of the global execution context.

Syntax

void setContext(String contextName, Object context

Parameters

contextName
The name of the specific execution context to assign to the global execution context. Currently, MAPCONTEXT is the only valid value.

context
An object that contains the information for the execution context. For map execution contexts, this Object is of type MapExeContext.

Return values

None

Notes

You might explicitly set the map execution context if you want to execute a submap with a relationship transformation. In this case, you would choose to create a new context with its own calling context (initiator) in the map context so that the relationship behaves correctly.

Currently, you can only use the CxExecutionContext() to set the map execution context, and only save one MapExeContext() instance in the CxExecutionContext(). If you use setContext()to set a new MapExeContext()into the CxExecutionContext(), the old one will be gone.

Examples

The following example shows the use of setContext():

         mapExeContext originalMapExeContext = (MapExeContext)
cwExecCtx.getContext(CxExecutionContext.MAPCONTEXT);
     MapExeContext newMapExeContext = new MapExeContext();
newMapExeContext.setInitiator(originalMapExeContext.getInitiator());
     newMapExeContext.setConnName(originalMapExeContext.getConnName());
     newMapExeContext.setLocale(originalMapExeContext.getLocale());
     cwExecCtx.setContext(CxExecutionContext.MAPCONTEXT,
newMapExeContext);

The following example saves a map execution context into a global execution context:

globalExeContext.setContext(CxExecutionContext.MAPCONTEXT,
   mapExeContext);

The following example shows how to set the map execution context:

CxExecutionContext cwCtx = new CxExecutionContext();
MapExeContext mapCtx = new MapExeContext();
cwCtx.setContext(CxExecutionContext.MAPCONTEXT, mapCtx);

// do some work involving execution context

     cwExecCtx.setContext(CxExecutionContext.MAPCONTEXT,
originalMapExeContext);

Copyright IBM Corp. 1997, 2004