Skip to content

Commit eb6f021

Browse files
committed
BAEL-305: Simplified FrontControllerServlet. Removed unused JBoss deployment descriptor.
1 parent 4a3460f commit eb6f021

2 files changed

Lines changed: 6 additions & 19 deletions

File tree

‎enterprise-patterns/front-controller-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/FrontControllerServlet.java‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,17 @@ protected void doGet(
2222

2323
private FrontCommand getCommand(HttpServletRequest request) {
2424
try {
25-
return (FrontCommand) getCommandClass(request)
26-
.asSubclass(FrontCommand.class)
27-
.newInstance();
28-
} catch (Exception e) {
29-
throw new RuntimeException("Failed to get command!", e);
30-
}
31-
}
32-
33-
private Class getCommandClass(HttpServletRequest request) {
34-
try {
35-
return Class.forName(
25+
Class type = Class.forName(
3626
String.format(
3727
"com.baeldung.enterprise.patterns.front.controller.commands.%sCommand",
3828
request.getParameter("command")
3929
)
4030
);
41-
} catch (ClassNotFoundException e) {
42-
return UnknownCommand.class;
31+
return (FrontCommand) type
32+
.asSubclass(FrontCommand.class)
33+
.newInstance();
34+
} catch (Exception e) {
35+
return new UnknownCommand();
4336
}
4437
}
4538
}

‎enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jboss-web.xml‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)