use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TmlHttpServlet method callDirect.
private final void callDirect(HttpServletRequest request, HttpServletResponse response) {
String service = request.getParameter("service");
if (service == null) {
logRequestParams(request);
return;
}
final String instance = determineInstanceFromRequest(request);
// PrintWriter out = response.getWriter();
Navajo tbMessage = null;
DispatcherInterface dis = null;
dis = DispatcherFactory.getInstance();
try {
tbMessage = constructFromRequest(request);
Navajo resultMessage = handleTransaction(instance, dis, tbMessage, null, null);
sendResponse(request, response, resultMessage);
statLogger.info("direct legacy call");
} catch (Exception ce) {
logger.error("Error: ", ce);
} finally {
dis = null;
}
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TmlHttpServlet method handleTransaction.
@SuppressWarnings({ "rawtypes", "unchecked" })
private Navajo handleTransaction(String instance, DispatcherInterface dis, Navajo in, Object certObject, ClientInfo clientInfo) throws FatalException {
//
if (this.bundleContext != null) {
// OSGi environment:
ServiceReference sr = bundleContext.getServiceReference(LocalClient.class.getName());
if (sr == null) {
logger.warn("Resolving localclient service failed. Falling back to regular.");
return fallbackHandleTransaction(dis, in, certObject, clientInfo);
}
LocalClient lc = (LocalClient) bundleContext.getService(sr);
Navajo nn = lc.handleInternal(instance, in, certObject, clientInfo);
bundleContext.ungetService(sr);
lc = null;
return nn;
}
return fallbackHandleTransaction(dis, in, certObject, clientInfo);
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TmlRunnableBuilder method constructRequest.
private static AsyncRequest constructRequest(final HttpServletRequest req, HttpServletResponse resp, String instance) throws IOException {
Object certObject = req.getAttribute("javax.servlet.request.X509Certificate");
String contentEncoding = req.getHeader("Content-Encoding");
String acceptEncoding = req.getHeader("Accept-Encoding");
AsyncRequest request = null;
if ("POST".equals(req.getMethod())) {
request = new BaseRequestImpl(req, resp, acceptEncoding, contentEncoding, certObject, instance);
} else {
Navajo in = TmlHttpServlet.constructFromRequest(req);
request = new BaseRequestImpl(in, req, resp, instance);
}
return request;
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class ITAsyncClient method testAsync.
@Test
@Ignore
public void testAsync() throws Exception {
final ManualAsyncClient ac = new AsyncClientImpl();
String service = "club/InitUpdateClub";
System.err.println(TestConfig.NAVAJO_TEST_SERVER.getValue());
ac.setServer(TestConfig.NAVAJO_TEST_SERVER.getValue());
ac.setUsername(TestConfig.NAVAJO_TEST_USER.getValue());
ac.setPassword(TestConfig.NAVAJO_TEST_PASS.getValue());
Navajo input = NavajoFactory.getInstance().createNavajo();
final NavajoResponseHandler showOutput = new NavajoResponseHandler() {
@Override
public void onResponse(Navajo n) {
logger.info("Navajo finished!");
try {
StringWriter sw = new StringWriter();
n.write(sw);
logger.info("Response2 : {}", sw);
} catch (NavajoException e) {
logger.error("Error: ", e);
}
}
@Override
public void onFail(Throwable t) {
logger.error("whoops: ", t);
}
@Override
public Throwable getCaughtException() {
return null;
}
};
for (int i = 0; i < 10; i++) {
ac.callService(input, service, showOutput);
logger.info("Exchange sent");
}
Thread.sleep(10000);
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class ServerAsyncRunner method run.
/**
* Main thread
*/
@Override
public void run() {
try {
prevTime = System.currentTimeMillis();
while (isIterating()) {
if (kill) {
logger.warn("Kill called in ServerAsyncRunner...");
myResult.getHeader().setCallBackInterrupt("kill");
setIterating(false);
}
if (myPollingInterval > 0) {
myNavajo.removeHeader();
myNavajo.addHeader(myResult.getHeader());
Navajo temp = doSimpleSend(myNavajo, myMethod);
if (temp.getMessage("ConditionErrors") != null) {
logger.warn("Had ConditionErrors in Asyncsend.. ");
killServerAsyncSend();
} else {
poll(temp);
}
}
}
} catch (ClientException ex) {
logger.debug("oooops");
myListener.handleException(ex);
return;
}
if (myListener != null) {
myListener.handleException(new ClientException(-1, -1, "Operation aborted"));
}
}
Aggregations