About this task
The
start() method in com.ibm.btt.tools.aw.sample.Activator.java
of BTTJumpStartSampleRCPClient Project initializes BTT and BTT business components,
and then it establishes BTT C/S connectivity.
Replace the content of the
start() method
as follows:
public void start(BundleContext context) throws Exception {
super.start(context);
try {
InitManager.reset("jar:///definitions/btt.xml");
UniversalElementFactory elementFactory;
elementFactory = new UniversalElementFactory("jar:///bcConfig/BusinessComponentConfig.xml");
BTTFactory.setElementFactory(elementFactory);
XUIEngine.init("jar:///definitions/xuiengine.xml");
ContextFactory.setAutoChainToParentContext(true);
// create root context, the first context which created is the root.
ContextFactory.createContext("branchClientCtx");
//establish Client/Server connectivity
CSClientService cs = CSClient.getCSClient("realCSClient");
cs.setKeepAliveConnection(false);
cs.establishSession();
//send client info to server to create session context,
BTTOperation oper = (BTTOperation) BTTOperation
.readObject("startupClientOp");
oper.execute();
oper.close();
}catch (Exception e){
e.printStackTrace();
}
plugin = this;
}
Where:
- The InitManager is used to initialize BTT definition
files.
- BTTFactory.setElementFactory(elementFactory) is used
to initialize BTT business components.
- XUIEngine.init() is used to initialize the XML UI engine
from the global settings file.
- ContextFactory.setAutoChainToParentContext(true) is a
switch for local context. If the switch is on, when a local context with the
parent property is created, the local context will be chained to its parent
context automatically.
- branchClientCtx is the root context in this application.
You can create root context according to your requirements, such as branch
information context, teller information context and so on.
- CSClientService is the key class used to establish communications
with the server side, for example: sending and receiving information.
- StartupClientOp is used to create session context in
the server side.
Remember to close Client/Server connectivity in Activator class
stop(BundleContext
context) method:
try {
//logoff and dispose session context in server side.
BTTOperation oper = (BTTOperation) BTTOperation
.readObject("logoffClientOp");
oper.execute();
oper.close();
//close Client/Server connectivity
CSClientService cs = CSClient.getCSClient("realCSClient");
cs.closeSession();
} catch (Exception e) {
e.printStackTrace();
}