Name

Service to Worker

Also Known As

Dispatcher View

Goal

Decouple navigation from the front controller (Figure A-9).

Classes in the Service to Worker pattern
Figure A-9. Classes in the Service to Worker pattern

Participants

Service (front controller)

Singleton object that intercepts all requests and performs common functions.

Dispatcher

Encapsulates worker and view selection based on request information and/or an internal navigation model.

Workers (actions)

Process user input and perform a specific update on the model.

Model

Stores application state data.

Views

Stateless pages that transform model data into a form appropriate for display to the user (Figure A-10).

Interactions in the Service to Worker pattern
Figure A-10. Interactions in the Service to Worker pattern

Interactions

The front controller intercepts all requests and performs common functions using decorators. The front controller passes request information to the dispatcher, which uses the request and an internal model to chooses and execute appropriate actions. The actions process user input, translating it into appropriate updates to the model. The model applies business rules and stores the data persistently. Based on the user input and results of the actions, the dispatcher chooses a view. The view transforms the updated model data into a form suitable for the user.

Notes

Actions are typically implementations of the GoF Command ...

Get J2EE Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.