EJB 2

From sheep
Revision as of 21:28, 14 September 2021 by Martin (talk | contribs) (Created page with "= EJB 2 persistence = == CMP == Application implements the storage, update and query code SQL Frees developer from details of model changes == BMP == Developer creates inser...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

EJB 2 persistence

CMP

Application implements the storage, update and query code SQL Frees developer from details of model changes

BMP

Developer creates insert, read, update code. Recommendation was use BMP with DAO as tools mature If developer can tune SQL and produce more efficient code

EJB 2 Interfaces

Ref: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/index.html

Entity Bean

  • FooBean extends javax.ejb.remote
    • implementation
  • FooBeanRemote extends javax.ejb.EJBObject
    • business methods - interface - remote component interface
  • FooBeanRemoteHome extends javax.ejb.EJBHome
    • get handle - remote home interface
  • FooBeanLocal extends javax.ejb.EJBLocalObject
    • business methods - interface - local component interface
  • FooBeanLocalHome extends javax.ejb.EJBLocalHome
    • get handle - local home interface

javax.ejb.EJBHome

  • not for session beans
    • create(id) - CMP
    • remove()
    • findByPrimaryKey(id) - CMP

javax.ejb.EJBObject

  • Remote interface
  • Business methods
  • Acts as a proxy

Bean

  • Implementation details
  • one of Session or Entity

javax.ejb.SessionBean

  • Stateful
  • Stateless
  • ejbActivate()
  • ejbPassivate()
  • ejbRemove()
  • setSessionContext(ctx)

javax.ejb.EntityBean

  • CMP + BMP
  • ejbActivate()
  • ejbLoad()
  • ejbPassivate()
  • ejbRemove()
  • ejbStore()
  • setEntityContext(ctx)
  • unsetEntityContext()