advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement



Title: Professional EJB
ISBN: 1861005083
US Price: $ 59.99
Canadian Price:
C$ 89.95
UK Price: £ 47.99
© Wrox Press Limited, US and UK.

Reviews : Java Books :
Professional EJB : The EJB 2.0 Entity Model

EJB 2.0 Changes to Bean-Managed Persistence

The changes and improvements to bean-managed persistence are not nearly as extensive as those for container-managed persistence. There are basically two:

  • A developer of an EJB entity using bean-managed persistence can take advantage of fine- grained entities using local interfaces, rather than dependent value objects, in implementing the object model. This will solve state data-aliasing problems, but not relationship data- aliasing problems.
  • A developer can use the new home interface business methods to implement business methods for operations that are not specific to a particular entity; for example, methods that apply to groups of entities or that do not need any entity instances to exist.

Rules for Using Home Interface Business Methods

Home business methods are the EJB equivalent of class (static) methods in general Java development. In other words, they are an appropriate place for functionality that applies to that class of object, rather than a particular object.

For each home business method declared in the home interface, there must be a corresponding method in the implementation class with "ejbHome" prepended to the method name. Because there is no entity identity associated with the instance when it is executing a home business method, the bean developer must not access functionality associated with a particular entity. This includes the accessor methods and the entity context.

A BMP Example Using Home Business Methods

Let's look at an example of how an entity bean with bean-managed persistence can take advantage of the new home interface methods. We'll use a simple entity that represents measurements in the database and uses bean-managed persistence. Once it has been recorded in the database, this bean is read-only and our only requirements are for reporting. We'll access the data we need in two ways: first, using a finder method and iterating through instances on the client; and second, by using a home business method.

This example comprises five files:
File Name File Description
Measurement.java The entity remote component interface.
MeasurementHome.java The entity remote home interface.
MeasurementEJB.java The entity implementation class.
ejb-jar.xml The deployment descriptor.
Client.java A simple file to test the application.

Remote Component Interface

A remote interface would often replace these fine-grained accessors with a view object. We have defined our component to be read-only once created; note that there are no setter accessors in this interface.

package measurements;

import java.util.Date;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;

public interface Measurement extends EJBObject {

public long getId() throws RemoteException;
public Date getEventTimestamp() throws RemoteException;
public String getEventName() throws RemoteException;
public double getEventMagnitude() throws RemoteException;
}

Remote Home Interface

Along with the typical finder and create methods, this interface defines a business method. This is new for EJB 2.0:

package measurements;

import java.util.Date;
import java.util.Collection;
import java.rmi.RemoteException;
import javax.ejb.EJBHome;
import javax.ejb.FinderException;
import javax.ejb.CreateException;

public interface MeasurementHome extends EJBHome {
  public Measurement create(long measurementId, Date timestamp,
		String eventName,
		double magnitude) throws CreateException,
		RemoteException;

public Measurement findByPrimaryKey(Long measurementId)
	throws FinderException, RemoteException;

The totalMagnitudeForRange() business method is declared here. Note that it doesn't make sense for this method to be in the component interface, because it may apply to more than one measurement:

	public double totalMagnitudeForRange(Date from,
		Date to) throws RemoteException;
	public Collection findInDate(Date from, Date to)
		throws RemoteException, FinderException;
}

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Intel Go Parallel Portal
 Internet.com eBook Library
 IBM Software Construction Toolbox
 Microsoft RIA Development Center
 Destination .NET
XML error: not well-formed (invalid token) at line 43
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Google Hopes Chrome Will Help, Not Hurt Firefox
Remember Figlets? They're Back With Zend
Microsoft Readies an App Store Competitor?
Google: Chrome Browser Will Make Money
Sam Ramji: Microsoft's Man in Open Source
Google to Shake Up Browsers With Own Launch
Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun
Oops! I Fixed the Linux Kernel
Jim Zemlin: The New Center of Linux Gravity

Code Around C#'s Using Statement to Release Unmanaged Resources
Writing Functional Code with RDFa
BitLocker Brings Encryption to Windows Server 2008
Network Know-How: Exploring Network Algorithms
Create a Durable and Reliable WCF Service with MSMQ 4.0
The Baker's Dozen: 13 Tips for SQL Server 2008 and SSRS 2008
Book Excerpt: Microsoft Expression Blend Unleashed
Develop a Mobile RSS Feed the Easy Way
State of the Semantic Web: Know Where to Look
A 3D Exploration of the HTML Canvas Element

Advertising Info  |   Member Services  |   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