Session 02 Design Patterns, Maven, Lombok
Session 02 Design Patterns, Maven, Lombok
ANTEA TRAINING
Design Patterns in Java
Session 02
• Summary
• The clients can get new objects without knowing which type
of object it will be.
• Usage of Prototype Pattern
• It
defines each behavior within its own class, eliminating the
need for conditional statements.
• It
makes it easier to extend and incorporate new behavior
without changing the application.
• Filters
are used before the request is even passed to the
adequate controllers for processing.
• These filters can exist in the form of a Filter Chain and include
multiple filters, or simply exist as one Filter.
• Nevertheless, they run checks on authorization,
authentication, supported browsers, whether the request
path violates any constraints and restrictions etc.
JEE Design Pattern
• Intercepting Filter Design Pattern:
JEE Design Pattern
• Composite Entity Pattern Design Pattern:
• The
Data Access Object pattern, most often shortened to
DAO is a pattern in which objects are dedicated to the
communication with the Data Layer.
• These objects often instantiate "Session Factories" for this
purpose and handle all of the logic behind communicating
with the database.
• The
standard practice is to create a DAO interface, followed
by a concrete class implementing the interface and all
methods defined in it.
JEE Design Pattern
• Data Access Object Design Pattern:
JEE Design Pattern
• Service Locator Design Pattern:
• This
pattern is used to transfer objects with lots of fields and
parameters in one go.
• The Transfer Object pattern employs new objects, used only
for transfer purposes, usually passed to the DAO.
• Theseobjects are serializable POJOs. They have fields, their
respective getters and setters, and no other logic.
JEE Design Pattern
• Transfer Object Design Pattern:
Session 02
Lombok project
Session 02
Lombok Project
• Introduction to Project:
• Project Lombok is a java library that automatically plugs into
your editor and build tools, to avoid the repetitive code.
• Available for most of IDEs like Jetbrains IntelliJ IDEA.
• This
is such a common pattern that Lombok developers have
cared to simplify it for us:
Lombok Project
• Automate Objects Composition:
https://projectlombok.org/
• If
there are a lot of dependencies for the project. Then it is
easy to handle those dependencies using maven.
• If
the dependency version update frequently. Then one has
to only update version ID in Pom file to update dependencies.
• Continuous builds, integration, and testing can be easily
handled by using maven.
• When one needs an easy way to Generating documentation
from the source code, Compiling source code, Packaging
compiled code into JAR files or ZIP files.
Maven Automation Tool
• How maven works?
Maven Automation Tool
• Core Concepts of Maven:
• POM Files: are XML file that contains information related to the
project and configuration information used by Maven to build
the project.
• Dependencies and Repositories: Dependencies are external
Java libraries required for Project and repositories are
directories of packaged JAR files.
• Build Life Cycles, Phases and Goals: A build life cycle consists of
a sequence of build phases, and each build phase consists of a
sequence of goals.
• Build Profiles: Build profiles a set of configuration values which
allows you to build your project using different configurations.
Maven Automation Tool
• The sample of pom.xml:
Maven Automation Tool
• Maven Repository: