S7 PSM EJB 02 19 - Universitetet i Oslo€¦ · OptimalJ training section 9 - PSM: DBMS Model 5 9...

17
OptimalJ training section 9 - PSM: DBMS Model 1 1 PSM—EJB Model OptimalJ Foundation 2 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

Transcript of S7 PSM EJB 02 19 - Universitetet i Oslo€¦ · OptimalJ training section 9 - PSM: DBMS Model 5 9...

OptimalJ training section 9 - PSM: DBMS Model 1

1

PSM—EJB Model

OptimalJ Foundation

2

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

OptimalJ training section 9 - PSM: DBMS Model 2

3

What is the EJB Model?

4

EJB Model as a PSM Model

OptimalJ training section 9 - PSM: DBMS Model 3

5

Mapping the EJB Model

6

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

OptimalJ training section 9 - PSM: DBMS Model 4

7

EJB Model and Code Generation

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 5

9

Entity Component• Purpose

• Corresponds a domain class • Object wrapper around data

• Model elements • Business method• Finder method• Select method• EJB entity component reference

10

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

OptimalJ training section 9 - PSM: DBMS Model 6

11

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

12

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

OptimalJ training section 9 - PSM: DBMS Model 7

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

14

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

OptimalJ training section 9 - PSM: DBMS Model 8

15

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

16

• Definition• Client views to the EJB components• Remote: location transparency!• Local: performance!• Local and Remote: flexibility!

• Model elements• Local• Remote

Local and Remote Interfaces

OptimalJ training section 9 - PSM: DBMS Model 9

17

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

18

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

OptimalJ training section 9 - PSM: DBMS Model 10

19

• 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

Finder Methods

20

• 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

Select Methods

OptimalJ training section 9 - PSM: DBMS Model 11

21

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

22

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.

OptimalJ training section 9 - PSM: DBMS Model 12

23

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

24

Message Production• Delivered by all EJB components

• Defined used JMS destinations and factories

OptimalJ training section 9 - PSM: DBMS Model 13

25

Message Consumption• Delivered via a model wizard• Durable subscribers

• Guaranteed message delivery• Reliability

26

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

• Re-enable any disabled modules

Switching EJB 2.0 and 1.1

OptimalJ training section 9 - PSM: DBMS Model 14

27

Roadmap• EJB model overview• EJB model elements—details• Implementation features

• Simple scenario• Domain model• EJB model• Code model

28

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

OptimalJ training section 9 - PSM: DBMS Model 15

29

CRM—Domain Model• CRM main elements

• Customer• Service Agreement• Call• Address (structure)• CustomerMSvc

30

CRM—EJB Model• Entity and session components• Data schemas and key classes

OptimalJ training section 9 - PSM: DBMS Model 16

31

CRM—Code Model

32

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

OptimalJ training section 9 - PSM: DBMS Model 17

33

• 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

Exercises