Pramati Technologies

Using Express Development in Pramati Studio

Overview

J2EE architecture defines the typical EJB component development lifecycle as create, assemble, deploy, and run the application. Express Development provides an easy programming archetype by automating the tasks in a typical J2EE development life cycle.

The main features of Express Development are:

This chapter describes Express Development in Studio and its features in detail.

Advantages of Express Development

For J2EE development, it is necessary to create, assemble, and deploy each J2EE module in an application according to the specification. Express Development allows assembling and updation of changed components to be automated with default values and always keeps the desk root, EJB modules and web modules ready-to-deploy; the default values can be modified.

Advantages of using Express Development are:

Viewing Express Development output

Express Development provides event feedback for:

Status of each event is displayed as a node in the Express Development tab of output panel. The status is shown by means of icons and colors. Each event triggered has processes that are displayed as sub-nodes under the main node. These tasks are marked as they are completed with unsuccessful events displayed in red, and successful ones in blue. For example, clean building a module or file creates a separate node in the tree, and successful completion of the task depends on completion of all sub-nodes. The main node does not change its status until all sub-nodes have been completed. Actions that can be performed in Express Development tab in output panel are:

Using Express Development with EJB module

EJB module is a source root stored directly under desk node in the desk tree hierarchy; it is always in a ready-to-deploy state. EJB module represents an extracted archive view of ejb-jar and provides with all added functions of Express Development.

Note: There can be more than one EJB module in one desk pointing to a single source root in the file system. More than one EJB module in a desk can share a single EJB component.

The types of EJB modules in a desk are:

The advantages of using Express Development with EJB modules are:

File structure of EJB module created by Express Development

Creating a bean in EJB module using Bean Wizard, generates the bean class file, bean, its interfaces, and compiles them, automatically. The classes directory of EJB module is set by Studio based on module name and is placed under the desk classes directory specified at desk creation time; it cannot be modified. For example, if the EJB module name is TestEJB, the classes are stored in the directory <Desk-classes-dir>/TestEJB. This is set so that Express Development can maintain physical separation between different modules and treat them as virtual ejb-jars.

Modifying EJB module properties

Packaging information in ejb-jar.xml for a bean under EJB module is generated from the information provided in bean properties of that bean. Any changes made to the packaging information in bean properties is picked up by Express Development. Use Bean Properties panel to change any packaging information. To open Bean Properties panel, right click on the bean properties node in the desk and select Open or double click on the node. The attributes that can be set here are:

For more information, read `Packaging EJB Components'.

Modifying packaging properties

Express Development generates ejb-jar.xml file automatically. The ejb-jar.xml comprises of enterprise beans in addition to packaging information, so that the module functions as a complete EJB application and is ready-to-deploy. The ejb-jar file must contain class files of each enterprise bean either by inclusion or by reference. The class files are:

To view the ejb-jar.xml properties, right click on the EJB module and select ejb-jar.xml. This provides an archive view of the JAR.

This panel allows you to add and make changes to the Security Roles. All other changes to be made should be made in the Bean Properties panel. EJB module displays all the beans to be deployed and their properties such as:

Deleting a bean from the EJB module

Deleting a bean from the desk automatically removes all beans holding relationships with that bean from the ejb-jar.xml for that module. The related beans are not physically removed. This process is repeated until ejb-jar.xml is consistent as per EJB specifications. The XML is updated accordingly and all related deployment information is modified and updated. To reconstruct the JAR, new relationships should be created again using the Relationship Manager or by editing bean sources, manually. To add any removed beans, compile them in the desk. This triggers Express Development to add these beans back to ejb-jar.xml.

Modifying deployment properties for EJB module

All deployment information for beans under EJB modules are stored in:

The deployment information is taken from bean properties. Changes made here all are placed in the appropriate Bean Properties panel. Deployment information can be examined and modified for any target server by opening the EJB module as an archive file in Deploy Tool, and saving this information. To open and modify the module in Deploy tool, select Tools > Deploy, and in the Deploy Tool, select Archive > Open > Module Name.

Configuring EJB module components to be deployed

The EJB module can be configured to include or exclude sub-components to be deployed. Right click on the module and select Properties. In Properties panel, select the Deploy tab.

Here, Beans option in the Include field allows beans to be marked as deployable or non-deployable. Non-deployable beans are ignored by Express Development. Unchecking a bean marks it as non-deployable and removes it from packaging information. Other properties that can be configured are files and folders. In this case, the files and folders to be deployed with the JAR can be selected manually.

Note: Unchecking a CMP 2.0 bean affects all other beans in the relationship (CMR) graph.

Modifying Queries

Information on all queries for EJB 1.1 modules are stored in the queries.props file. This information is also available in Finders node in Bean Properties panel. To modify any query, use this panel. For more information, read `Designing Queries using the Query Manager in Studio'.

Exporting into Java archives

The `Export as Archive' option ask s you to choose the destination. The following files are available in the exported Java archive:

The exported Java archive can be used in the desk like any other ejb-jar created using Package Tool; it is enabled for updation. Right click on the JAR and select Update to pick new packaging information. As per Update Operation semantics for Package Tool, the deployment information does not get updated. For Example, if we change finder or select methods, the update option will not work. `Export as Archive' option should be selected again on the module.

Filtering files for exporting EJB module as an archive

You can filter files to be excluded when an EJB module is exported as an archive. Filters are stored in the file <ModuleName>ExportAsArchiveFitlers.props located under the desk root directory. Files matching any of the provided patterns in this file are removed from the archive, automatically. For example, to exclude all CVS files from an exported archive, edit the files in the module for filters by adding the entry <ModuleName>.<filterNum>=*CVS/* as the pattern to exclude. The default patterns that are used for EJB modules is *.java. The filter files can be edited any time. The changes is pick up the next time `Export as Archive' operation is performed.

Using Express Development with web module

A web module is a folder directly under desk node in the desk tree hierarchy and is always in a ready-to-deploy state. Web module represents the archive view of WAR in the desk and provides you with all the added functions of Express Development. There can be more than one web module in a desk but two web modules can not point to the same source root directory in the file system. Web module has the following benefits with Express Development:

File structure of a web module

Files are organized under Web module with the classes directory defined according to the J2EE specification and cannot be modified. It is constructed by <Web module Location>/WEB-INF/classes.

Modifying web module properties

The web module automatically generates web.xml file when required. To modify web component properties:

Note: If reference classes are changed, right click and select Update on supportingClasses.jar; deploy the web module

Deploying web module

To deploy a web module, right click on the module node and select Deploy. If the deployment information is incomplete and reasonable defaults are not available for that option, Deploy Tool opens where all pending tasks can be completed. The changes made are saved into the module and corresponding web module files. Changes made to the JSPs are reflected when they are saved, and the module need not be redeployed. If the interfaces of the referenced beans are modified, the module must be redeployed to reflect these changes. This is especially important when references are auto-packaged into supportingClasses.jar as this JAR is updated only on deployment.

Picking Servlets and Filters classes

To pick up Servlets/Filters from a web module classpath and add them to the web.xml file:

  1. Right Click on the web module node and select Properties; select Deploy tab in this panel.
  2. In the Include field, select the option, Servlets/Filters from the dropdown.
  3. Click `Servlets' button to pick Servlets from a JAR under WEB-INF/lib. Clicking `Filters' button allows you to pick Filters from a JAR under WEB-INF/lib. Clicking any of these buttons opens a dialog that scans the JARs and looks for Servlets or Filters.
  4. The Scanning dialog displays Servlets or Filters as they are found. You need not wait for the scanning to end. At any point, you can select the classes required and click OK. This interrupts the process and displays all the Servlets or Filters in Deploy tab.
  5. Servlets or Filters selected from the classpath, appear in the table. Added Servlets and Filters are selected and in Deploy column, to be added to web.xml. To remove them from web.xml, uncheck the Servlet or Filter name.
Note: Loose classes from WEB-INF/classes are not scanned or picked up. Only Servlets/Filters in the JAR files are picked up. Servlets and Filters cannot be deleted from the Include table but, can be checked or unchecked.

Exporting web module into web archive

To convert the web module into a physical archive visible in the desk, right click on the module and select Export as Archive. Before exporting into an archive, ensure that a WAR archive node exists in the desk. Selecting Export as Archive prompts for the destination. The files that are added to the archived WAR are:

Exported archive can be used in the desk like any other WAR created using Package Tool. It is enabled for updation, and right clicking on the file and selecting Update picks up all the latest packaging information, but deployment information is not updated.

Modifying context root of a web module

When a web module is deployed, the context root is taken as the web module name. To modify the context root, refer to the methods explained in the following sections.

Method1

The first method involves creating a new web module with a name same as the context root name, and then deploying it as follows:

  1. Create a new web module with the same name as context root.
  2. Import all required files into this module and close the desk.
  3. Copy web.xml file of the old web module into new web module. The web.xml file is stored at <install_dir>/<desk_dir>/<webmod_dir>/WEB-INF.
  4. Copy pramati-j2ee-server.xml from the old module into new. This file is stored at <install_dir>/<desk_dir>/<webmod_dir>.
  5. Re-open the desk in Studio.
  6. To deploy the new module, right click on the web module node and select Deploy.
  7. To access the application, run JSP client. For example, http://localhost:8181/context_root/test.jsp, where context_root is the name of the new web module and test.jsp is the JSP client used to access the WAR.

Method 2

This method involves creating a WAR using the Export As Archive option, and changing the context root of the WAR file created.

Method 3

This method involves creating a WAR, adding it to an EAR and then deploying the application as an EAR.

Filtering Files for Exporting

The exported archive picks up all available files in the Web module for performance reasons. This may result in certain unnecessary files getting packaged, increasing the WAR file size. These files include Java source files, map files used by the Debugger. The Filtering Files option helps avoid this situation, by not including these unnecessary Java source and map files.

Files can be filtered to be excluded when a Web module is exported as an archive. Filters are stored in a file named <ModuleName>ExportAsArchiveFitlers.props located under the Desk Root directory. File matching any of the provided patterns in this file, are automatically removed from the archive.

Always use / to indicate path names. The default patterns that are used for Web modules are *.java, *.map

The filter files can be edited any time. The changes get picked up the next time the operation, Export as Archive is performed. Filter Patterns are not applied on the supportingClasses.jar.

Desk Root

A Desk Root is a virtual representation of a J2EE desk, and is stored. The Desk Root acts as the node containing the entire J2EE application. It represents the archive view of the EAR in the desk and provides the user with all the added functions of Express Development.

Using the option Deploy available on a right click deploys the modules under the Desk Root. Using Deploy as EAR, available on a right click deploys the application as an enterprise archive. If all the settings required for deployment are not provided, the deploy tool comes up so that the user can make the required changes.

Changes made in the Deploy Tool are not persisted when the desk is deployed as an EAR. The application gets deployed with the changed deployment information only for the current deployment. The JSP Pages are also not refreshed automatically in this case. But, When a JSP page is changed and saved, the changes reflect without redeployment.

Exporting into Enterprise Archives

To smoothen the progress of moving from the Express Development mode of working to the typical J2EE mode of working, use the Export As Archive option. This option converts the Desk Root node into a physical enterprise archive (EAR).

To do this, right click on the Desk Root node in the Explore Panel and select Export as Archive. This converts it into a physical archive in the desk. To export the Desk Root into an EAR, the desk must have a folder of the type, enterprise archive.

These archives are complete J2EE archives and comprise the deployment descriptors (XML files) and can be deployed on the Server or opened in Studio to be modified. These archives have an independent existence from their source. Changes here do not get reflected anywhere else.

Validating the Desk Root

The Desk Root can be validated before deploying, to verify that all tasks to be performed by the bean provider, as mentioned in the EJB 2.0 specification, are complete.

To validate the Desk Root, right click on the Desk Root node in the Explore Panel and select Validate. This exports the Desk Root into an enterprise archive (EAR), and then validates the archive created.

Configuring Deployable Modules

The desk can be deployed without all the modules under it. This is especially useful when the desk contains modules that are still being developed, or are incomplete. To do this, right click on the desk tree node and select Properties. In the Properties panel that comes up, click on the Deploy tab, and uncheck the modules that are not to be deployed. The modules that are unchecked are not included in any of the operations - Deploy, Validate, or Export as Archive.

Pending Tasks

Express Development keeps track of user operations and tries to keep the application in a state where all the common, error-prone, manual tasks have been automated. To achieve this, it uses certain user operations like triggers. Example, Bean compilation is treated as trigger. Such triggers result in requests that have to be processed sequentially. Some of these requests may take some time to get executed. This results in stopping all other operations until the request is executed completely. For example, deployment requests may take a long time to execute completely. When the user invokes an operation that requires UI feedback like validation, displaying packaging properties, or exporting as archive, the operation may not be executed immediately because of pending tasks. Pending task are tasks in Studio that are yet to be executed.

The Express Development Pending Tasks Panel in such a case, pops-up in the Status Bar and shows all the pending tasks of the different modules. When the specified tasks are executed successfully, the panel disappears from the Status bar. This panel can also be hidden by clicking on the Hide button.

Troubleshooting Tips

The EJB module, Web module or the Desk Root in the desk may not reflect the specified settings of the application. To solve this, Right Click on the Desk Root/EJB module/Web module > Properties. This brings up the Properties dialog box. Click on the Repair tab and use the Sync State button to forcibly regenerate all the deployment information.


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX