eSobi Website Multilayered Architecture

19
eSobi Website eSobi Website Multilayered Architecture Architecture Allan Huang @ esobi Inc. Allan Huang @ esobi Inc.

description

 

Transcript of eSobi Website Multilayered Architecture

Page 1: eSobi Website Multilayered Architecture

eSobi WebsiteeSobi WebsiteMultilayered ArchitectureArchitecture

eSobi WebsiteeSobi WebsiteMultilayered ArchitectureArchitecture

Allan Huang @ esobi Inc.Allan Huang @ esobi Inc.

Page 2: eSobi Website Multilayered Architecture

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

Page 3: eSobi Website Multilayered Architecture

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.

Page 4: eSobi Website Multilayered Architecture
Page 5: eSobi Website Multilayered Architecture
Page 6: eSobi Website Multilayered Architecture

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.

Page 7: eSobi Website Multilayered Architecture

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.

Page 8: eSobi Website Multilayered Architecture

Aspect Oriented Programming

AOP (Aspect Oriented Programming) that aims to increase Modularity by allowing the separation of Cross-Cutting Concerns.

Page 9: eSobi Website Multilayered Architecture

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.

Page 10: eSobi Website Multilayered Architecture

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.

Page 11: eSobi Website Multilayered Architecture

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.

Page 12: eSobi Website Multilayered Architecture

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.

Page 13: eSobi Website Multilayered Architecture

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.

Page 14: eSobi Website Multilayered Architecture

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.

Page 15: eSobi Website Multilayered Architecture

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.

Page 16: eSobi Website Multilayered Architecture

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.

Page 17: eSobi Website Multilayered Architecture

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.

Page 18: eSobi Website Multilayered Architecture

Reference

Spring Gossip: AOP 觀念與術語 Aspect Oriented Programming with Spring Java Reflection - Dynamic Proxies Apache Commons Proxy

Page 19: eSobi Website Multilayered Architecture

Q&A