Best practices: Mediation modules and packaging

When developing mediation service applications, you may need to work with resources such as JSP files, JAR files, Web projects, Java™ projects, and J2EE projects. This topic provides information to help you set up your projects and resources so that they can be successfully built and deployed to WebSphere® Enterprise Server or WebSphere Process Server.

Working with Java code

Best Practices: If you need to develop Java applications or import JAR files that will be used by a custom mediation primitive, you should create a Java project for the code and add a dependency on the Java project to the mediation module that will be using the Java code.

The Java properties of the business integration library or mediation module should not be altered because this may cause problems in deployment code generation. As a result, we do not recommend that you develop complex Java applications or import JAR files into a library or mediation module in order to use them. Also, when generating Java implementations for Java components in a mediation module assembly diagram, the generated Java implementations should be used as a launch point to call other Java classes.

Note that the Business Integration view only shows Java implementations and interfaces that are used in an assembly diagram. They are listed under the mediation module that uses them. If you need to work with Java projects you can switch to work in the Java perspective.

Switching to the Java perspective

Open the Java perspective by following these steps:

  1. From the menu, select Window > Open Perspective > Other....
  2. Select Java and click OK.

In the Java perspective, the two opened perspectives are shown at the top right corner of the Workbench window, you can switch to the Business Integration perspective by clicking the Business Integration perspective button, as shown in this image:

top right corner of the Workbench window showing the two perspective buttons

Here are some instructions for the Java development in a Java project:
  • Create a Java project.
  • Do your Java development in the Java project. If you need to import a JAR file, import the file into the Java project. Do not import JAR files into the mediation module or library; the JAR will not be added to the EAR file.
  • Open the mediation module that will use the Java code with the dependency editor. Add the Java project as a dependent and make sure that the Deploy with Module check box is selected. The dependency editor will add the Java project to the module's classpath. The JAR file will be deployed with the module.

Business objects and interfaces for imports and exports

Best Practices: If you plan to use imports and exports in mediation module assembly diagrams, it is a good practice to put the business objects and interfaces that are used by the import and exports into a library so that they can be shared. Then, add a dependency on the library to all of the modules that use these common resources. Avoid copying the same business objects and interfaces into different modules to use them.

Library resources that are shared

After deployment, if shared resources change in the library, modules using the resources have to be updated. For example, two modules share some resources in a library. The applications are deployed. One of the modules has to be updated resulting in changes to some of the shared resources in the library. In this case, the second module also needs to be updated to reflect the changes in the shared resources.

WSDL files must be in a module or a library

If you need to use a WSDL file in a module, copy it to the module. Optionally, copy the WSDL file to a library and, in the module, set a dependency on the library so that you can use the library's resources. If you tried to drag a WSDL file from another type of project, for example a Web project, an error message will prompt you to copy the WSDL to the module or library.

J2EE module names

The mediation module is a simple project which produces a J2EE EAR file consisting of J2EE projects. If the module is named MyApp, then J2EE projects with these names are generated and you should not use them for your own J2EE projects:
  • MyAppApp
  • MyAppEJB
  • MyAppEJBClient
  • MyAppWeb

Changing dependencies without the editor

You should avoid modifying module dependencies outside of the dependency editor.

When you add a dependency on a library, Java project, or J2EE project, changes are made to the module's properties. That is, the module's properties are changed, as follows:

  • The Java Build Path would have the library or project added to its build path.
  • The Project References determines which J2EE projects or utility JARs are to be included in the resulting EAR file for the module. If in the dependency editor, the library or project is also selected to be Deployed with the Module, then the Project References will have the library or project selected so that it will be added to the EAR file for deployment.

Use the dependency editor to manage project dependencies for your mediation modules and libraries instead of editing their properties. There are important Java assumptions set in the properties of mediation modules and libraries, so you should not modify the Java properties, for example, to change their source and output folders.

Related concepts
Modules and libraries
Modules and libraries dependencies
Business integration capabilities and roles
Business integration cheat sheets
Related tasks
Creating a module for business services
Creating a mediation module
Changing default namespaces
Enabling tools capabilities
Adding dependencies to modules and libraries
Creating the library

Related information

Tutorial: Work with modules and libraries

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.