@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String method = req.getParameter("method");
PrintWriter writer = res.getWriter();
try {
ConnectionFactory factory;
if ("lookup".equals(method)) {
String lookup = "java:jboss/jaxr/ConnectionFactory";
InitialContext context = new InitialContext();
factory = (ConnectionFactory) context.lookup(lookup);
}
else if ("new".equals(method)) {
factory = ConnectionFactory.newInstance();
} else {
throw new IllegalArgumentException("Invalid method: " + method);
}
log.infof("ConnectionFactory at '%s' => %s", method, factory);
writer.println(factory.getClass().getName());
} catch (Exception ex) {
ex.printStackTrace(writer);
} finally {
writer.close();
}