UML Package Diagrams Examples
Here we provide some examples of UML package diagrams:
- Multi-Layered Application Model
- Multi-Layered Web Architecture
- Java Servlet 2.5 API
- Value Object Package Template
- Spring and Hibernate DAO Classes
Multi-Layered Application Model
An example of model diagram representing a model of layered application, based on Microsoft Application Achitecture Guide, 2nd Ed.
According to the Guide, layers are concerned with the logical division of components and functionality, and do not take into account the physical location of components, whereas tiers describe the physical distribution of the functionality and components on separate servers, computers, networks, or remote locations. Layers can be located on different tiers, or they may reside on the same tier.
Application model shows several layers - presentation layer, services layer, business, data, and cross-cutting layers. All layers are represented as UML models.
Users and external systems are also represented as models, and communicate with presentation and services layers, correspondingly. Diagram also shows data sources such as relational databases and web service agents that provide access to data and external or remote services that are consumed by the application.
Cross-cutting layer contains common functionality that spans layers and tiers. This functionality typically supports authentication, authorization, caching, communication, exception management, logging and instrumentation, and validation. Such functionality is generally described as crosscutting concerns.
Layered application model diagram
Multi-Layered Web Architecture
An example of package diagram representing some multi-layered web architecture. Dependencies between packages are created in such a way as to avoid circular dependencies between packages. Higher level packages depend on lower level packages. Packages belonging to the same level could depend on each other. Data transfer objects and common exceptions are used by packages at all higher levels.
Package diagram of some multi-layered web architecture
Java Servlet 2.5 API
An example of UML 2.4 package diagram representing most important interfaces and classes of Java™ Servlet 2.5 API.
Application Programming Interface (API) is a common programming term which is usually defined as a set of interfaces, classes and some rules specifying how some client of the API could (re)use the services and/or resources provided by the software component implementing that API.
Note, UML 2.4 does not provide any notation or stereotypes to support modeling of APIs. On the diagram below Servlet API is notated as the package stereotyped as «api». Note, «api» is not a standard UML stereotype.
A servlet is a Java™ technology-based Web component, managed by a web container, that generates dynamic content. The servlet container is a part of a Web server or application server that provides the network services over which requests and responses are sent, decodes MIME-based requests, and formats MIME-based responses. A servlet container also contains and manages servlets through their lifecycle. The Java Servlet API v.2.5 is described in Java™ Servlet Specification Version 2.5 and is a required (part of) API of the Java Platform, Enterprise Edition, v.5.
Java Servlet API consists of two packages: javax.servlet and javax.servlet.http. The javax.servlet package contains a number of interfaces and classes (both abstract and concrete) that describe and define the contracts between a servlet class and the runtime environment provided for an instance of such a class by a conforming servlet container. The javax.servlet.http is package specialized for the servlet class running under the HTTP protocol and for corresponding runtime environment.
UML package diagram representing major interfaces and classes of Java Servlet 2.5 API.
Value Object Package Template
A UML package template example for (Data) Transfer Object (DTO) also known as Value Object (VO) J2EE or .Net design pattern. Value Object is used to bundle together some related data (used to be called structure in older programming languages), e.g. related to some customer, purchase order, item, etc. A single method call is used to get or to send the whole Value Object to reduce the number of remote calls for each specific data field.
Package template example for the Value Object (also Data Transfer Object) design pattern.
The template has unconstrained class parameter ID and two string expression parameters. Binding replaces formal class ID parameter with Integer class while string expression parameters are used to build names of actual interfaces and classes. Customer Data Access is bound package.
The result of the binding is shown below. Customer Data Access package contains Customer DAO (Data Access Object) and Customer VO (Value Object) classes implementing corresponding interfaces.
Customer Data Access is a template bound package.
Spring and Hibernate Classes
An example of UML package diagram representing some Spring and Hibernate data access classes.
An example of package diagram for Spring and Hibernate data access classes
