Managing Session

BTT uses session context to do session management and uses BTT operation to create the session context. When the http session is created in an Web 2.0 application, it will create a session context to maintain the session scope values.

Define the following configuration in channel handler section:

<kColl id="WEB2Client">
	<field id="startUpOp" value="CreateSessionOpStep" >
</kColl>

The value of startUpOp is the name of operation that creates the session context. For example, the session context data definition is as follows:

<kColl id="sessionData">
	<refData refId="TID" />
	<refData refId="userId" />
	<refData refId="CustomerId" />
	<refData refId="CustomerName" />
	<refData refId="HostBuff" />	
	<refData refId="sessionID" />
	<refData refId="locale" />
</kColl>

The context definition is as follows:

<context id="sessionCtx" parent="branchServer" type="session">
	<refKColl refId="sessionData" />
</context>

Following is a sample of creating session operation:

public class CreateSessionOpStep extends BTTServerOperation {
	@Override
	public void execute() throws Exception {
		Context root = ContextFactory.getRoot();
		if (root == null) {
		System.out.println("Creating root ctx");
			root = ContextFactory.createContext("branchServer", false);
		}
		System.out.println("Create session context");
		Context sessionCtx = ContextFactory.createContext("sessionCtx", false);
		sessionCtx.chainTo(root);
		Context ctx = getContext();
		ctx.chainTo(sessionCtx);
	}
}