EMTM 600 Software Development - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

EMTM 600 Software Development

Description:

BusObjs are POJOs and are persisted in joint and complex framework following ... persist multiple related business objects by using the same entity bean with ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 11
Provided by: cisU
Category:

less

Transcript and Presenter's Notes

Title: EMTM 600 Software Development


1
EMTM 600Software Development
  • Spring 2007
  • Lecture Notes 4

2
Assignments for next time
  • Recall the Pet Store application shown in class,
    the two user stories that you outlined in a
    previous assignment and the interaction that the
    servlet needs to have with a session façade
    domain object for these user stories, which you
    outlined in the last assignment. Outline
    informally a few business objects related to thse
    user cases and how you might persist them using
    entity beans or POJOs. 1.5 to 2 pages. Groups of
    3-4 students OK.
  • From chapter 7 of the textbook read the pattern
    Application Service (pp. 363-373). From chapter 8
    of the textbook read the patterns Service
    Activator (pp. 496-515) and Web Service Broker
    (pp. 557-579). (Warning the first two of these
    three patterns are not exactly about Web services
    but are related.) Two days before the next
    lecture email me TWO QUESTION about something you
    didnt understand. Each student.

3
Enterprise Applications (contd)
EJB Container
data source
presentation
data mapping
controller
domain
CMP Entity EJBs
Specific to App.Server Vendor
Session EJBs
Servlets
HTML
BMP Entity EJBs
JSP
Struts
JDBC
CMP Container-Managed Persistence BMP
Bean-Managed Persistence
4
Some good practices
  • When using Session Façade, provide both a remote
    and local interface. Sometimes the servlet runs
    on the same JVM and local interfaces are more
    efficient (EJB 2.0)
  • Entity EJBs are meant for persistence. Put the
    domain logic in session EJBs.
  • Do not separate session beans and entity beans on
    different hosts. (Therefore, your entity beans
    need only local interfaces.)
  • Do not use entity beans for read-only
    information. It adds unnecessary EJB container
    overhead.

5
Data Mapping Layer
  • Purpose separates domain from data sources.
  • Like the MVC pattern, Data Mapping is a
    super-pattern based on the need make the
    business object representation in the domain
    independent from the way they are stored.
  • Three reasons
  • - data sources may (will!) be shared with other
    apps
  • - data sources are relational while the domain
    model is OO (richer!)
  • - DB programming is tricky best left to
    specialists.

6
Persistence Solutions for Business Objects
  • All solutions are a form of Object-Relational
    Mapping (ORM).
  • Options
  • BusObj is POJO and handles persistence itself
    (Active Record pattern in Fowler).
  • BusObj is POJO but separate Data Access Object
    handles persistence (see Data Access Object, p.
    462 textbook).
  • BusObj is Entity Bean with Bean-Managed
    Persistence (BMP) (see Composite Entity, p. 391
    textbook).
  • BusObj is Entity Bean with Container-Managed
    Persistence (CMP) uses vendor-specific
    proprietary ORMs (which may or may not follow
    Domain Store p. 516 textbook).
  • BusObjs are POJOs and are persisted in joint and
    complex framework following Domain Store, p. 516
    textbook. This framework may be a JDO
    implementation.

7
Plain CMP
  • Easiest!
  • It is vendor-dependent, but all vendors of Java
    EE application servers implement this.
  • For example, WebSphere Application Server
    provides CMP that maps entity EJBs to a single
    relational table (one row per object) when the
    object attributes permit.
  • More complicated mappings are supported by the
    WebSphere Studio Application Developer (through
    wizards that allow the specification of various
    mappings).
  • But it may make scalability control very hard!

8
JDO
  • Java Data Objects (JDO) is an open specification
    (like Java EE) for tools that achieve
    object-relational mapping.
  • Commercial implementations
  • Kodo (BEA), intelliBO (Signsoft), Open Access
    (Vanatec) etc.
  • Open Source implementations
  • JPOX (jpox.org), JDOinstruments (SourceForge),
    etc.

9
More ORM Issues
  • Handling object identity
  • Dont want to create two copies of the same
    business object!
  • See Fowlers Identity Map pattern.
  • Idea have the mapper object keep a dictionary
    of objects that have been already loaded
    sometimes called a Registry.
  • Mapping non-relational features
  • Using UML for the Domain Model, we get features
    that are not in the relational model
    associations, inheritance.
  • Luckily, the DB people have already worried
    about mapping from Entity-Relationship Diagrams
    to relational schemas. Mapping from UML is
    similar. See Fowlers patterns Concrete Table
    Inheritance and Inheritance Mappers.

10
Coarse-grain, fine-grain Good practices
  • Keeping this difference in mind has an essential
    effect on performance and scalability!
  • Worry about transactional granularity
  • do not expose entity bean methods directly to
    controller code instead, wrap them with a
    session bean!
  • group multiple related user stories in the same
    session bean!
  • Worry about persistence granularity
  • persist multiple related business objects by
    using the same entity bean with multiple
    dependent objects! (see Composite Entity p. 391
    in textbook)
  • make one entity bean correspond to multiple
    related records in the relational database! (with
    CMP this may not always work as needed)
Write a Comment
User Comments (0)
About PowerShow.com