advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the sample migration code.
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 3/5 | Rate this item | 1 user has rated this item.
Email this articleEmail this article
 
Moving On: Migrating from EJB 2.1 to EJB 3.0
Find out how much you can simplify your EJB code by working through these examples, which show the process for migrating EJBs to version 3.0. 

advertisement
efore showing you how to migrate your EJBs from EJB 2.1 to EJB 3.0, it's worth exploring what you gain by making the move. Basically, EJB 3.0 reduces the number of classes, interfaces, and deployment descriptors needed to create EJBs. The EJB 3.0 specification simplifies EJB development by letting you replace abstract bean classes with Plain Old Java Objects (POJOs) and replace Component and Home interfaces with Plain Old Java Interfaces (POJIs). The latter are optional—you don't have to include them at all.


  • The deployment descriptor ejb-jar.xml, which specifies the EJB name, the bean class name, the interfaces, the finder methods, the container-managed relationships (CMR), and any vendor-specific deployment descriptors are no longer required; they're replaced by metadata annotations in the bean classes. That's why you need JDK 5.0 to develop EJB 3.0 EJBs—because they use annotations, which weren't available until JDK 5.0.
  • EJB 3.0 replaces the create() and finder methods of EJB 2.1 with the javax.persistence.EntityManager API. Client applications for EJB 2.1 obtain a reference to entity and session bean objects using the JNDI name, while EJB 3.0 clients obtain them using the @Resource, @Inject, and @EJB annotations.
  • In EJB 2.1, you developed entity and session beans using the javax.ejb package classes and interfaces, where a session bean implements the SessionBean interface and an entity bean implements the EntityBean interface. In contrast, EJB 3.0 session and entity bean classes are POJOs, and do not implement the SessionBean and EntityBean interfaces.
  • An EJB 2.1 session bean class specifies one or more ejbCreate methods, callback methods, the setSessionContext method, and business methods. Similarly, an EJB 2.1 entity EJB specifies the ejbCreate(), ejbPostCreate(), callback, Container-managed persistence (CMP), getter and setter CMR, and getter, setter, and business methods. An EJB 3.0 session bean class specifies only the business methods. Similarly, an EJB 3.0 entity bean specifies business methods, getter/setter methods for the different bean properties, and getter/setter methods for bean relationships.
  • The EJB 2.1 home interface extends the javax.ejb.EJBHome interface, and a local home interface extends the javax.ejb.EJBLocalHome interface. The EJB 2.1 remote interface extends the javax.ejb.EJBObject interface, and a local interface extends the javax.ejb.EJBLocalObject interface. EJB 3.0 doesn't specify the component and home interfaces—they're replaced with POJI business interfaces. If a session bean class doesn't specify a business interface, the EJB server generates a POJI business interface from the session bean class.
With these changed features in mind, the rest of this article concentrates on showing you the details you need to know to migrate an example session bean and an example entity bean from EJB 2.1 to EJB 3.0.

  Next Page: Migrating Session Beans


Page 1: IntroductionPage 3: Migrating Entity Beans
Page 2: Migrating Session BeansPage 4: Migrating EJB Entity Bean Clients
Untitled
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Intel PDF: Virtualization Delivers Data Center Efficiency
Intel eBook: Managing the Evolving Data Center
Microsoft Article: BitLocker Brings Encryption to Windows Server 2008
Symantec eBook: The Guide to E-Mail Archiving and Management
Microsoft Article: RODCs Transform Branch Office Security
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
Avaya Article: Advancing the State of the Art in Customer Service
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Seminar: Efficiencies in Hardware/Software Virtualization
HP Webcast: Disaster Recovery Planning
Go Parallel Video: Performance and Threading Tools for Game Developers
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
IBM TCO eKIT: Your IT Budget is Under Attack, Get in Control
IBM Energy Efficiency eKIT: Learn How to Reduce Costs
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Microsoft Article: Silverlight Streaming--Free Video Hosting for All
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
HP Demo: StorageWorks EVA4400
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES