Implement mechanisms for efficient inter-component calls

This page discusses - Implement mechanisms for efficient inter-component calls

Ads

Tutorials   
Chapter 2. Design, build and test web components Chapter 2. Design, build and test web components Test and debug enterprise components Describe the effects of a server failure on the application Interact with connection pools to obtain and release connections Part II. Appendixes WSAD 5.0 Practicing for IBM Test 000-287 Preface Identify misbehaving application components Implement mechanisms which support loose coupling between clients and components Manipulate transactional behavior of EJBs using deployment descriptors Use JTA to control transaction demarcation Design, develop and test JSPs Configure JMS connection factories and destinations Implement Java clients calling Web Services Chapter 3. Develop clients that access the enterprise components IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide Implement mechanisms for efficient inter-component calls Chapter 7. Validate, tune and troubleshoot an application within an IBM WebSphere Application Server environment Manage end-user state and understand performance tradeoffs of using HTTP sessions Explain implications of resource management on application design and implementation Part I. Exam Objectives Access container and server services from enterprise components Chapter 1. Design, build and test reusable enterprise components Validate operational parameters of application server to support the enterprise application Design and develop entity EJBs Design and develop message-driven EJBs Chapter 5. EJB transactions Chapter 4. Demonstrate understanding of database connectivity and messaging within IBM WebShpere Application Server Design and develop custom tags Configure resource and security-role references Chapter 6. Assemble enterprise applications and deploy them in IBM WebSphere Application Server Deploy enterprise applications into servers WSAD 5.0 Practicing for IBM Test 000-287 Mind Map Appendix A. Additional materials
Ads

Implement mechanisms for efficient inter-component calls

Bean Interfaces and Implementation

According to the 2.0 specification, the implementation classes for entity beans that use CMP are now abstract classes.

Session beans and entity beans in 2.0 can have two types of interfaces: a remote interface and a local interface.

  • Local Interface

    The local interfaces for session and entity beans provide support for light weight access from enterprise beans that are local clients. That is, the bean uses a local interface if the bean wants to provide tight coupling with its clients with pass-by-reference semantics. The local interface is a standard Java interface that does not inherit from RMI.

  • Remote interface

    A bean that needs to have remote capabilities - the bean inherits from RMI and interacts with distributed clients - uses a remote interface. A bean can have both a local and a remote interface - that is, it can provide both a local and a remote client view.

Typically, however, a bean will be designed to provide only one or the other interface. Similarly, a bean can have a remote home interface and/or a local home interface.

In the 2.0 specification, a bean typically uses its remote interface to expose its methods across the network tier. A bean uses the local interface to expose its methods to other beans that reside within the same container. It is thus possible to directly access a bean through its local interface without the overhead of a remote method call.

Local interfaces provide the foundation for container managed relationships among entity beans and session beans. The bean uses the local interface to maintain its references to other beans. For example, entity beans use local interfaces to maintain relationships to other entity beans. They also allow session and entity beans to be tightly coupled with their clients. Using local interfaces, beans can also expose their state and use pass-by-reference to pass their state between related bean instances.

Adding references to enterprise beans

You can add different types of references to an enterprise bean, including EJB references (local and remote), resource references, security role references, and resource environment references.

An EJB reference is a logical name used by a client (or another bean) to locate the home interface of an enterprise bean. It is a best practice to use an EJB reference for any enterprise bean that you need to reference. Using an EJB reference will allow you to safely write Java code to lookup the home interface of the target enterprise bean without the worry of the binding changing for the target enterprise bean. This is necessary if you need to install the same EJB module on the same server with different bindings.

In addition, for looking up local home interface, you are required to use an EJB local reference.

At deployment, the EJB reference is bound to the enterprise bean's home in the target operational environment. The container makes the application's EJB references available in a JNDI naming context. Resource environment reference elements contain declarations of an enterprise bean's reference to an administered object associated with a resource in the application client's environment. Resource environment references are available only for J2EE 1.3 application clients. For EJB 2.0, the created resource reference has WebSphere Application Server extensions for isolation policy and connection policy.

To add references to an enterprise bean:

  1. In the J2EE Hierarchy view, right-click the desired EJB module and select Open With > Deployment Descriptor Editor from the pop-up menu.

  2. On the References page of the editor select the enterprise bean that you want to add a reference to (the referencing bean) - TravelAgent, and click the Add button. The Add Reference wizard opens.

    References
  3. Select the type of reference that you want to create (EJB local reference), and click Next.

    Add Reference wizard
  4. Select the location of the enterprise bean that you want to reference (the referenced bean).

    Note: Local references can reference enterprise beans in the same EJB project or in the same application. Remote references can also reference enterprise beans in another application.

    When you select an enterprise bean in another EJB project within the same application or another application, the Java JAR dependencies are automatically set up. If you select an enterprise bean in another application and the preference to create EJB client projects is turned on, you will be prompted to create an EJB client project for the EJB project of the selected enterprise bean if one does not already exist. The EJB client project is added as a Java utility JAR to all applications that the source bean projects belongs to. A Java JAR dependency for the source EJB project is also added to the utility JAR file, which is the target EJB client project.

  5. Select the enterprise bean that you are referencing (Cabin), and update the Name field or accept the default (recommended).

    Name - ejb/Cabin

    Add EJB Local Reference wizard
  6. Click Next to review your selections and enter a description for the reference.

    Add EJB Local Reference wizard
  7. Click Finish.

The reference is added to the bean that you selected and is displayed on the References page of the EJB deployment descriptor editor.

Reference


<session id="TravelAgent">
	<ejb-name>TravelAgent</ejb-name>
	...
	<ejb-local-ref id="EJBLocalRef_1122033021884">
		<ejb-ref-name>ejb/Cabin</ejb-ref-name>
		<ejb-ref-type>Entity</ejb-ref-type>
		<local-home>com.titan.cabin.CabinLocalHome</local-home>
		<local>com.titan.cabin.CabinLocal</local>
		<ejb-link>Cabin</ejb-link>
	</ejb-local-ref>
</session>
					
					

Repeat the same steps and add a reference to (the referencing bean) - TravelAgent for Ship (referenced) bean:

Reference


<session id="TravelAgent">
	<ejb-name>TravelAgent</ejb-name>
	...
	<ejb-local-ref id="EJBLocalRef_1122300603538">
		<ejb-ref-name>ejb/Ship</ejb-ref-name>
		<ejb-ref-type>Entity</ejb-ref-type>
		<local-home>com.titan.ship.ShipLocalHome</local-home>
		<local>com.titan.ship.ShipLocal</local>
		<ejb-link>Ship</ejb-link>
	</ejb-local-ref>
</session>
					
					

Advertisements

Ads
Share on Google+Share on Google+

Implement mechanisms for efficient inter-component calls

Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Implement mechanisms for efficient inter-component calls  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads