2. Agenda
Java EE Web Technique
Multilayered Architecture
Presentation / Web Service Layer
Aspect Oriented Programming
AOP Terminology
Proxy Pattern
Dynamic Proxy
Inversion Of Control
Service Locator Layer
Business Logic Layer
Data Access Layer
Domain Object Layer
Utility Layer
3. Java EE Web Technique
A tailored lightweight and multifunctional web platform
for business operations of eSobi.
Refer some of 14 rules on the book High Performance
Web Sites.
Design Presentation and Web Service Layer by referring
MVC concept and structure of Struts 2
Design Business Logic Layer and Data Access Layer by
referring AOP and IoC concept of Spring 2
Auto-setup all bean instances by using the extends and
implements declarations to reduce the amount of
configuration files.
4.
5.
6. Presentation / Web Service
Layer
Web Context Listener initializes/destroys needed
resources firstly/lastly while web context is
loaded/unloaded.
Resource Access Filter intercepts any HTTP requests,
and handles/passes/rejects them, further forward them
to the next handler/servlet.
The main goal of HTTP ETag Response Stream, HTTP
Cache-Control Header and Compressed Response
Stream reduce the amount or frequency of HTTP
response transmission.
7. Presentation / Web Service
Layer
HTTP Request, HTTP Response and Servlet Context
are wrapped in a Request Context is convenience to be
passed to Controllers.
Page Action and it’s Controller handle HTTP requests
and return an HTML page via Page Forward or Page
Redirect.
AJAX Call and it’s Controller handle HTTP requests and
return an JSON string that wrapped in AJAX Call Return
and JSON Message.
Remote Command and It’s Controller handle HTTP
requests and return an XML string in Remote Command
Return and XML Message.
8. Aspect Oriented Programming
AOP (Aspect Oriented Programming) that aims to
increase Modularity by allowing the separation of Cross-
Cutting Concerns.
9. AOP Terminology
Join point
A point during the execution of a program, such as the execution
of a method or the handling of an exception.
Advice
Action taken by an aspect at a particular join point. Different
types of advice include "around," "before" and "after" advice.
Pointcut
A predicate that matches join points.
Weaving
linking aspects with other application types or objects to create
an advised object. This can be done at compile time, load time,
or at runtime.
10. Proxy Pattern
A surrogate or placeholder for another object to control
access to it.
Deferred Initialization
Acts as a "stand-in" for the actual implementation allowing it to be
instantiated only when absolutely necessary.
Security
Verify that the user actually has the permission to execute the
method.
Logging
Log every method invocation, providing valuable debugging
information.
Performance Monitoring
Log each method invocation to a performance monitor allowing
system administrators to see what parts of the system are potentially
bogged down.
11. Dynamic Proxy
Using standard Java SE Dynamic Proxies (since JDK1.3)
for AOP proxies. This enables any interface (or set of
interfaces) to be proxied.
12. Inversion of Control
The main goal of IOC (Inversion of Control) is to remove
dependencies of an application.
DI (Dependency Injection) is a subtype of IoC and is
implemented by constructor injection, setter injection or
method injection.
13. Service Locator Layer
Singleton Service Bean Factory create all Service Bean
instances at initiate time of web context and put them
into it’s own pool. DAO Bean Factory is the same as
above circumstances.
According to AOP, all bean instances are constructed by
Java SE Reflection API and create dynamic
implementations of interfaces at runtime by Java SE
Dynamic Proxy API.
14. Business Logic Layer
Service Bean must implement specific service interface
that implements IGeneric Service Interface, and extends
Abstract Generic Service.
Transaction Adviser is responsible for opening SQL
connection, executing target method, committing result,
and finally close SQL connection by Java SE Dynamic
Proxy API.
Thread Local<Stack> of Transaction Adviser keeps track
of each target method recursively via push and pop
action per thread lifecycle.
15. Data Access Layer
DAO Bean must implement specific DAO interface that
implements IGeneric DAO Interface, and extends
Abstract Generic DAO.
JDBC Utility is responsible for setting SQL Data Source
at initiate time of web context and closing Data Source at
destroy time of web context.
Thread Local<Connection> of JDBC Utility keeps track
of concurrent connection per thread lifecycle.
16. Domain Object Layer
Domain Object classes must extend Abstract Entity
interface.
Each domain class has an unique ID attribute as primary
key and its default equals and hashCode methods are
overridden.
Relationships be expressed as Java List or Set structure
among domain classes are constructed by according to
E-R model.
17. Utility Layer
Introduce well-known Apache Commons libraries that
contain BeanUtils, Codec, Collections, Compress,
DBCP, DbUtils, Email, FileUpload, IO, Lang, Logging,
Net, Primitives, Proxy, and Log4J, Xerces, etc.
Develop Utility classes (framework) that are
independence on Java EE web container based on
above libraries.
18. Reference
Spring Gossip: AOP 觀念與術語
Aspect Oriented Programming with Spring
Java Reflection - Dynamic Proxies
Apache Commons Proxy