|
|
|
WebSphere Studio Application Developer is designed for the creation of more complex projects, providing fully dynamic web applications
If you have moved beyond simple servlets and wish to create a complete J2EE application using EJBs, the J2EE perspective is likely where you will
All the J2EE module creation wizards allow you to select an enterprise application project to contain the new module, so the creation and assembly of your complete application should take place almost automatically. However, if you wish to modify the resulting EAR in any way, the J2EE view is the best place to do so. The physical layout of enterprise applications, EJB projects, and web projects in the workbench file system is that all projects are created as peers. You may expect EJB and web projects to be physically children of a containing enterprise application project, but that structure would prevent the use of the same modules in more than one enterprise project.
This approach allows the modules to be created and reused with ease, and the logical containment of EJB web projects in an enterprise projects is represented via the J2EE view. As described with web projects above, the assembly of all projects into their correct file types and containing modules is now
The structure of an enterprise application project does represent the contents of the resulting archive. There is a
/META-INF
directory that contains the various metadata files – both the spec-defined
application.xml
and the IBM extensions. In general it should not be necessary to directly manipulate the content of the files, as the provided enterprise application editor will give a logical view of the data while ensuring the correct files are updated.
The J2EE view also provides an optimized view of your EJB projects; there are many additional files required while executing an EJB. However, the basic
In addition to the modules required to assemble your application, the databases used and server definitions are also available in the J2EE view. This provides an easy way to access the various files, as opening the files from this view will reuse the same editor available in other views.
Any reasonably
In addition, the
MANIFEST.MF
file in the archive will
EJBs are discussed in depth throughout later chapters, so we will limit this discussion to an introduction to the EJB capability in Studio. WebSphere Studio Application Developer version 5.0 supports the creation and deployment of both 1.1 and 2.0 EJBs. The project type itself must be defined at creation time, as the DTD of the deployment descriptor has changed between versions. An EJB 2.0 project can contain CMP beans with both 1.1 and 2.0 style persistence, although it is not recommended that you mix the two in a single JAR.
The EJB project creation wizard is very similar to the web project creation wizard, prompting first for the desired specification level, and then for any module dependencies. The structure of an EJB Project is also consistent with web projects; there is a single directory ( ejbModule ) that represents the contents of the resultant archive. Any files that are placed in this directory will also be included in the output JAR; any files that are associated with the project, but that you do not wish to distribute should be located in any directory you have created in the root of the project, as a peer to ejbModule .
Within ejbModule is a /META-INF directory, which contains the deployment descriptor and associated metadata files. The WebSphere extensions take the form of several additional files in this directory:
|
File
|
Description |
|---|---|
|
META-INF/ejb-jar.xml |
Spec deployment descriptor |
|
META-INF/ibm-ejb-jar-ext.xmi |
IBM deployment descriptor extensions |
|
META-INF/ibm-ejb-jar-bnd.xmi |
IBM deployment descriptor bindings |
|
META-INF/map.mapxmi |
Mapping information for CMP beans |
|
META-INF/schema/* |
Schema information for CMP beans |
Note that you can also define multiple schema maps for beans with version 2.0 persistence, but this scenario will result in additional metadata files saved in the META-INF tree.
Despite the fact that the EJB metadata
The last page of the editor is a source page, allowing you to view the resulting deployment descriptor. This is a live view, so changes can be made in the source page and they will be immediately reflected in the other pages of the editor.
As described above, the J2EE view shows the critical files for an EJB as nodes in the main Navigator view tree. When editing the bean in the Java editor in this perspective, the Outline view of the file can also be used to add methods to or remove
Entity EJBs with CMP require a schema, and a mapping of CMP fields to that schema, to generate the code to implement that persistence. Studio can generate a schema from an EJB definition (known as "top-down"), or you can use the mapping editor to connect an existing schema definition to the entity ("meet in the middle"). These modes of operation can be mixed, allowing you to create a top-down map, and then modify it in the mapping editor. You can also create a new EJB from an existing schema definition, as a so-called "bottom-up" operation.
The metadata files are saved in the JAR, allowing the batch mode EJBDeploy tool to run outside the workbench, and still reflect a comprehensive schema map. When running the top-down schema creation, the database vendor must be defined. The resulting code to implement a particular mapping is type specific, not vendor specific – but the optimum selection of types may vary by vendor.
We want to use a CMP EJB to persist the data for our phonebook application. The resulting EJB is very simple, containing just two fields – a name and a number. The following screenshot shows how this EJB is mapped to the schema we defined previously. The mapping editor provides several views of the
Having completed the mapping operation, the
Testing of web applications is relatively simple, as they are designed with a user (web) interface. You must run the server, and interact with them via a browser, but the method of that interaction is clearly defined. Testing of EJBs is not quite as simple, as they only provide a Java interface. It is
To address these issues, Studio includes a web application called the Universal Test Client. This application is
The test client starts by listing the JNDI namespace. You can either enter the name of the bean you
Once you have located the home bean, you will see the methods on the home bean displayed. Invoking a create() or find() method will return a bean instance, which can then be expanded. Any object that is returned can be added to the tree on the left, not just EJBs; objects are dynamically introspected, and so the results can be displayed, and further methods invoked, as required. The same test client can also be used to interact with returned JavaBeans, when working with web services.
A complete collection of application analysis tools is available in Studio, including tracing the flow of distributed applications, performance analysis of those applications, and server log analysis and problem determination.
The distributed trace support requires the installation of the Remote Agent Controller on the remote machines, but this is also required for the remote server support and so may already be installed. To trace an application, you first start the server in profiling mode from within Studio. In the profiling perspective you then attach to the application you have started (which may be on the local or a remote machine), start the monitor, and then just use your application as you would normally. All usage is now being captured, and flows back to Studio, even as the application makes calls to other applications, or across machine boundaries.
When the application is complete, you can close it down, and display the results of the analysis in a large number of different textual and graphical formats. One of the most useful views is the Sequence Diagram, as shown below. This diagram provides a call flow of the application on a UML-style interaction diagram, including the relative performance of the call as a coloured bar on the left of the screen. The brighter the colour, the longer that method took:
Guided by this overview of the performance, you can then open the details page of the data, which will show the exact time spent in each method, and in
The log analyser tool provides a mechanism to import a WebSphere-generated log file, view it graphically, and then compare it with a symptom database. If you are having trouble activating or configuring a WebSphere server, either locally or remotely, the log analyser can help you navigate the different logs that are generated to identify the likely cause. Problems that can be identified by the log analyser range from common configuration errors, to defects in the code for which fixes are available. Suggestions for fixing recognized problems are then displayed in the window.
Updates to the symptom database can be downloaded (in Studio) from an IBM FTP site. This mechanism means that IBM can provide an updated symptom database reflecting the causes of recently
|
|
|