BAEL-305: Simplified FrontControllerServlet. Removed unused JBoss deployment descriptor.

This commit is contained in:
Christian Rädel 2016-09-03 20:13:55 +02:00
parent 4a3460fd01
commit eb6f0214ca
2 changed files with 6 additions and 19 deletions

View File

@ -22,24 +22,17 @@ public class FrontControllerServlet extends HttpServlet {
private FrontCommand getCommand(HttpServletRequest request) {
try {
return (FrontCommand) getCommandClass(request)
.asSubclass(FrontCommand.class)
.newInstance();
} catch (Exception e) {
throw new RuntimeException("Failed to get command!", e);
}
}
private Class getCommandClass(HttpServletRequest request) {
try {
return Class.forName(
Class type = Class.forName(
String.format(
"com.baeldung.enterprise.patterns.front.controller.commands.%sCommand",
request.getParameter("command")
)
);
} catch (ClassNotFoundException e) {
return UnknownCommand.class;
return (FrontCommand) type
.asSubclass(FrontCommand.class)
.newInstance();
} catch (Exception e) {
return new UnknownCommand();
}
}
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
<context-root>/front-controller/</context-root>
</jboss-web>