24
OgilviePartners.com 1 Enterprise Object Persistence ~ with ~ Java Data Objects Robin M. Roos Principal Consultant Ogilvie Partners Ltd [email protected]

Data Objects (JDO) (Robin Roos, Ogilvie Partners)

  • Upload
    aamir97

  • View
    502

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 1

Enterprise Object Persistence ~ with ~

Java Data Objects

Robin M. Roos

Principal Consultant

Ogilvie Partners Ltd

[email protected]

Page 2: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 2

Topics

• What is JDO ?

• Where does it fit in Enterprise Architecture ?

• What’s new with JDO 2.0 ?

• Who is using JDO with WebSphere ?

• Where can I go for more information ?

Page 3: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 3

Topics (reprise)

• Why Objects ?

• Why Persistence ?• Why Relational ?

• Why Determine Architecture First ?

• To be or not to be a Component?

• What is the Present ?• What is the Future ?

Page 4: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 4

Why Objects ?

• Object Oriented Programming 101– Objects have State & Behaviour

• Java 101 (OO concepts)– Inheritance, Interfaces, Polymorphism,

Encapsulation

• Domain Driven Design– Use Objects to Model the Business Domain

• Collaboration Patterns– Distribute business logic amongst collaborators

Page 5: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 5

Why Persistence ?

• If you model the domain with object graphs, how can you– store the object graphs– retrieve individual objects– navigate object references– handle object-relational impedance mismatch

• Whilst maintaining– appropriate visibility– polymorphism– architecture neutrality

Page 6: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 6

Why Relational ?

• Datastore choice is core to Architecture– SQL 92 ?– Oracle 9i ?

– A particular ODBMS ?– An XML Repository ?– All of the above (and others besides) ?

Page 7: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 7

Why Determine Architecture ?

• What in the world is this chap on ?

• Choice of underlying persistence infrastructure can constrain further architectural choices

Page 8: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 8

To be or not to be a Component ?

• An object (or set thereof) which encapsulates logic and/or data and executes within a container on which it is reliant for service provision [J2EE]

• An object with identity, and the reachable graph of dependent objects, together constituting a recognized business concept or abstraction.

Page 9: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 9

What is the Present ?

• JDO 1.0 (March 2001)– Transparent– Datastore agnostic– Polymorphic

– Transactional (Pessimistic, Optimistic, CMT)

– Architecture Neutral

• JDO 1.0.1 (February 2003)– JDOOptimisticFailureException– PersistenceManagerFactory.close()

Page 10: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 10

Transparent & Testable

• J2EE– Clients interact through the container

• JDO– Clients interact with domain objects directly

Page 11: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 11

Bytecode Enhancement

Page 12: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 12

Client-ServerArchitecture

Page 13: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 13

WebArchitectureOgilviePartners.com

Page 14: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 14

EnterpriseArchitecture

OgilviePartners.com

Page 15: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 15

Entity Bean Delegate

ArchitectureOgilviePartners.com

Page 16: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 16

J2EE Compliance

• The JDO 1.0 specification mandates compliance with the J2EE 1.3 connector architecture and transaction manager.– Every JDO 1.0 compliant implementation

will work with every J2EE compliant application server.

– Required J2EE configuration info may be server-specific.

Page 17: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 17

J2EE Integration - EJB

• Enterprise Component:– Looks up PMF in JNDI when EJBContext is set– CMT & BMT with UserTransaction

• Gets and closes PM from PMF within UserTransaction

– BMT with JDO Transaction• Gets PM from PMF outside UserTransaction

• Commit Transaction before closing PM

Page 18: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 18

J2EE Integration - WEB

• Servlet Filter gets PMF at init time• Servlet Filter gets PM from PMF at request time

– Puts PM into request scope

– Begins transaction

• Web component uses PM from request scope• Servlet Filter commits transaction and closes PM

prior to returning response

Page 19: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 19

WebSphere & JDO

• EJ Gallo, the Californian Wine Maker

• Amkor Technologies

• Harbor Freight Tools

Page 20: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 20

What is the Future of . . . JDO ?

• JDO 2.0– Greatly improved JDOQL

• Aggregation, Projection

– Standardized Object-Relational Mapping– Standardized Fetch Groups

– Detached Operation– Miscellaneous

• Sequences, Long-lived Optimistic Transactions, Useful helper methods, Native Connection Exposure, etc.

Page 21: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 21

. . . Object Oriented Design ?

Page 22: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 22

. . . Enterprise Architecture ?

Page 23: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 23

Parting Thoughts

• JDO is not an end in itself. Instead it is an enabling technology. We can finally apply best-practice in Object Oriented Design without undue constraint, and we can fully exploit the best of the services J2EE has to offer when doing so is appropriate.

Page 24: Data Objects (JDO) (Robin Roos, Ogilvie Partners)

OgilviePartners.com 24

Ogilvie Partnerswww.OgilviePartners.com