<kColl id="web2_xml"> <field id="requestHandler" value="com.ibm.btt.channel.Web2RequestHandler" /> <field id="presentationHandler" value="com.ibm.btt.channel.Web2PresentationHandler" /> <field id="processor" value="com.ibm.btt.channel.BTTMessageProcessor" /> <field id="cookies" value="false" /> <field id="encoding" value="UTF-8" /> <field id="runInSession" value="true" /> <field id="requestContext" value="XmlChannelContext" /> <field id="dataFormatter" value="XmlChannelFormatter" /> <field id="replyContext" value="XmlReplyContext" /> <field id="replyFormatter" value="XmlReplyFormatter" /> <field id="sessionReplyContext" value="XmlSessionReplyContext" /> <field id="sessionReplyFormatter" value="XmlSessionReplyFormatter" /> </kColl> <kColl id="WEB2Client"> <field id="startUpOp" value="CreateSessionOpStep" /> </kColl>
<CreateSessionOpStep.xml> <operation id="CreateSessionOpStep" context="myContext" implClass="com.ibm.btt.sample.opstep.CreateSessionOpStep"> </operation> <context id="myContext" type="op"> <refKColl refId="myCtxData" /> </context> <kColl id="myCtxData"> <field id="test" /> </kColl> </CreateSessionOpStep.xml>
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); } }
KeyedCollection settings = ChannelInitializer.getSettings(); String startupOp = (String) settings.tryGetValueAt(ChannelConstant.STARTUPOP); if (startupOp != null) { Operation oper = (BTTServerOperation) BTTServerOperation.readObject(startupOp); oper.execute(); final Context context = oper.getContext(); final Context sessionCtx = context.getParent(); final HttpSession session = request.getSession(); final SessionEntry se = new SessionEntry(session); se.setSessionId(session.getId()); se.setCurrentContext(sessionCtx); CSSessionHandler.addSession(se); response.setContentType("text/html"); ServletOutputStream o=response.getOutputStream(); String message="create sessionContext successful..."; }