What is the EJB Model?

advertisement

OptimalJ Foundation

PSM—EJB Model

1

Roadmap

• EJB model overview

• What is the EJB model?

• EJB model as a PSM model

• Mapping the EJB model

• Model elements and code generation

• EJB model elements—details

• Implementation features

• Simple scenario

2

OptimalJ training section 9 - PSM: DBMS

Model 1

What is the EJB Model?

3

EJB Model as a PSM Model

4

OptimalJ training section 9 - PSM: DBMS

Model 2

Mapping the EJB Model

5

Main Model Elements

• EJB model elements

• EJB module

• EJB data schema

• EJB data class

• EJB data association

• EJB entity component

• EJB session component

• EJB message-driven component

• EJB key class

6

OptimalJ training section 9 - PSM: DBMS

Model 3

EJB Model and Code Generation

7

8

Roadmap

• EJB model overview

• EJB model elements—details

• EJB entity component

• EJB session component

• EJB message-driven component

• EJB struct type

• EJB enum type

• JMS Message

• Implementation features

• Simple scenario

OptimalJ training section 9 - PSM: DBMS

Model 4

Entity Component

• Purpose

• Corresponds a domain class

• Object wrapper around data

• Model elements

• Business method

• Finder method

• Select method

• EJB entity component reference

9

Session Component

• Purpose

• Corresponds a domain service

• Logical view of compound data

• Browsing data with the assistance of DAO

• Model elements

• Business method

• Data schemas

• State

10

OptimalJ training section 9 - PSM: DBMS

Model 5

Message-driven Component

• Purpose

• Serves as a JMS message consumer

• Modeled in the EJB model – no equivalent in the domain

• Model elements

• JMS message consumption

• JMS destination type and name

• Selectors

11

Other Elements in the Model

• EJB Structure

• Single unit of reusable data – set of attributes

• Maps to a Serializable Java class

• EJB Enumeration

• List of named unordered values

• JMS Message

• Meta information for message and transported data

• Associated with the EJB message-driven component

12

OptimalJ training section 9 - PSM: DBMS

Model 6

13

Roadmap

• EJB model overview

• EJB model elements—details

• Implementation features

• EJB implementation patterns

• EJB interfaces, relationships, and persistence

• Finder, home, and select methods

• Interaction with the EJB tier

• Messaging

• Simple scenario

EJB Implementation Patterns

• Two implementation patterns

• EJB 1.1

• EJB 2.0 (default)

• Local and Remote interfaces

• EJB persistence and relations

• Use of SQL or EJB QL

• Transactions

• Concurrency support

14

OptimalJ training section 9 - PSM: DBMS

Model 7

Interaction with the EJB Layer

• Problem description:

• Clients usually require more than one value from a bean

• Set and get methods increase the number of remote calls

• Solution:

• Business Facade to limit the network traffic

• Data object collects the data in case of read

• Business Facade creates an update object for fine-grain communication

• Update object is passed back to the EJB in case of update

15

Local and Remote Interfaces

• Definition

• Client views to the EJB components

• Remote: location transparency!

• Local: performance!

• Local and Remote: flexibility!

• Model elements

• Local

• Remote

16

OptimalJ training section 9 - PSM: DBMS

Model 8

EJB Persistence and Relations

• EJB 1.1 defaults—CMP and BMR

• EJB 2.0 defaults—CMP and CMR

• EJB relations

• One-to-many

• One-to-one

• Many-to-many

• Model elements

• EJB references

• Relationship management

• Referred component

17

EJB References

• Definition

• Element containing the relationship information

• Features

• Appear under EJB entity component

• Appear under EJB session component

• One reference for each navigable association

18

OptimalJ training section 9 - PSM: DBMS

Model 9

Finder Methods

• Definition

• Queries to return one or a collection of entity beans instances

• Exposed via Home/LocalHome

• Operate on CMP and CMR fields

• Utilize SQL or EJB QL

• Properties

• whereClause

• ejbQLQuery

19

Select Methods

• Definition

• Queries to return single or a collection of entity beans instances

• Queries to return CMP or CMR values

• NOT exposed via Home/LocalHome

• Operate on CMP and CMR fields

• Use EJB QL

• Properties

• ejbQLQuery

20

OptimalJ training section 9 - PSM: DBMS

Model 10

Home Methods

• Definition

• Perform operations related to the EJB component

• Not specific to a bean instance

• Defined in the Home/LocalHome interface

• Property

• isHomeBusinessMethod = True

21

Create and Remove Methods

• Definition

• Create method—a factory method that clients use to get a reference to an EJB object.

• Remove method—a method that a client use to release a reference to an EJB object and to free resources.

22

OptimalJ training section 9 - PSM: DBMS

Model 11

Messaging in OptimalJ

• Creation of JMS messages

• Message consumption and production

• Creation of message-driven components

• Registration of JMS destinations in JBoss

• Support for durable subscribers

• Message selectors

23

Message Production

• Delivered by all EJB components

• Defined used JMS destinations and factories

24

OptimalJ training section 9 - PSM: DBMS

Model 12

Message Consumption

• Delivered via a model wizard

• Durable subscribers

• Guaranteed message delivery

• Reliability

25

Switching EJB 2.0 and 1.1

• Add ipEjb11.jar (or ipEjb20.jar) from modules directory under OptimalJ installation

• Re-enable any disabled modules

26

OptimalJ training section 9 - PSM: DBMS

Model 13

27

Roadmap

• EJB model overview

• EJB model elements—details

• Implementation features

• Simple scenario

• Domain model

• EJB model

• Code model

Simple Scenario—CRM

• Customer Relationship Management (CRM) project

• A simplified real-life example

• Conduct basic customer relationship management tasks

• Monitoring range of queries on the customer database

• Viewing customer calls per customer

• Maintaining call data

• Demonstrate the functionality of the EJB model

28

OptimalJ training section 9 - PSM: DBMS

Model 14

CRM—Domain Model

• CRM main elements

• Customer

• Service Agreement

• Call

• Address (structure)

• CustomerMSvc

29

CRM—EJB Model

• Entity and session components

• Data schemas and key classes

30

OptimalJ training section 9 - PSM: DBMS

Model 15

CRM—Code Model

31

Summary

• The OptimalJ EJB model:

• Support for entity, session, and message-driven beans

• Code generated for enterprise beans conforms to EJB specifications

• Generation of deployment descriptors as prescribed by specifications

• Well-designed implementation approaches

• Extended messaging support

32

OptimalJ training section 9 - PSM: DBMS

Model 16

Exercises

• Explore the EJB model

• Become familiar with the main EJB model features

• Create a finder method

• Define finder methods based on CMP and CMR fields

• Create a home and select methods

• Model a home business method, which invokes a select method

• Optional—JMS application

• Model JMS message production and consumption

33

OptimalJ training section 9 - PSM: DBMS

Model 17

Download