@SuppressWarnings({"unchecked"})
public void handle(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String actionName = req.getParameter("action");
if (actionName != null) {
RequestHandler action = actions.get(actionName);
if (action == null) {
Class<RequestHandler> ac = classes.get(actionName);
if (ac != null) {
if (beanManager == null)
throw new IllegalArgumentException("No Weld manager present");
InjectionTarget<RequestHandler> it = beanManager.createInjectionTarget(beanManager.createAnnotatedType(ac));
CreationalContext<RequestHandler> cc = beanManager.createCreationalContext(null);
action = it.produce(cc);
it.inject(action, cc);
action.initialize(context);
actions.put(actionName, action);
}
}
if (action != null)
action.handle(req, resp);
else
throw new ServletException("No such matching action: " + actionName);
}
}