Author Message
JanPetersen
Joined: Mar 18, 2015
Messages: 33
Offline
Hi Dev

My question is what is best practise when using a servlet in OD

*1 : How to create more than one exit point in a servlet

*2 : How to log from a servlet

I have attached a project "Aaod8xSevletTest00" with a servlet node.

Regards

Jan
Filename Aaod8xSevletTest00.zip [Disk] Download
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
The best practice with the custom servlet should be writing logic for processing values from the project variables and store the results back into the variables in the servletImplementation method only. The following sample demonstrates getting value from a variable named test (which you'd create in the Project Variable editor), increasing the value and storing it back to the variable. It also shows the API to do logging.


public void servletImplementation(com.avaya.sce.runtimecommon.SCESession mySession) {

int i = mySession.getVariable(IProjectVariables.TEST).getSimpleVariable().getIntValue();
i++;
mySession.getVariable(IProjectVariables.TEST).getSimpleVariable().setValue(i);

if (mySession.isDDTraceEnabled() == true) {
mySession.getTraceOutput().writeln(ITraceInfo.TRACE_LEVEL_INFO, "I am logging");
}

}

In terms of branching, you rather use a variable to store the state coming out of the servlet then use a Data node where you can use if/else (to exam the value of the variable coming out of the servlet) for branching
JanPetersen
Joined: Mar 18, 2015
Messages: 33
Offline
Hi Wilson

Found this in a Servlet node

* The user should override updateBranches() to determine which Goto that the
* framework will activate. If there is not at least one enabled Goto item,
* the framework will throw a runtime exception.<BR>

Would be very useful to have more than one "Branches".

So could you please investigate and provide an example.

Regards

Jan
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
It depends. You could use this method to manipulate the existing branches. The way to go about it is to first take a look at the code in the getBranches method, which creates the list that is passed to the updateBranches method. You can re-arrange the collection, delete or add new branches using similar code

aGoto = new com.avaya.sce.runtime.Goto("Return", 0, true, "Green");
list.add(aGoto);

aGoto = new com.avaya.sce.runtime.Goto("Return", 0, true, "Yellow");
list.add(aGoto);

aGoto = new com.avaya.sce.runtime.Goto("Return", 0, true, "Red");
list.add(aGoto);
Go to:   
Mobile view