• No results found

Core J2EE Patterns, Frameworks and Micro Architectures

N/A
N/A
Protected

Academic year: 2021

Share "Core J2EE Patterns, Frameworks and Micro Architectures"

Copied!
81
0
0

Loading.... (view fulltext now)

Full text

(1)

[email protected]

Patterns & Design Expertise Center Sun Software Services

Core J2EE Patterns, Frameworks and

Micro Architectures

(2)

Agenda

● Patterns

● Core J2EE Pattern Catalog Background ● J2EE Progressive Refactoring

● Pattern Frameworks ● Micro Architecture

– Web Worker Micro Architecture Example – Messaging Micro Architecture Example

(3)

Architectural Decisions Produce

Varying Results

(4)
(5)

What Is A Pattern?

• “Solution to a recurring problem in a context” ➢ Context : What is the environment like?

➢ Problem : What do I want to do? ➢ Solution : How do I do it?

(6)

Patterns are...

Abstractions

Discovered, not created

Difficult to see the appropriate

granularity

Mined from good designs

(7)

Core J2EE Patterns

● Core J2EE Patterns are platform patterns.

– The context is bounded by the J2EE platform – Built upon non-platform patterns – GoF

(8)

Core J2EE Patterns Book

● 1st Edition June 2001

● 15 Patterns categorized by

tiers:

– Presentation – Business

– Integration

● Lots of Code Samples ● Design Considerations ● Bad Practices

● Refactorings

● 2nd Edition JavaOne, June 2003 ● 21 patterns

(9)

Core J2EE Patterns Book

Client Tier

Browser, Applets, Applications, Clients Presentation Tier

JSP, Servlets, UI Elements Business Tier

EJB and Business Objects Integration Tier JDBC, JMS, Connectors

Resource Tier

Databases, Systems Legacy

J2EE Pattern Catalog Addresses 3 Tiers

(10)

Pattern Format

Extensibility

Problem

Forces

Solution

– Structure – Interaction

Consequences

(11)

Pattern Strategies

Pattern is abstract and a strategy is

(more) concrete

(12)
(13)

Presentation-Tier Patterns

Intercepting Filter

Front Controller

Composite View

View Helper

Service to Worker

Dispatcher View

Context Object

Application Controller

new

(14)

Business Tier Patterns

Business Delegate

Session Facade

Service Locator

Transfer Object

Composite Entity

Transfer Object Assembler

Value List Handler

Business Object

Application Service

new

(15)

Integration Patterns

Data Access Object

Service Activator

Domain Store

Web Service Broker

new

(16)

New Patterns Facts

Patterns represent abstractions emerging from

using existing patterns in complex

applications and flesh out pattern language

(Context Object, Application Controller,

Business Object, etc.).

New patterns rely on POJO stereotype

New patterns identify a “web container only”

scenario

Domain Store addresses Transparent

Persistence (JDO and the like)

(17)

Presentation Tier Patterns

Intercepting Filter

Front Controller

Context Object

Application Controller

View Helper

Composite View

Service To Worker

Dispatcher View

(18)

Context Object

Problem:

– You want to avoid using protocol-specific system

information outside of its relevant context

Forces:

– You have components and services that need access to

system information

– You want to decouple application components and

services from the protocol specifics of system information

You want to expose only the relevant APIs within a

(19)

Context Object

Solution:

– Use a Context Object to encapsulate state in a

protocol-independent way to be shared throughout your application

(20)

Context Object Strategies

● Request Context Strategies

– Request Context Map Strategy – Request Context POJO Strategy

– Request Context Validation Strategy

● Configuration Context Strategies

– JSTL Configuration Strategy

● Security Context Strategies

● General Context Object Strategies

– Context Object Factory Strategy

(21)

Application Controller

Problem:

– You want to centralize and modularize action

and view management

Forces:

– You want to reuse action-management and

view-management code

– You want to improve code modularity and

maintainability

(22)

Application Controller

Solution:

– Use an Application Controller to centralize

retrieval and invocation of request-processing components, such as commands and views.

(23)

Application Controller:

(24)

Business Tier Patterns

● Business Delegate ● Service Locator

● Session Facade ● Business Object

● Application Service ● Composite Entity

● Transfer Object

● Transfer Object Assembler ● Value List Handler

(25)

Business Object

Problem:

– You have a conceptual domain model with

business logic and relationships

Forces:

– You have a conceptual model containing

structured, interrelated composite objects, complex business logic, validation, rules

– You want to centralize business logic and state

in an application

– You want to increase reusability of business

(26)

Business Object

Solution:

– Use Business Objects to separate business data

(27)

Application Service

Problem:

– You want to centralize business logic across

several business-tier components and services

Forces:

– You want to minimize business logic in service

facades

– You have business logic acting on multiple

Business Objects or services

– You want to encapsulate use case-specific logic

(28)

Application Service

Solution:

– Use an Application Service to centralize and

aggregate behavior to provide a uniform service layer

(29)

Integration Tier Patterns

Data Access Object

Service Activator

Domain Store

(30)

Domain Store

Problem:

– You want to separate persistence from your

object model

Forces:

– You want to avoid putting persistence

details in your Business Objects

– You do not want to use entity beans

– Your application might be running in a web

container

– Your object model uses inheritance and

(31)

Domain Store

Solution:

Use Domain Store to separate persistence from the

(32)

Web Service Broker

Problem:

– You want to provide access to one or more

services using XML and web protocols

Forces:

– You want to reuse and expose existing services

to clients

– You want to monitor and potentially limit the

usage of exposed services

– Your services must be exposed using open

(33)

Web Service Broker

Solution:

– Use a Web Service Broker to expose and broker

one or more services using XML and web protocols

(34)

Web Service Broker: Strategies

Custom XML Messaging Strategy

Java Binding Strategy

(35)

Agenda

● Patterns

● Core J2EE Pattern Catalog Background ● J2EE Progressive Refactoring Scenarios ● Pattern Frameworks

● Micro Architecture

– Web Worker Micro Architecture Example – Messaging Micro Architecture Example

(36)

J2EE Refactoring

14 Refactorings in the book

Presentation Tier:

– Hide Presentation Tier specifics from Business

Tier

– Introduce Synchronizer Token

Business Tier:

– Wrap Entities with Session – Merge Session Beans

(37)

Hide Presentation Tier specifics...

Presentation

Component ComponentBusiness

HttpServletRequest HttpServletRequest

Presentation

Tier BusinessTier Presentation

Component ComponentBusiness

HttpServletRequest HttpServletRequest

Presentation

Tier BusinessTier

Presentation

Component ComponentBusiness

HttpServletRequest UserInfo

Presentation

Tier BusinessTier Presentation

Component ComponentBusiness

HttpServletRequest UserInfo

Presentation

(38)

Introduce Synchronizer Token

Duplicate Allowed Controller Presentation Tier JSP Client Request Duplicate 2 1 2 1 Controller Presentation Tier JSP Client Request Duplicate 2 1 2 1 2 1 Controller Presentation Tier JSP Client Request Duplicate 2 1 2 1 Duplicate Disallowed No Access TOKEN TOKEN

(39)

Wrap Entities With Session

Entity Bean A Entity Bean B Entity Bean C Client Busine ss Logic Transaction Logic Client Busine ss Logic Session Facade Entity Bean A Entity Bean B Entity Bean C Transaction Logic: Bean Managed or Container Managed Business Tier Business

Tier BusinessTier

Client or Presentation Tier Client or Presentation Tier Client or Presentation Tier Client or Presentation Tier

(40)

Merge Session Beans

Business Tier Business Tier Client or Presentation Tier Client or Presentation Tier Client or Presentation Tier Client or Presentation Tier Business Tier Business Tier Client Interaction #1 Client Interaction #2 Client Interaction #3 Client Interaction #1 Client Interaction #2 Client Interaction #3 Session Session Session Entity Entity Enti ty Facade Facade Enti ty Enti ty Enti ty

(41)

Progressive Refactoring Scenarios

Direct Access

Introduce DAO

Introduce Application Service

Introduce Service Facade

(42)

Direct Access

Database

Command Helper

(43)

Introduce DAO

Database Command

Helper

(44)

Introduce Application Service

POJO Architecture

Database Command

Helper

DAO Application

(45)

Introduce Application Service

EJB Architecture

Command

Business

Delegate SessionFacade Helper

Application Service

(46)

Design Note: Service Facades

Remote and non-Remote business tier

<<RemoteSession>> RemoteFacade <<LocalSession>>

LocalFacade <<POJO>>

POJOFacade <<SessionEJB>>SessionFacade ServiceFacade

(47)

Introduce Service Facade

Non-Remote Business Tier

Service Facade >> Local Facade >>

Local Session Bean | POJO Command

Service Facade Helper

(48)

Introduce Service Facade

Remote Business Tier

Physical Boundary

Service Facade >> Remote Facade >>

Remote Session Bean Command Business Delegate Service Facade Helper DAO

(49)

Introduce Business Objects

Command

Business

Delegate SessionFacade

Business Object

Domain Store Helper

Application Service

(50)
(51)

Agenda

● Patterns

● Core J2EE Pattern Catalog Background ● J2EE Progressive Refactoring Scenarios ● Pattern Frameworks

● Micro Architecture

– Web Worker Micro Architecture Example – Messaging Micro Architecture Example

(52)

Pattern Framework

Set of cooperating patterns

Targeting macro problem

(53)

Pattern Realization

(54)

Agenda

● Patterns

● Core J2EE Pattern Catalog Background ● J2EE Progressive Refactoring Scenarios ● Pattern Frameworks

● Micro Architecture

– Web Worker Micro Architecture Example – Messaging Micro Architecture Example

(55)

Micro Architectures

● Micro-architectures are building blocks for designing

applications

● They represent a higher level of abstraction than the

individual patterns described in the catalog, and are expressed by a combination of patterns to solve a problem

● Micro-architecture is a prescriptive design leveraging

patterns to solve a larger problem, such as designing a subsystem

● Micro-Architectures:

▬ WebWorker Micro Architecture ▬ Messaging Micro Architecture

(56)
(57)

Web Worker Micro Architecture

● Problem:

– How do you integrate a J2EE application and a workflow

system and have the workflow system direct users to the appropriate web page

User 1 User 2 User 3

J2EE

Use Case 1 Page Logic

Use Case 2 Page Logic

Use Case 3 Page Logic

(58)
(59)

Hire Employee Collaboration

with Adapters

(60)

Action Adapter Class Diagram

Application Controller

Service Activator

Business Delegate

(61)

Work Adapter Class Diagram

(62)

Messaging Micro Architecture

Messaging >> Async, Web Services

Problem:

– How do you provide async, doc-based web

services in J2EE

(63)

Async WS Orchestration

With J2EE

Invoke Async Reply (sometime later) Business Process Orchestration (BPEL) J2EE WebService J2EE WebService J2EE WebService

(64)
(65)

Shipping Example

(66)

Async Web Service Orchestration

Shipping Company contracts Transporters

to ship products

Client Web App Orchestration

Server

Transport 1

Transport 2

Transport 3 Micro Architecture

Micro Architecture Bid Request

(67)

Micro Architecture composed of Patterns

Context Object Intercepting

Filter Web Service Broker Application

Controller

Transporter Message Context

Message Handler

Service Endpoint, Broker/Mediator, Validation Routing Service Activator Orchestration Server Application Service Service

(68)
(69)
(70)

Get Bids Interaction – Part 1

Transporter Web Service

(71)
(72)
(73)

Create Bid Interaction – Part 1

(74)

Create Bid Interaction – Part 2

(75)
(76)

ACE: Design To Deploy Service

Rapid intuitive design of enterprise

applications

Focus on design rather than coding

Builds upon best practices, patterns

and frameworks

Fewer resources, faster development

(77)

DASL: Specification Language

ACE uses a high level domain

modeling language called DASL

DASL is used to specify:

– Business Objects, relationships – Core reusable business logic – User interaction

(78)
(79)

Summary

Patterns are great! Use them effectively to improve

software quality

Build New Architecture

Analyse / understand existing Architecture

Refactor

Avoid re-inventing the wheel

Promote design re-use

Increase developer productivity, communication

Micro Architectures leverage patterns

(80)

Stay Connected:

Check out CJP:

– http://www.corej2eepatterns.com

Subscribe:

http://archives.java.sun/j2eepatterns-interest.html

Write to us:

[email protected]

(81)

[email protected]

January 2004

References

Related documents

Advanced Auto Beat Loop - The CDJ-900 generates a four-beat loop at a touch of a button creating acustomized sound to provide more time for DJs to.. blend in

In order for UnitedHealthcare Community Plan to monitor the quality of care and utilization of services by our members, all UnitedHealthcare Community Plan providers are required

The combination of process-specific motion simulation with explode, render and animation capabilities in Solid Edge allows you to promote your designs internally, helps you win

Please rank all the policies listed below based on your perception of how they might stimulate the adoption of CNG as an automotive fuel in Nigeria2. Terminated Prioritisation

tailed look at urban schools and school dis- tricts, highlighting some of the important ways in which urban districts differ from both wealthier suburban districts and

To do this, the server returns:.. ) This is an NSEC5PROOF RR for c.example.com. It’s RDATA is the NSEC5 proof corresponding to c.example.com. This is a signed NSEC5

Simulation models classified in the first two classes are used in our research on sport science simulations as well as in software components of the FootballAvatar project.. In the

B) Wish va seguido de pasado simple (aunque normalmente se refiere al presente o al futuro).. Ex: I wish they were