Design Patterns Composite Entity Pattern - Design Patterns

What is Design Patterns Composite Entity Pattern?

Composite Entity pattern is use in EJB persistence mechanism. A Composite entity is an EJB entity bean which represents a diagram of objects.

When a composite entity is updated, inside dependent objects beans get updated automatically as being manage by EJB entity bean. Following are the participants in Composite Entity Bean.

  • Composite Entity - It is primary entity bean. It can be coarse grained or can contain a coarse grained object to be used for persistence purpose.
  • Coarse-Grained Object - This object contains dependent objects. It has its own life cycle and also manages life cycle of dependent objects.
  • Dependent Object - Dependent object is an object which depends on coarse grained object for its persistence lifecycle.
  • Strategies - Strategies represents how to implement a Composite Entity.

Implementation

We are going to make Composite Entity object acting as Composite Entity. CoarseGrainedObject will be a class which contains dependent objects. CompositeEntityPatternDemo, our demo class will use customer class to show use of Composite Entity pattern.

compositeentity_pattern_uml_diagram

Step 1

Construct dependent relative Objects.

DependentObject1.java

DependentObject2.java

Step 2

Create Coarse Grained Object.

CoarseGrainedObject.java

Step 3

Create Composite Entity.

CompositeEntity.java

Step 4

Create Client class to use Composite Entity.

Client.java

Step 5

Make use of the Client to demonstrate Composite Entity design pattern usage.

CompositeEntityPatternDemo.java

Step 6

Verify the output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Design Patterns Topics