Runtime components : Core components : Contexts : Tasks : Customizing contexts : Defining contexts : Chaining to parent context automatically
  
Chaining to parent context automatically
After you enable the auto-chain function, you can chain a context to the parent context automatically if the context has the parent context name in its definition.
In the following example, if you enable the auto-chain function, the session context will be chained to its parent branchServer context automatically after creation:
<context id="branchServer" type="root" parent="nil">
  <refKColl refId="branchData" />
</context>
<context id="sessionCtx" parent="branchServer" type="session">
  <refKColl refId="sessionData" />
</context>
By default, the auo-chain function is not enabled. There are two ways to enable it: the application can either call API or set the attribute in btt.xml.
Class ContextFactory provides the following APIs to enable auto-chain function and query the flag:
setAutoChainToParentContext(boolean value)
boolean getAutoChainToParentContext()
You can also set the autoChainToParentContext attribute to enable the auto-chain function as shown in the following example:
<kColl id="context">
  <kColl id="classTable">
    <field id="context" value="com.ibm.btt.base.LocalContextImpl" />
    <field id="refService" />
  </kColl>
  <field id="initializer" value="com.ibm.btt.base.ContextInitializer" />
  <field id="extFile" value="dsectxt.xml" />
  <field id="autoChainToParentContext" value="true" />
</kColl>
Go up to
Defining contexts