Core J2EE
Pattern Catalog
Last
Updated:
January 29, 2006 8:54 PM
In Association with Amazon.com
Application Service
See Core J2EE Patterns,
2nd Edition for full description of this pattern and its strategies.
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 provide a coarser-grained service API over existing business-tier
components and services.
- You want to encapsulate use case-specific logic outside of individual
Business Objects.
Solution
Use an Application Service to centralize and aggregate behavior
to provide a uniform service layer.
Class Diagram
Sequence Diagram
Strategies
- Application Service Command Strategy
- GoF Strategy for Application Service Strategy
- Application Service Layer Strategy
Consequences
- Centralizes reusable business and workflow logic
- Improves reusability of business logic
- Avoids duplication of code
- Simplifies facade implementations
- Introduces additional layer in the business tier
Related Patterns
- Session Façade
Application Services provide the background infrastructure for Session
Façades, which become simpler to implement and contain less code
because they can delegate the business processing to Application Services.
- Business Object
In applications that use Business Objects, Application Services encapsulate
cross-Business Objects logic and interact with several Business Objects.
- Data Access Object
In some applications, an Application Service can use a Data Access Object
directly to access data in a data store.
- Service Layer [PEAA]
Application Service is similar to Service Layer pattern in that both
aim to promote a service layer in your application. Service Layer explains
how a set of services can be used to create a boundary layer for your
application.
- Transaction Script [PEAA]
When an Application Service is used without Business Objects (374),
it becomes a service object where you can implement your procedural
logic. Transaction Script describes the use of procedural approach to
implementing business logic in your application.
Excerpted from Core J2EE
Patterns, 2nd Edition. See the book for full description of the pattern
including class diagrams, sequence diagrams and sample code.