YOUR FEEDBACK
Three RIA Platforms Compared: Adobe Flex, Google Web Toolkit, and OpenLaszlo
NN wrote: Yeah you are right GWT is poor man's Flex. After using GWT on two...
SOA World Conference
Virtualization Conference
$200 Savings Expire May 16, 2008... – Register Today!

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Integrate EJB Services
With WebSphere Process Server

Digg This!

IBM WebSphere Process Server is a runtime platform for business integration solutions developed using IBM WebSphere Integration Developer.

Many existing business functions for a company's IT infrastructure are written based on JavaTM 2 Enterprise Edition (J2EE) stateless Enterprise Java Beans (EJB). When you design and implement new business process integration applications, it is important that you have the ability to leverage and integrate these functions easily.Overview diagramThe scenario we use in this article is pretty straightforward. It consists of one Service Component Architecture (SCA) module that has a Java component, which uses the imported EJB service.

Software prerequisitesYou need to install:

  • WebSphere Integration Developer V6
  • WebSphere Process Server V6 test environment
This article assumes that you have some knowledge of J2EE and have used WebSphere Studio Application Developer or Rational Application Developer before. To learn more about these products, visit developerWorks.

Configuration
In this section, we develop a sample EJB application and an SCA module that utilizes the EJB service.

You can begin by creating the enterprise application, package, and EJB session.

  1. Create an enterprise application called Echo (Figure 1) with one EJB module, EchoEJB2. Create a package called com.ibm.issw.poc.invokeejb.
  1. Create a stateless EJB session called Bean Echo (Figure 2)
  2. Create a simple method called echoSimple, and promote it the remote interface:

    public String echoSimple(String name){
           System.out.println("inside echoSimple");
           return "Hello, " + name;
        }

  3. Open the ejb deployment descriptor, and notice the default JNDI name (Figure 3) for the EJB:

    ejb/com/ibm/issw/poc/invokeejb/EchoHome

  4. Create an EJB client (Figure 4) project and jar that will be used later in the SCA module.
  5. Right-click and select EchoEJB => EJB Client Jar => Create EJB Client Project and enter EchoEJBClient in the name field.
  6. Run and test the EJB application (see Figure 5).
Now, that we've created the EJB, let's integrate it.

Create an EJB component
To integrate the EJB into the WebSphere Process Server SCA component:

  1. Create a module called InvokeEcho.
  2. From the Dependencies editor (Figure 6), select EchoEJBClient as the dependent Java project and click Add to add EchoEJBCLient as the dependent Java project.

    It is important to add module dependency at this point. When we add the interface later, the wizard will be able to find the remote EJB interface.

  3. From the Assembly editor, open the module, InvokeEcho in Assembly editor, add an Import component (Figure 7) on the canvas. Change the name to EchoEJB.
  4. Add the interface for the import:
    1.  Click the Add Interface icon.
    2.  In the resulting window, select Show Java.
    3.  Enter echo in the Filter by interface field.
    4.  Select Echo from Matching interfaces . This interface is from project
    /EchoEJBClient/ejbModule (see Figure 8).
    5.  Click Ok and save the module diagram (Figure 9).
    6.  Generate the Session EJB Binding.
  1. Right-click the EchoEJB import and select Generate Binding => Stateless Session Bean Binding (Figure 10).
  2. Notice how the icon changed in the import (see Figure 11).
  3. Select the Properties view and the Binding tab. You can see that the JNDI name field is now populated (see Figure 12).
Create a Java Component
To create a Java Component:
  1. Drag and drop a Java Component onto the assembly canvas and change the name to InvokeEcho (see Figure 13).
  2. Create an interface (Figure 14) called InvokeEchoInterface with a one-way operation callEcho and one input parameter:
  3. Select the Java component and add an interface for it, InvokeEchoInterface.
  4. Wire the InvokeEcho and EchoEJB together (see Figure 15).

    Notice that a reference EchoPartner has been generated. We will use it in the Java Component implementation (see Figure 16).

  5. Select and right-click the Java Component and generate the default Java implementation. When the implementation opens, replace the callEcho method with the following code:

        try {

          System.out.println("in callEcho");
          // Create an instance of the ServiceManager
          ServiceManager serviceManager = new ServiceManager();

          Echo echo= (Echo)serviceManager.locateService("EchoPartner");

          String result = echo.echoSimple(name);
          System.out.println("called imported EJB, and response is " + result);

        } catch (Exception e) {
          e.printStackTrace();
        }

  6. Running and testing the scenarioTo test the scenario:
    1.  Right-click InvokeEcho and select Test Component (Figure 17).
    2.  In the test configuration, remove the emulator for EchoEJB, since we want to invoke the real EJB implementation.
    3.  Enter a value for the name field and click Continue.
    4.  Notice the expected result (Figure 18).
Notice the result from the System.out.

Congratulations, you've successfully imported and invoked the Echo EJB from the SCA component, InvokeEcho. In this scenario, the SCA module and the EJB service are running on the same server.

Conclusion
This article helped you implement a WebSphere Process Server solution that integrates EJB services. As you can see, using EJB services from an SCA component is easy to do. Reusing EJB-based services in this way creates tremendous opportunities for integration products, such as WebSphere Process Server..

(This article was first published on developerWorks WebSphere at http://www.ibm.com/developerWorks/websphere.) This article shows you how to use IBM WebSphere Process Server Version 6 and IBM WebSphere Integration Developer Version 6 to integrate existing J2EE applications without making changes to them.

About Peter Xu
Peter Xu is a Senior Consultant with IBM Software Services for WebSphere group. Consultants with Software Services for WebSphere help customers deploy IBM products into their organizations. Peter provides consulting services, education, and mentoring on J2EE technologies, and specifically WebSphere and WebSphere Studio products to Fortune 500 clients.

WEBSPHERE LATEST STORIES . . .
Microsoft To Keynote 4th International Virtualization Conference & Expo
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
Micro Focus Upgrades SOA Express for IBM CICS
Micro Focus announced the availability of SOA Express 8.0. The new version adds support for direct deployment into IBM's Customer Information Control System (CICS), enabling users to accelerate the deployment of Web services by reusing their existing CICS TS mainframe infrastructure in
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
Red Hat Named "Platinum Sponsor" of Virtualization Conference & Expo
Red Hat is a trusted open source provider. Red Hat offers enterprise customers a long-term plan for building infrastructures on the quality and innovation of open source. Combining open source operating system platform, Red Hat Enterprise Linux, together with applications, management
Migration from IBM Rational Application Developer to MyEclipse 6.5 Blue Edition
Genuitec announced the availability of the milestone release of MyEclipse 6.5 Blue Edition, a tailored, customizable tool suite for WebSphere developers. Notably, this initial release of MyEclipse 6.5 Blue Edition offers project migration support. Developers currently working with IBM
Virtualization - IBM Creates Cloud Box
IBM claims to have created new species of custom-built, industry-standard, Linux-based rack server for Web 2.0 and Cloud Computing companies with massive data centers and tens of thousands of servers, like online gaming, social networks, search and Internet firms. A relatively limited
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING WEBSPHERE NEWS
Cognos Taps Partner Community to Accelerate Industry Growth
Cognos, an IBM company, and the world leader in business intelligence and performance