Escolar Documentos
Profissional Documentos
Cultura Documentos
By Content Management, Web Services, and Development Tools Horizontal Technologies Market Development Engineering
Page 1 of 69
Table of Contents
1 Overview..................................................................................................... 3 1.1 Introduction.......................................................................................... 3 1.2 Scope of the Document........................................................................... 3 1.3 Document Organization.......................................................................... 3 2 IDEs Overview............................................................................................. 5 2.1 Sun Java Studio Enterprise 7................................................................... 5 2.2 IBM WebSphere Studio Application Developer 5.1.2.................................... 6 2.3 Differences between Sun JSE 7 and IBM WSAD 5.1.2.................................. 7 3 Migration Steps............................................................................................ 9 3.1 Steps for Migrating a Java Project............................................................ 9 3.2 Steps for Migrating a Web Application..................................................... 10 3.3 Steps for Migrating EJB Projects............................................................. 12 3.3.1 Steps for Migrating a Session EJB Project.......................................... 12 3.3.2 Steps for Migrating a CMP EJB Project............................................... 12 3.3.3 Steps for Migrating a MDB EJB Project.............................................. 13 3.4 Steps for Migrating a Web Services Project.............................................. 15 3.5 Steps for Migrating Team Support.......................................................... 16 4 Migration Examples..................................................................................... 18 4.1 Example for Migrating a Java Project....................................................... 18 4.2 Example for Migrating a Web Application................................................. 24 4.3 Examples for Migrating EJB Projects........................................................ 32 4.3.1 Example for Migrating a Session EJB Project...................................... 32 4.3.2 Example for Migrating a CMP EJB Project........................................... 38 4.3.3 Example for Migrating a MDB EJB Project.......................................... 48 4.4 Example for Migrating a Web Services Project.......................................... 55 4.5 Example for Migrating Team Support...................................................... 64 5 Appendix................................................................................................... 68
Page 2 of 69
1 Overview
1.1 Introduction
This white paper is aimed at providing guidelines for migrating projects from IBM WebSphere Studio Application Developer(WSAD) 5.1.2 IDE to Sun Java Studio Enterprise (JSE) 7 IDE. Guidelines have been provided for the following type of projects:
Migration of Java technology-based, Web, EJB beans (EJB), and Web Service applications from WSAD. Migration of Team Support from WSAD.
Suitable examples have been provided where necessary for better comprehension of the concepts discussed.
Since the aim of this paper is to describe the migration steps between the Integrated Development Environments (IDEs), it should not be used as a tutorial for IBM WSAD 5.1.2 or Sun JSE 7 IDEs. It is assumed that the user is familiar with basic tenets of projects in the IDEs. Migration of multi-layered J2EE applications is beyond the scope of this document. Concepts related to deployment of EJB/Web applications and configuration of associated resources on the Web or Application servers is beyond the scope of this document. Migration of applications across application servers has also not been covered in this document. For information on migration across application servers, please refer to the Appendix.
Page 3 of 69
Section # 2.3
Section Name Differences between Sun JSE 7 and IBM WSAD 5.1.2 Migration Steps
Purpose Explores the differences between Sun JSE 7 and IBM WSAD 5.1.2
3 4 5
Provides steps for migration from IBM WSAD 5.1.2 to Sun JSE 7
Migration Examples Provides examples for migration from IBM WSAD 5.1.2 to Sun JSE 7 Appendix Provides additional information related to the concepts discussed
Page 4 of 69
2 IDEs Overview
2.1 Sun Java Studio Enterprise 7
Sun Java Studio Enterprise (JSE) 7 is a platform for enterprise developers that provides integrated development environment for developing enterprise scale applications and services targeted for deployment on the Sun Java Enterprise System. Sun JSE 7 has been built on top of the NetBeans 3.6 platform. Highlights of Sun JSE 7 2004Q4 include:
Provides J2EE-platform based enterprise applications for creating, extending, and testing EJB components such as Message-Driven, Session, BMP Entity, and CMP Entity beans. Provides a platform for development of Web services and applications based on the Web Application Framework. Provides UML modeling support with live marker less round trip engineering. This includes the capability for synchronization of class model to code and vice versa. Provides the capability for enterprise application profiling along with support for method level code profiling, memory profiling and EJB container profiling. Also supports load testing of applications for multiple users. Provides refactoring capabilities for aiding in Java-based development. Provides collaborative development capabilities to improve team development capabilities, especially in a distributed team development model. Provides integrated support for Sun Java Enterprise System components such as Sun Java System Application server, Sun Java System Web server, Sun Java System Portal server, Sun Java System Directory server, Sun Java System Access Manager and Sun Java System Message Queue. Provides a platform for developing Portal applications. Provides support for developing desktop applications based on Java Swing and AWT. Provides support for XML files, JUnit testing framework, and Ant build scripts.
Sun JSE 7 provides templates for creating projects,modules, and files. It also provides different views for navigation. The main views include Filesystems, Projects and Runtime. It also provides tabs such as Web Application Framework, Versioning, Modeling, Properties, Collaboration, Enterprise Application Profiler, GUI Editing and Debugging. Sun JSE 7 provides the Filesystems tab for mounting or unmounting directories (the directory structure appears as on disk). The IDE also allows the developers to mount or unmount archive files and version control systems. The Projects tab displays the files that are associated with the project. The Runtime tab displays the runtime components such as integrated servers, databases, processes, UDDI Registry, HTTP server and VCS commands. The Web Application Framework displays the logical structure of the application built Page 5 of 69
using Web Application Framework (JATO). The Versioning tab displays the modules for the configured version control system. The Modeling tab displays the UML modeling aids. The Properties tab displays the properties for any selected item which is contextual. The Collaboration tab displays the developer collaboration utilities. The Enterprise Application Profiler window displays the profiling features for any Web, J2EE or Enterprise applications. The Debugging tab displays the debugger details such as Threads, Call Stack, Watches, Breakpoints etc. The illustration shown below depicts some of the views in Sun JSE 7.
across the team, JSF components and Struts tools for constructing Web-based applications. In addition, it also provides support for connecting Web applications to relational databases and Web services. IBM WSAD 5.1.2 provides templates for developing the following type of projects: Eclipse Modeling Framework (EMF), Enterprise Generation Language (EGL), EJB, J2EE, Java, Plug-in Development, Server, Web, and examples. It also provides the following perspectives to work with these projects: Component Test, CVS Repository Exploring, Data, Debug, EGL, EGL Web, Install/Update, J2EE, Java, Java Browsing, Java Type Hierarchy, Plug-in Development, Profile and Logging, Resource, Server, Web, XML and XSL Debug. The illustration below depicts some of the views and perspectives in WSAD 5.1.2.
interface, navigational aids and views. Sun JSE 7 provides Filesystems and Project tabs for navigating with the Java projects. IBM WSAD provides various perspectives with associated views. Sun JSE 7 and IBM WSAD 5.1.2 both provide templates for creating Java, Web, EJB and Web Services applications. Sun JSE 7 provides support for version control systems such as CVS, PVCS, ClearCase and Visual SourceSafe whereas IBM WSAD 5.1.2 provides support for CVS and ClearCase.
Page 8 of 69
3 Migration Steps
3.1 Steps for Migrating a Java Project
This section explains the steps for migrating a standard Java project (including classpath settings etc.) from IBM WSAD 5.1.2 to Sun JSE 7. The project comprises of a Java class file containing the main method. This class also refers to a utility Java library (.jar file). Structure of the application is described below: Directory Project Directory Source Classes Description Contains the Source and the Classes directories. Contains the Java source files. When compiled, classes for these will be generated in the Classes directory. Contains compiled Java classes.
The steps required to migrate the JAVA project to Sun JSE 7 are:
Create a new project. Add the Java source files by mounting the Source directory via Filesystems -> Mount -> Local Directory. Specify a target directory for class files.
Mount the Classes directory as a filesystem to serve as the output for the compiler. Specify this as a target directory (using Tools -> Options -> Building -> Compiler Types) for the class files.
Mount the JAR files used by the project via Filesystems -> Mount -> Archive Files.
Note: Information for the additional JAR files used by a project in IBM WSAD 5.1.2 can also be found from the entries in the .classpath file. The classpathentry tag with path attribute shows the JAR files that were included in the project.
On the Project window, right-click on the root project node and select Add Existing... from the contextual menu. On the Select Objects dialog, select the directories and files to be added to the project. Click on OK to add them to the project.
The migrated application can be verified by compiling and executing the application in Sun JSE 7. Migration of a Java project from IBM WSAD 5.1.2 to Sun JSE 7 has been described with an example in section 4.1.
Page 9 of 69
WEB-INF
WEBINF/classes
WEB-INF/lib Contains associated resources that are packaged in JAR files. The steps required to migrate a Web application are:
Create a new project in Sun JSE 7. Add a new Web Module to the project (This is to mount the WebContent directory in the Web project in the WSAD 5.1.2 workspace). Add the additional Java source files by mounting their directories via Filesystems -> Mount -> Local Directory. Specify a target directory for class files.
Mount the WebContent\WEB-INF\classes directory as a filesystem to serve as the output for the compiler. Specify this as a target directory (using Tools -> Options -> Building -> Compiler Types) for the class files for these additional source files.
Mount any additional JAR files used by the Web project in WSAD via Filesystems -> Mount -> Archive Files.
Note: The additional JAR files used by WSAD 5.1.2 can also be found from the entries in the . classpath file. The classpathentry tag with sourcepath attribute shows the JAR file that was included with the Web project in Eclipse.
Page 10 of 69
Following steps are optional and can be taken for including additional features in the application being migrated:
To make the servlet features available for the project, mark the servlet classes by choosing Tools -> Mark as Servlet.
Compile the source files and the Web module. Specify the Context Root for the Web module. Deploy and execute the Web module to an appropriate Web server.
Note: - Update the server CLASSPATH to add the external .jar archives used by the Web application, if any. - Refer to the IDE help documentation for deploying and executing the Web application.
Migration of the Web project from WSAD 5.1.2 to Sun JSE 7 has been described along with an example in section 4.2.
Page 11 of 69
Select the session bean package from the mounted filesystem. Open the Session bean wizard by right-clicking on the package and selecting New > All Templates....
On the Choose Template page, expand the J2EE node and select Session EJB. Click on Next >. On the Session Bean Name and Properties page, specify the session bean specifics. Click on Next > button. On the Session Bean Class Files page, click on Modify... buttons to select existing EJB class files (for the Home, Remote and Bean Classes).
Compile and validate the EJB. Deploy and execute the EJB on an appropriate application server.
Note: - Refer to the IDE help documentation for deploying and executing the EJB.
Mount the ejbModule directory (using the absolute path to the ejbModule directory in the EJB project in the WSAD 5.1.2 workspace). Select the CMP bean package from the mounted filesystem. Open the CMP Entity EJB bean wizard by right-clicking on the package and selecting New > All Templates....
On the Choose Template page, expand the J2EE node and select CMP Entity EJB. Click on Next >.
Page 12 of 69
On the CMP Entity Bean Name and Properties page, specify the CMP specifics EJB Name, Package, Source for Entities and Fields (CMP 2.x Bean Class), Component Interfaces. Click on Next > button.. On the Select a CMP 2.x Bean Class page, select the existing EJB class file. Click on Next > button. On the CMP Fields page, select the Primary Key field. Click on Next > button. On the CMP Entity Bean Class Files page, click on Modify Interface... buttons to select existing EJB class files (for the Home, Remote and Primary Key Classes).
In the FileSystems section of the Explorer, right-click the method node for the finder method and choose Properties to display the property sheet. Select the EJBQL Query property and click on the ellipses(...) button to define the EJBQL Query.
Note: Values for providing the information for EJBQL can be found from the ejb-jar.xml file found in the META-INF directory in the root directory of the EJB project in the WSAD 5.1.2 workspace.
Compile and validate the EJB. Create a connection to the requisite database. Create a database schema using the connection. Map the CMP Entity bean fields to the database schema fields. Deploy and execute the EJB on an appropriate application server.
Note: - Refer to the IDE help documentation for creating a database connection, capturing the database schema, mapping the CMP and database fields, deploying and executing the EJB.
Mount the ejbModule directory (using the absolute path to the ejbModule directory in the EJB project in the WSAD 5.1.2 workspace on the filesystem) to get access to the MDB EJB associated with the project. Select the package of the MDB EJB from the mounted filesystem. Open the MDB EJB bean wizard by right-clicking on the package and selecting New > All Templates....
Page 13 of 69
On the Choose Template page, expand the J2EE node and select Message-Driven EJB. Click on Next >. On the Message-Driven Bean Name and Properties page, specify the MDB EJB specifics. Click on Next > button. On the Message-Driven Bean Class File page, click on Modify... buttons to select existing bean class file.
Compile and validate the EJB. Configure a JMS Resource such as a Queue/Topic along with a JMS Resource Connection Factory and associate the MDB to these resources. Deploy the EJB on an appropriate application server and send messages to the associated JMS queue.
Note: - Refer to the IDE help documentation for configuring the JMS resources, associating the MDB to these resources, deploying and testing the EJB.
Migration of EJBs from WSAD 5.1.2 to Sun JSE 7 has been described along with an example in section 4.3.
Page 14 of 69
Locate the .wsdl file created by IBM WSAD 5.1.2. Mount the directory containing the .wsdl file in the Filesystems view of Sun JSE 7. Create appropriate Java packages. Create a Web service by selecting the Local WSDL file as the input. Select the .wsdl file as the input file.
Sun JSE 7 generates all the Web service related files(.wsdl, EJBs, etc.). It identifies the business methods from the WSDL file and adds them to the generated EJBs (sans the business logic).
Copy the business logic from the business methods of the renamed EJB files to the EJB files generated by Sun JSE 7.
Input and output parameters of methods in the Web service are mapped as input and output Java objects in the business methods of the EJBs generated by Sun JSE 7 if the style and use of the SOAP message binding for the Web service are document and literal. Sun JSE 7 generates the input and output parameter types as they are in the Web service if the style and use of the SOAP message binding for the Web Service are rpc and literal or rpc and encoded. The logical node of the Web service in the Filesystems tab can be used to generate all the Web service related files, Web Service Test Client, and a WSDL file. It can also be used to add another operation (method) to the Web service. The Web service can be tested from the IDE using the generated client. The client can be used to modify the appropriate JAX-RPC version for execution. The IDE also allows the developers to publish the Web service to the UDDI registry that comes bundled with the IDE. Migration of a simple Web service from WSAD 5.1.2 to Sun JSE 7 has been described along with an example in section 4.4.
Page 15 of 69
Illustration 3. CVS Properties in WSAD The CVS Repository properties can be used in Sun JSE 7 to connect to the same CVS repository. To connect to CVS, select Versioning -> Mount Version Control.
Page 16 of 69
Sun JSE 7 opens up the Versioning tab which displays the hierarchy for the module from the CVS repository. It also displays the VCS Output tab which gives the status of the commands. An example to illustrate the migration of the CVS repository from WSAD 5.1.2 to Sun JSE 7 has been described in section 4.5.
Page 17 of 69
4 Migration Examples
This section contains examples for migrating Java, Web, EJB and Web Services projects from IBM WSAD 5.1.2 to Sun JSE 7.
Illustration 5. Java project example in IBM WSAD Structure of the application is described below: Directory java_app Source Description Contains the Source and the Classes directories. Contains the java source files. When compiled, classes for these will be generated in the Classes directory.
Page 18 of 69
Directory Classes
This application refers to an external JAR file, java-utils.jar, as depicted in the illustration below:
The steps required to migrate the java-app project to Sun JSE 7 are:
Create a new project. Add the Java source files by mounting the Source directory via Filesystems -> Mount -> Local Directory as depicted in the illustration below.
Page 19 of 69
Mount the Classes directory as a filesystem to serve as the output for the compiler. Specify this as a target directory (using Tools -> Options -> Building -> Compiler Types) for the class files for the additional source files as shown in the illustration below.
Page 20 of 69
Page 21 of 69
Mount the java-utils.jar JAR files used by the project via Filesystems -> Mount -> Archive Files as shown in the illustration below.
Note: Information for the additional JAR files used by a project in IBM WSAD 5.1.2 can also be found from the entries in the .classpath file. The classpathentry tag with path attribute shows the JAR files that were included in the project.
On the Project window, right-click on the root project node and select Add Existing... from the contextual menu. On the Select Objects dialog, select the directories and files to be added to the project. Click on OK to add them to the project.
Page 22 of 69
Illustration 10. Migrated Java project in Sun JSE 7 The migrated application can be verified by compiling and executing the application in Sun JSE 7.
Page 23 of 69
Illustration 11. Example Web application in WSAD 5.1.2 The Web project in WSAD 5.1.2 confirms to a typical Web application (based on the Sun Microsystems Java Servlet 2.3 Specification). Structure of the Web application is described below:
Description Contains the JavaSource and the WebContent directories. Contains the servlet source files for the Web project. When compiled, classes for these servlets will be generated in the WEB-INF/classes directory.
Contains the WEB-INF directory and all directories and files that must WebContent be accessible to the client request, such as JSPs, HTML pages, cascading style sheets, images, and JavaScript files. Page 24 of 69
Directory
Description (Required) Contains the classes, lib and the taglib (custom tag libraries) directories, the standard Web application deployment descriptor (web.xml), and possibly a server specific deployment descriptor (<server>-web.xml). This directory is not part of the public document tree of the application; that is, you cannot directly serve any file contained in this directory, or any of its subdirectories, to a client.
WEB-INF
WEBINF/classes
Contains compiled Java classes, and associated resources that are not packaged in JAR files.
Contains associated resources that are packaged in Java ARchive WEB-INF/lib (JAR) files such as the customtags.jar containing the custom tags to be used by the tag library. Apart from the libraries in the WEB-INF/lib folder, this Web application also refers to an external utility Java library, java-utils.jar, as depicted in the illustration below:
Page 25 of 69
Illustration 12. Library settings in WSAD 5.1.2 The steps required to migrate the jsp-app Web application from WSAD 5.1.2 to Sun JSE 7 are:
Create a new project in Sun JSE 7. Name the project using the conventions followed for the WSAD 5.1.2 project, i.e. jsp-app. Add a new Web Module to the project as depicted in the illustration below.
Click on Next > button to specify the absolute path to the directory for the Web module (path to the WebContent directory in the Web project in the WSAD 5.1.2 workspace) as depicted below. (This is to mount the WebContent directory in the Web project in the WSAD 5.1.2 workspace)
Page 26 of 69
Page 27 of 69
Add all the additional Java source files by mounting their directories via Filesystems -> Mount -> Local Directory as depicted in the illustration below. These are the Java source files for which the class files are to be generated in the WEB-INF\classes folder.
Page 28 of 69
Mount the WebContent\WEB-INF\classes directory as a filesystem to serve as the output for the compiler. Specify this as a target directory (using Tools -> Options -> Building -> Compiler Types) for the class files for the additional source files as shown in the illustration below.
Note: This is needed as the class files for a Web application project should reside in the WEBINF\classes folder, if not bundled with as .jar files.
Illustration 15. Specifying target directory for compiled files in Sun JSE 7
Page 29 of 69
Mount the java-utils.jar JAR files used by the Web project in WSAD 5.1.2 via Filesystems -> Mount -> Archive Files as shown in the illustration below.
Note: The additional JAR files used by WSAD 5.1.2 (along with their location) can also be found from the entries in the .classpath file. The classpathentry tag with sourcepath attribute shows the JAR files that were included with the Web project in WSAD 5.1.2.
Page 30 of 69
Illustration 17. Migrated Web application in Sun JSE 7 To test the migrated Web application, perform the following steps:
Compile the source files and the Web module. Specify the Context Root for the Web module. Deploy and execute the Web module to an appropriate Web server.
Note: - Update the server CLASSPATH to add the external .jar archives used by the Web application, if any. - Refer to the IDE help documentation for deploying and executing the Web application.
Page 31 of 69
Illustration 18. Stateful session bean in IBM WSAD 5.1.2 This project comprises of a J2EE 1.3 compliant stateful Session EJB. Structure of the project is described below:
Description Contains the ejbModule directory. Contains the META-INF directory and the EJBs. Contains the standard EJB deployment descriptor (ejb-jar.xml), and possibly a server specific deployment descriptor. example.ejb.session package contains the home, remote and bean classes for the EJB.
Page 32 of 69
The steps required to migrate the session EJB associated with this project from WSAD 5.1.2 to Sun JSE 7 are:
Mount the ejbModule directory (using the absolute path to the ejbModule directory in the session-ejb project in the WSAD 5.1.2 workspace on the filesystem) to get access to the session ejb associated with the project. Select the package example.ejb.session from the mounted filesystem. Open the Session bean wizard by right-clicking on the package and selecting New > All Templates....
On the Choose Template page, expand the J2EE node and select Session EJB as shown in the illustration below.
Page 33 of 69
On the Session Bean Name and Properties page, specify the following, as shown in the illustration below:
EJB Name - HelloWorld Package - example.ejb.session State - Stateful Transaction Type Container-Managed Component Interfaces Remote Interfaces Only (Default)
Page 34 of 69
On the Session Bean Class Files page, click on Modify... buttons to select existing EJB class files (for the Home, Remote and Bean Classes) as shown in the illustration below.
Page 35 of 69
The following illustration displays the Sun JSE 7 dialog box that can be used to specify an existing bean class.
Page 36 of 69
The migrated Session EJB in Sun JSE 7 is shown in the illustration below.
Illustration 23. HelloWorld session bean in Sun JSE 7 To test the migrated session EJB, perform the following steps:
Compile and validate the EJB. Deploy and execute the EJB on an appropriate application server.
Note: - Refer to the IDE help documentation for deploying and executing the EJB.
Page 37 of 69
Illustration 24. CMP entity EJB in IBM WSAD 5.1.2 This project comprises of a J2EE 1.3 compliant CMP Entity EJB. Structure of the project is shown below:
Description Contains the ejbModule directory. Contains the META-INF directory and the EJBs. Contains the standard EJB deployment descriptor (ejb-jar.xml), and possibly a server specific deployment descriptor.
META-INF
Apart from this, it also contains the backends\<database> directory for storing the cmp-database mappings (for specifying the mapping of the CMP fields with the database table columns) as shown in the illustration below. Page 38 of 69
Directory
Description example.ejb.entity package contains the home, remote and bean classes for the EJB. This CMP also has a finder method findByUserId to find a user based on the UserId using the EJBQL query select object(o) from UserInfo o where o.userId = ?1.
UserInfo EJB
The following illustration displays the mapping of CMP fields with database table columns in WSAD 5.1.2.
Page 39 of 69
The steps to migrate the CMP EJB associated with this project from WSAD 5.1.2 to Sun JSE 7 are:
Mount the ejbModule directory (using the absolute path to the ejbModule directory in the cmp-ejb project in the WSAD 5.1.2 workspace) to get access to the CMP EJB associated with the ''cmp-ejb project. Select the package example.ejb.entity from the mounted filesystem. Open the CMP Entity EJB bean wizard by right-clicking on the package and selecting New > All Templates....
On the Choose Template page, expand the J2EE node and select CMP Entity EJB as shown in the illustration below.
Page 40 of 69
On the CMP Entity Bean Name and Properties page, specify the following as shown in the illustration below:
EJB Name - UserInfo Package - example.ejb.entity Source for Entities and Fields - CMP 2.x Bean Class Component Interfaces Remote Interfaces Only
Illustration 27. CMP entity bean name and properties in Sun JSE 7
Page 41 of 69
On the Select a CMP 2.x Bean Class page, select the UserInfoBean class as shown in the illustration below.
Page 42 of 69
On the CMP Fields page, select userId field as the Primary Key as shown in the illustration below.
Illustration 29. Selecting the primary key for a CMP in Sun JSE 7
Page 43 of 69
On the CMP Entity Bean Class Files page, click on Modify Interface... buttons to select existing EJB class files (for the Home, Remote and Primary Key Classes) as shown in the illustration below.
Page 44 of 69
The following illustration displays the Sun JSE 7 dialog box for defining an existing primary key class as the primary key class for the CMP EJB.
Page 45 of 69
To associate the EJB QL to the findByUserId(String userId) finder method, perform the following:
In the FileSystems section of the Explorer, right-click the method node and choose Properties to display the property sheet as shown in the illustration below.
Select the EJBQL Query property and click on the ellipses(...) button to define the EJBQL Query as shown in the illustration below.
Note: Values for providing the information for EJBQL can be found from the ejb-jar.xml file found in the META-INF directory in the root directory of the cmp-ejb project in the WSAD 5.1.2 workspace.
Page 46 of 69
The migrated CMP EJB in Sun JSE 7 can be shown as in the illustration below.
Illustration 34. CMP entity bean in Sun JSE 7 To test the migrated CMP EJB, perform the following steps:
Compile and validate the EJB. Create a connection to the requisite database. Create a database schema using the connection. Map the CMP Entity bean fields to the database schema fields. Deploy and execute the EJB on an appropriate application server.
Note: - Refer to the IDE help documentation for creating a database connection, capturing the database schema, mapping the CMP and database fields, deploying and executing the EJB.
Page 47 of 69
Illustration 35. MDB EJB in IBM WSAD 5.1.2 This project comprises of a J2EE 1.3 compliant Message Driven EJB. Structure of the project is described below:
Description Contains the ejbModule directory. Contains the META-INF directory and the EJBs. Contains the standard EJB deployment descriptor (ejbjar.xml), and possibly a server specific deployment descriptor. example.ejb.mdb package contains the bean class for the EJB.
Page 48 of 69
This MDB is configured to receive messages from an associated JMS destination via a ListenerPort as shown in the illustration below.
Page 49 of 69
The steps to migrate the MDB EJB associated with this project from WSAD 5.1.2 to Sun JSE 7 are:
Mount the ejbModule directory (using the absolute path to the ejbModule directory in the mdb-ejb project in the WSAD 5.1.2 workspace on the filesystem) to get access to the MDB EJB associated with the project. Select the package example.ejb.mdb from the mounted filesystem. Open the MDB bean wizard by right-clicking on the package and selecting New > All Templates....
On the Choose Template page, expand the J2EE node and select Message-Driven EJB as shown in the illustration below.
Page 50 of 69
On the Message-Driven Bean Name and Properties page, specify the following as shown in the illustration below:
Page 51 of 69
On the Message-Driven Bean Class File page, click on Modify Class... button to select an existing bean class file as shown in the illustration below.
Page 52 of 69
The following illustration displays the Sun JSE 7 dialog box for specifying an existing bean class.
Page 53 of 69
The migrated MDB EJB in Sun JSE 7 is shown in the illustration below.
Illustration 41. MDB EJB in Sun JSE 7 To test the migrated MDB EJB, perform the following steps:
Compile and validate the EJB. Configure a JMS Resource such as a Queue/Topic along with a JMS Resource Connection Factory and associate the MDB to these resources. Deploy the EJB on an appropriate application server and send messages to the associated JMS queue.
Note: - Refer to the IDE help documentation for configuring the JMS resources, associating the MDB to these resources, deploying and testing the EJB.
Page 54 of 69
Page 55 of 69
The Calculator Web Service can be tested and executed from WSAD. It displays the results as shown in the illustration below:
Illustration 43. Sample Web service output in IBM WSAD 5.1.2 The Calculator Web service uses SOAP binding parameters style and use as rpc and encoded. A sample .wsdl file for the Calculator Web service is shown below:
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://ejb" xmlns:impl="http://ejb" xmlns:intf="http://ejb" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:types> <schema targetNamespace="http://ejb" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://ejb" xmlns:intf="http://ejb" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <element name="a" type="xsd:int"/> <element name="b" type="xsd:int"/> <element name="substractReturn" type="xsd:int"/> <element name="int" type="xsd:int"/> <element name="addReturn" type="xsd:int"/> </schema> </wsdl:types> <wsdl:message name="substractRequest"> <wsdl:part name="a" type="xsd:int"/> <wsdl:part name="b" type="xsd:int"/>
Page 56 of 69
</wsdl:message> <wsdl:message name="addResponse"> <wsdl:part name="addReturn" type="xsd:int"/> </wsdl:message> <wsdl:message name="addRequest"> <wsdl:part name="a" type="xsd:int"/> <wsdl:part name="b" type="xsd:int"/> </wsdl:message> <wsdl:message name="substractResponse"> <wsdl:part name="substractReturn" type="xsd:int"/> </wsdl:message> <wsdl:portType name="Calculator"> <wsdl:operation name="substract" parameterOrder="a b"> <wsdl:input message="intf:substractRequest" name="substractRequest"/> <wsdl:output message="intf:substractResponse" name="substractResponse"/> </wsdl:operation> <wsdl:operation name="add" parameterOrder="a b"> <wsdl:input message="intf:addRequest" name="addRequest"/> <wsdl:output message="intf:addResponse" name="addResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="CalculatorSoapBinding" type="intf:Calculator"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="substract"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="substractRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ejb" use="encoded"/> </wsdl:input> <wsdl:output name="substractResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ejb" use="encoded"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="add"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="addRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ejb" use="encoded"/> </wsdl:input> <wsdl:output name="addResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ejb" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="CalculatorService"> <wsdl:port binding="intf:CalculatorSoapBinding" name="Calculator"> <wsdlsoap:address location="http://localhost:9080/TestProjectRouter/services/Calculator"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Page 57 of 69
Mount the directory containing the Calculator.wsdl file from the Filesystems view. Mount a filesystem where the Web service is to be created. Create Java packages such as websvc, ejb and client to hold the source code related to Web service, EJB and the Web service client respectively. Right-click on the websvc package, select New -> All Templates. Select Web Service from the Web Services templates.
Page 58 of 69
Next, specify the name of the Web service, and select Local WSDL File in the Create From options.
Page 59 of 69
Select the .wsdl file from IBM WSAD workspace as the input for a similar Web service implementation.
Page 60 of 69
As the business logic for the Web service methods is implemented in EJBs by Sun JSE 7, specify the EJB name and the package to create the EJBs.
Page 61 of 69
Sun JSE 7 generates the Web service and the business methods in EJBs. Copy the business logic into these methods to get the same functionality. If the business methods in WSAD access other modules such as Java projects or EJB projects, refer to sections 4.1 and 4.3. Sun JSE 7 with generated Web service files is shown in the illustration below.
Illustration 48. Sample Web service in Sun JSE 7 To create a Web Service Test client, right-click on the logical node of the Web service. As in the illustration below, it provides an option for the package name.
Page 62 of 69
Illustration 49. Create Web service client in Sun JSE 7 From the generated client files, the Web service can be executed and tested by rightclicking on the client application node. The test output for the Web service is shown in the illustration below.
Page 63 of 69
Page 64 of 69
The properties for the mounted CVS Repository can be displayed by right-clicking on the the repository and selecting the Properties option from CVS Repository tab. The following illustration displays the properties for a sample CVS repository.
Page 65 of 69
The properties captured from Eclipse such as CVS Server Type, CVS Server Name, Port Number (default CVS port number is 2401), User name, Repository path, and the password can be used to connect to the same CVS repository. The following illustration displays the CVS settings to be configured in Sun JSE 7.
Page 66 of 69
Sun JSE 7 displays the structure of the module in the Versioning tab. The IDE displays the available CVS commands in the Runtime tab. It also opens up the VCS Output tab which displays the status of the commands that have been executed. Sun JSE 7 with typical Version Control System views is shown in the illustration below:
Page 67 of 69
5 Appendix
References
Page 68 of 69
Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved. U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms. This distribution may include materials developed by third parties. Sun, Sun Microsystems, the Sun logo, Java, JavaServer, JavaBeans, NetBeans, EJB, Enterprise JavaBeans, the Duke logo and the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries. Products bearing SPARC trademarks are based upon architecture developed by Sun Microsystems, Inc. This product is covered and controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.
Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, Etats-Unis. Tous droits rservs. Lutilisation est soumise aux termes de la Licence. Cette distribution peut comprendre des composants dvelopps par des tierces parties. Sun, Sun Microsystems, le logo Sun, Java, JavaServer, JavaBeans, NetBeans, EJB, EnterpriseJavaBeans, le logo Duke et le logo Java Coffee Cup sont des marques de fabrique ou des marques dposes de Sun Microsystems, Inc. aux Etats-Unis et dans dautres pays. Toutes les marques SPARC sont utilises sous licence et sont des marques de fabrique ou des marques dposes de SPARC International, Inc. aux Etats-Unis et dans d'autres pays. Les produits portant les marques SPARC sont bass sur une architecture dveloppe par Sun Microsystems, Inc. Ce produit est soumis la lgislation amricaine en matire de contrle des exportations et peut tre soumis la rglementation en vigueur dans dautres pays dans le domaine des exportations et importations. Les utilisations, ou utilisateurs finaux, pour des armes nuclaires,des missiles, des armes biologiques et chimiques ou du nuclaire maritime, directement ou indirectement, sont strictement interdites. Les exportations ou rexportations vers les pays sous embargo amricain, ou vers des entits figurant sur les listes dexclusion dexportation amricaines, y compris, mais de manire non exhaustive, la liste de personnes qui font objet d'un ordre de ne pas participer, dune faon directe ou indirecte, aux exportations des produits ou des services qui sont rgis par la lgislation amricaine en matire de contrle des exportations et la liste de ressortissants spcifiquement dsigns, sont rigoureusement interdites.
Page 69 of 69