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

Local Interfaces, Remote Interfaces, and the Client View

A local client is one that is located in the same Java Virtual Machine as its component and uses a local interface. A remote client uses the remote interface of the component. The two different types of clients have different privileges for accessing details of the object model.

A local interface may use other local interfaces as parameters and return values, and may also use the collection classes that represent multi-valued relationships as parameters and return values. A remote interface must not ever use a local interface or relationship collection as a parameter or a return value. The reason for this rule is easily understood: a remote client may not be using the same Java Virtual Machine, but these classes are dependent on a particular virtual machine for their correct execution.

The client view of an EJB component is defined by the methods in the EJB's home and remote interface. This view is independent of the EJB's implementation – and specifically, independent of the EJB's object model. From the point of view of a client, local interfaces and relationships are just an irrelevant implementation detail. All the client of an EJB cares about are the remote methods that it can invoke.

For instance, let's consider the example of an entity bean representing an order. This entity bean might have the following remote interface:

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

	public interface Order extends EJBObject {

		public Long getOrderId() throws RemoteException;
		public String getCustomerName() throws RemoteException;
		public String getStreetAddress() throws RemoteException;
		public String getCity() throws RemoteException;
		public String getState() throws RemoteException;
		public String getZip() throws RemoteException;
	}

The implementation class for this EJB (perhaps named OrderEJB) might have state variables representing the customer's street address, city, state, and zip code. On the other hand, it might have a one-to-one relationship with a local address EJB. It might have a regular Java object that gets serialized into a database column. It might even have a one-to-many relationship with local address EJBs, and use an algorithm to select an appropriate shipping address for an order based on the order's manufacturing facility. From the client's point of view, it doesn't matter. The same street, city, state, and zip code strings are returned through the public interface.

In fact, it is illegal to return a local component interface or a relationship collection class from a remote interface method in an entity. You could not simply write the above interface as follows (assuming Address is a local component interface):

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

	public interface Order extends EJBObject {

		public Long getOrderId() throws RemoteException;
		public Address getAddress() throws RemoteException;
	}

The local address remote interface cannot be the return value in a remote method invocation.

Transferring State to and from the Client

Even though it is illegal to return a local interface or a relationship collection to the client, it is still often necessary to transfer a view of the entity's state to the client, or to apply an update of the entity's state from the client. A common pattern is to use a Java class to represent the state or updates to be transferred. This class might be generic (a custom java.sql.ResultSet implementation) or specific to the state that needs to be transported (an AddressView or LineItemView class).

For instance, the interface for the order bean might be defined as follows:

	import java.rmi.RemoteException;
	import javax.ejb.EJBObject;
	import javax.ejb.CreateException;

	public interface Order extends EJBObject {

		public Long getOrderId() throws RemoteException;
		public LineItemView[] getLineItemViews() throws RemoteException;
		public void addLineItem(LineItemView liv)
			throws RemoteException, CreateException;
		public void updateLineItem(LineItemView liv) throws RemoteException;
		public void removeLineItem(long lineItemID) throws RemoteException;
	}

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