Friday, June 15, 2012

J2EE Tutorial-16(Modifying the J2EE Application)

Since the J2EE SDK is intended for experimentation, it supports iterative development. Whenever you make a change to a J2EE application, you must redeploy the application.

Modifying a Class File


To modify a class file in an enterprise bean, you change the source code, recompile it, and redeploy the application. For example, if you want to change the exchange rate in the dollarToYen business method of theConverterBean class, you would follow these steps.

  1. Edit ConverterBean.java.

  2. Recompile ConverterBean.java by typing ant converter.

  3. In deploytool, select ToolsUpdate Files.

  4. The Update Files dialog box appears. If the modified files are listed at the top of the dialog, click OK and go to step 6. If the files are listed at the bottom, they have not been found. Select one of those files and click Edit Search Paths.

  5. In the Edit Search Paths dialog, specify the directories where the Update Files dialog will search for modified files.

    1. In the Search Root field, enter the fully-qualified name of the directory from which the search will start.

    2. In the Path Directory list, add a row for each directory that you want searched. Unless fully-qualified, these directory names are relative to the Search Root field.

    3. Click OK.



  6. Select ToolsDeploy. Make sure the checkbox labeled Save Object Before Deploying is checked. If you do not want to deploy at this time, select ToolsSave to save the search paths specified in step 5.


As a shortcut, you can select ToolsUpdate And Redeploy. With this shortcut, the Update Files dialog box does not appear unless the files are not found.

To modify the contents of a WAR file you follow the preceding steps. The Update Files operation checks to see if any files have changed, including HTML files and JSP pages. If you change the index.jsp file ofConverterApp, be sure to type ant converter. The converter task copies the index.jsp file from the src to the build directory.

Adding a File


To add a file to the EJB JAR or WAR of the application, perform these steps.

  1. In deploytool, select the JAR or WAR in the tree.

  2. Select the General tab.

  3. Click Edit.

  4. In the tree of the Available Files field, locate the file and click Add.

  5. Click OK.

  6. From the main toolbar, select ToolsUpdate And Redeploy.


Modifying a Deployment Setting


To modify a deployment setting of ConverterApp, you edit the appropriate field in a tabbed pane and redeploy the application. For example, to change the JNDI name of the ConverterBean from ATypo toMyConverter, you would follow these steps.

  1. In deploytool, select ConverterApp in the tree.

  2. Select the JNDI Names tab.

  3. In the JNDI Name field, enter MyConverter.

  4. From the main toolbar, select FileSave.

  5. Select ToolsUpdate And Redeploy.

No comments:

Post a Comment