architecture of esobi club based on j2ee

35
Architecture of eSobi club based on J2EE Allan Huang @ eSobi Inc.

Upload: allan-huang

Post on 15-Dec-2014

317 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Architecture of eSobi club based on J2EE

Architecture of eSobi club based on J2EE

Allan Huang @ eSobi Inc.

Page 2: Architecture of eSobi club based on J2EE

Agenda

Software Layers for J2EE Application Table Schema structure and Domain Object

design Look from Top-Down, Carry out from Bottom-

Up

Page 3: Architecture of eSobi club based on J2EE

Integration Tier

Business Tier

Presentation Tier

Software Layers for J2EE Application

Arc

hite

ctur

e C

ompo

nent

Lay

er(F

ram

ewor

k)

Dom

ain

Obj

ect

Laye

r(D

omai

n M

odel

/ E

ntity

)Presentation Layer

(Servlet / JSP)

Deployment Layer

Business Logic Layer(Business Object)

Data Access Object Layer

Business Delegate Layer

Page 4: Architecture of eSobi club based on J2EE

Architecture Component Layer Generic application utilities Often, these objects are good candidates for

enterprise-wide use Well-known open source projects

Jakarta commons, dom4j, log4j, xerces, quartz, java mail, jasypt, captcha …

Page 5: Architecture of eSobi club based on J2EE

Domain Object Layer

Lightweight structures for related business information

Enterprise Java Bean BMP Entity Bean (EJB1.0) CMP Entity Bean (EJB2.0) POJO (EJB3.0)

Page 6: Architecture of eSobi club based on J2EE

Ratings of Data Persistence Methods

Goal JDBC EJB/BMP EJB/CMP JDO O/R Tool

Min Learning curve High Low Low Medium Medium

Min Code and configuration

Low Low Low Medium Medium

Max Ability to tune High Medium Low Low Low

Min Deployment effort High Low Low Medium Medium

Max Code portability Medium Medium High High High

Min Vendor reliance High Medium Medium Medium Low

Max Availability and fail-over

Low High High Low Low

Manageable via JTA Yes Yes Yes Yes Yes

Page 7: Architecture of eSobi club based on J2EE

Data Access Object Layer

Encapsulate data access and manipulation in a separate layer DB CRUD, File, XML, FTP Server, Mail Server ...

1:1 correspondence between VO and DAO Traditional JDBC DAO vs. Spring DAO Bean

Aspect-oriented programming (AOP) Cross-cutting concerns

Inverse of Control (IOC)

Page 8: Architecture of eSobi club based on J2EE

Business Logic Layer

Manages business processing rules and logic Maximize the possibility of reuse Access Business Objects (BO) via Service Locator

(Pattern) Stateless Session Bean vs. Spring Bean Fast Lane Reader (Pattern)

A more efficient way to access tabular, read-only, potentially stale data

Transfer Object (Pattern) Carry any multiple data elements across a tier Previously known as Value Object (is not Pattern) ?

Page 9: Architecture of eSobi club based on J2EE

Deployment Layer

Publishes business object capabilities Web Server (e.g. Tomcat) acted business

client, Application Server (e.g. Weblogic) acted business server

Remote session bean, Message-driven bean, RMI service, Web service, CORBA service ...

Page 10: Architecture of eSobi club based on J2EE

Features of Deployment Wrapper Types

Feature EJB Web Service

JMS RMI HTTP CORBA

Caller platform requirements

Java-complaint only

Any Any Java-complaint only

Any Any

Communication method supported

Synch. only Both Both Synch. only Synch. only

Synch. only

Coupling Tight Loose Loose Tight Loose Loose

Transaction support

Local and JTA Local and JTA Local Local Local Local

Requires J2EE container?

Yes No No No No No

Supports clustering for scalability and availability?

Yes Yes Yes No Yes Yes

Page 11: Architecture of eSobi club based on J2EE

Business Delegate Layer

Hide clients from the complexity of remote communication with business service components

Service Locator (Singleton) Transparently locate business components and

services in a uniform manner Class BeanFactoryLocator or

ApplicationContext of Spring Context

Page 12: Architecture of eSobi club based on J2EE

Presentation Layer

Controls display to the end user Servlet 2.4 & JSP 2.0 Servlet & Java Bean (View Object) JSP & Tag library JavaScript & DHTML & CSS

Asynchronous JavaScript And XML (AJAX)

Page 13: Architecture of eSobi club based on J2EE

AJAX

Only reload some part and difference of web page each time the user requests a change

A implementation of design style, not a framework

Consists of HTML, JavaScript, DHTML, and DOM, is an outstanding approach

Help you to transform clunky Web interfaces into interactive AJAX applications

AJAX Web or AJAX Application ?

Page 14: Architecture of eSobi club based on J2EE

Table Schema structure and Domain Object design

Page 15: Architecture of eSobi club based on J2EE

User-centric Tables & Classes ER Diagram Class Diagram

Table per subclass User, Supervisor, Member MemberFeed, SubscribeFeed, FavoriteFeed, Recomme

ndFeed, BackupFeed 1:1 Lazy initialization between Member and Memb

erProfile Nested MemberFolder

Tree structure 4 default folders per member

Page 16: Architecture of eSobi club based on J2EE

Feed-centric Tables & Classes ER Diagram Class Diagram

Nested FeedCategory Tree structure

Nested RecommendReply Tree structure While malicious of Reply == true, this reply would be removed from u

ser’s view FeedRecommend

While malicious of Recommend == true, this reply would be removed from user’s view

FeedTagCase between PublicFeed and FeedTag FeedVote between PublicFeed and User RecommendVote between FeedRecommend and User M:M between FeedTag and FeedRecommend

Page 17: Architecture of eSobi club based on J2EE

Mail-centric Tables & Classes ER Diagram Class Diagram

OutMail & InMail While trashed of OutMail == true, this mail would be rem

oved from sender’s view While trashed of InMail == true, this mail would be remo

ved from receiver’s view While one trashed of OutMail == true and trashed of it’s I

nMails == true simultaneously, these mails will be deleted from database

Page 18: Architecture of eSobi club based on J2EE

My Space-centric Tables & Classes ER Diagram Class Diagram

MySpaceSetting between MySpace and MySpaceChoice

MySpaceAnswer between MySpace and MySpaceQuestion

1:1 Lazy initialization between MemberProfile and MySpace

Page 19: Architecture of eSobi club based on J2EE

Access Control-centric Tables & Classes ER Diagram Class Diagram

Table per class hierarchy AccessControl, UserControl, RoleControl, GroupControl AccessRule, SupervisorRule, MemberRule

Nested Group Tree structure

M:M between Role and User M:M between Group and User Access Rule

Priority UserControl > RoleControl > GroupControl Resolves conflicts when the same type of AccessControl are

assigned

Page 20: Architecture of eSobi club based on J2EE

Forum-centric Tables & Classes ER Diagram Class Diagram

Nested TopicReply Tree structure While malicious of Reply == true, this reply would be re

moved from user’s view Topic Watch

Update last replied time when user replies Between User and ForumTopic

Page 21: Architecture of eSobi club based on J2EE

Look from Top-Down, Carry out from Bottom-Up

Page 22: Architecture of eSobi club based on J2EE

Ready for APIs & Components I User Authenticator

Related Tables & Classes User-centric

Login & Logout Cookie mechanics Password Digester Random 12-characters Password Generator

Page 23: Architecture of eSobi club based on J2EE

Ready for APIs & Components II eSobi Feed Subscriber

Related Tables & Classes User-centric Feed-centric

Public Feed count & Member Feed record eSobi Feed Recommender

Related Tables & Classes User-centric Feed-centric

Page 24: Architecture of eSobi club based on J2EE

Ready for APIs & Components III eSobi Folder Backup

Related Tables & Classes User-centric Feed-centric

eSobi Folder Restorer Related Tables & Classes

User-centric Feed-centric

Page 25: Architecture of eSobi club based on J2EE

Ongoing for APIs & Components I Data Migration

Old data is migrated to the new schema Data List Handler

A pattern for Large Search Result Sets Paging Controller applied to web page

RSS Parser Parse RSS XML to find information of feed

User Authorizer According to Access-Controls to find Access-Rules

Mail Carrier

Page 26: Architecture of eSobi club based on J2EE

Java Naming Convention

According to Java Bean convention Attribute firstly, Getter method secondly, Sett

er method lastly Collection-type Attribute, add extra Adder and

Remover method Convenient findXXXByZZZ method

Page 27: Architecture of eSobi club based on J2EE

SQL Syntax Convention

Statement Spells SQL keywords in upper case SQL statements are often broken into multiple

lines Table & Column name

Primary key should be the table name suffixed with "_id“

Separate words and prefixes with underlines, never use spaces

Page 28: Architecture of eSobi club based on J2EE

Logging Service Convention

Replace System.out / System.err println with Logger

Level warning & error & fatal on Production machine

Level trace & debug & info on SIT / UAT machine

Logging necessary messages about our logic. if log.isXXXEnabled, then log.XXX message

Page 29: Architecture of eSobi club based on J2EE

Centralized Controlling & Distributed Computing There’s no need to reinvent the wheel

Open Source Community Bitter design vs. Appropriate design

J2EE Pattern & GoF Pattern Hard code vs. Sophisticated Algorithm

Tree traverse method Universal entry between up-tier and down-tier

e.g. Service Locator & Session Façade Divide and conquer inside the same tier

Page 30: Architecture of eSobi club based on J2EE

Concurrent Access Risk

Deadlock while insert & update concurrently Dirty columns of table for performance gain AJAX seems delicious, but ...

Page 31: Architecture of eSobi club based on J2EE

Performance Issue & Tuning

High availability & High scalability Clustering & Load Balancing Fail Over & Session Persistence

Code Refactoring SQL statement (DAO) Tuning Business Logic (BO) Tuning Cached Result Page

Event-Driven: JMS (Synchronous) Scheduling: Quartz (Asynchronous)

Database Refactoring Re-Index on Tables Database Trigger Database Stored Procedure

Page 32: Architecture of eSobi club based on J2EE

Test-driven development

Planning Release planning creates the schedule Make frequent small releases The project is divided into iterations Iteration planning starts each iteration

Designing Simplicity Choose a system metaphor Refactoring whenever and wherever possible

Page 33: Architecture of eSobi club based on J2EE

Test-driven development

Coding Code must be written to agreed standards Integrate often Use collective code ownership Leave optimization till last

Testing All code must have unit tests All code must pass all unit tests before release When a bug is found tests are created Acceptance tests are run often

Page 34: Architecture of eSobi club based on J2EE

Reference

Core J2EE Patterns J2EE Patterns Catalog GoF Patterns AJAX Patterns Java Naming Convention Essential Database Naming Conventions SQL Syntax Conventions Extreme Programming

Page 35: Architecture of eSobi club based on J2EE

Q&A