skill_ufmt
Victor_Yuji_Maehira
Eu implementei minha própria classe RequestHelper:
public class RequestHelper {
HttpServletRequest request;
public RequestHelper (HttpServletRequest request) {
this.request = request;
}
public Command getCommand() throws Exception {
String commandName = "<nomeDoPacote>" + request.getParameter("helper");
System.out.println("commandName = " + commandName);
Class businessLogicClass = Class.forName(commandName);
if (!Command.class.isAssignableFrom(businessLogicClass)) {
throw new ServletException("classe nao implementa a interface: " + commandName);
}
return (Command) businessLogicClass.newInstance();
}
}
Command ficou assim:
public interface Command {
void execute (HttpServletRequest req, HttpServletResponse res) throws Exception;
}