use of org.jboss.additional.testsuite.jdkall.present.clustering.cluster.ejb.stateful.bean.Incrementor in project eap-additional-testsuite by jboss-set.
the class StatefulServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String module = getRequiredParameter(req, MODULE);
String bean = getRequiredParameter(req, BEAN);
HttpSession session = req.getSession(true);
Incrementor incrementor = (Incrementor) session.getAttribute(BEAN);
if (incrementor == null) {
try (LocalEJBDirectory directory = new LocalEJBDirectory(module)) {
incrementor = directory.lookupStateful(bean, Incrementor.class);
} catch (NamingException e) {
throw new ServletException(e);
}
}
try {
resp.setHeader(COUNT, String.valueOf(incrementor.increment()));
session.setAttribute(BEAN, incrementor);
} catch (NoSuchEJBException e) {
resp.setHeader(COUNT, String.valueOf(0));
session.removeAttribute(BEAN);
}
resp.getWriter().write("Success");
}
Aggregations