Server component must inherit com.nxstinc.nest.servlet.NEST class and com.nxstinc.nest.servlet.IProcess interface
package com.nxstinc.nest.servlet.api;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.nxstinc.nest.servlet.IProcess;
import com.nxstinc.nest.servlet.NEST;
import com.nxstinc.nest.servlet.ProcessException;
import com.nxstinc.nest.servlet.Result;
@WebServlet(value = "/Hello", description = "Hello example for server component")
public class Hello extends NEST implements IProcess {
private static final long serialVersionUID = 1L;
/**
* Server component beginning entry point method
*/
@Override
public void process(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/**
* Server component inputted data search
*/
Input in = getInputAsObject(request, Input.class);
try {
/**
* Server component outputted data creation
*/
ArrayList<Output> list = new ArrayList<Output>();
list.add(new Output(1, "a"));
list.add(new Output(2, "b"));
replyResult(new Result(list), request, response);
} catch (Throwable th) {
replyResult(new Result(Result.SERVICE_UNAVAILABLE,
"Sorry, Service Un-available"), request, response);
}
}
/**
* Delcare input paramaeter to server component class
*/
@Override
public Class<?> getInputSpec() {
return Input.class;
}
/**
* Delcare output paramaeter to server component class
*/
@Override
public Class<?> getOutputSpec() {
return Output.class;
}
static class Input {
String i1;
String i2;
}
static class Output {
int o1;
String o2;
Output(int o1, String o2) {
this.o1 = o1;
this.o2 = o2;
}
}
}