implements Bookshelf {
+ private static Bookshelf INSTANCE;
+
+ @Override
+ public Bookshelf getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new BookshelfImpl();
+ INSTANCE.init();
+ }
+ return INSTANCE;
+ }
+
+ @Override
+ public Book findByTitle(String title) {
+ return this.stream()
+ .filter(book -> book.getTitle().toLowerCase().contains(title.toLowerCase()))
+ .findFirst()
+ .orElse(null);
+ }
+}
diff --git a/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/book-found.jsp b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/book-found.jsp
new file mode 100644
index 0000000000..42e08b4a46
--- /dev/null
+++ b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/book-found.jsp
@@ -0,0 +1,12 @@
+
+
+
+ Bookshelf: Title found
+
+
+ Our Bookshelf contains this title:
+ ${book.getTitle()}
+ Author: ${book.getAuthor()}
+
+
+
diff --git a/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/book-notfound.jsp b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/book-notfound.jsp
new file mode 100644
index 0000000000..2f8ac01755
--- /dev/null
+++ b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/book-notfound.jsp
@@ -0,0 +1,10 @@
+
+
+
+ Bookshelf: Title not found
+
+
+ Our Bookshelf doesn't contains this title:
+ ${param.get("title")}
+
+
diff --git a/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/unknown.jsp b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/unknown.jsp
new file mode 100644
index 0000000000..b52b2de8d5
--- /dev/null
+++ b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/jsp/unknown.jsp
@@ -0,0 +1,9 @@
+
+
+
+ Bookshelf: Command unknown
+
+
+ Sorry, this command is not known!
+
+
diff --git a/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/web.xml b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..77113db09b
--- /dev/null
+++ b/enterprise-patterns/front-controller-pattern/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,15 @@
+
+
+
+ front-controller
+ com.baeldung.enterprise.patterns.front.controller.FrontControllerServlet
+
+
+ front-controller
+ /
+
+
diff --git a/enterprise-patterns/pom.xml b/enterprise-patterns/pom.xml
new file mode 100644
index 0000000000..2fba12547f
--- /dev/null
+++ b/enterprise-patterns/pom.xml
@@ -0,0 +1,35 @@
+
+
+ 4.0.0
+
+ com.baeldung.enterprise.patterns
+ enterprise-patterns-parent
+ pom
+
+ front-controller-pattern
+
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+
+ 1.8
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 6395fcd49b..db3fa8a21c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,6 +29,8 @@
dozer
dependency-injection
deltaspike
+
+ enterprise-patterns
gson