This subsection uses examples to describe the procedure for implementing the JavaBeans resources.
This section describes the required settings and notes when you use the server management commands (cjimportjb command) to import the JavaBeans resources.
Create the JavaBeans resource property file keeping the following points in mind:
An example of settings for the JavaBeans resource property file is as follows:
<!DOCTYPE hitachi-javabeans-resource-property PUBLIC '-//Hitachi, Ltd.//DTD JavaBeans Resource Property 7.0//EN' |
The template file (jb_template.xml) of the JavaBeans resource property file is stored in the following directory:
Cosminexus-installation-directory\CC\admin\templates
By using the -d option during an import operation, the JavaBeans resources can be imported with the same directory configuration and without creating an archive. Specify the top directory to be imported as the directory to be specified in -d.
An example of specifying the -d option when you import a JavaBeans resource is as follows. In this example, the "MyJavaBean" class with package name "com.mycompany.mypackage" is imported.
Directory-specified-in--d\ |
The -d option imports all the files existing beneath the specified directory, so do not include unnecessary files in the directory.
You declare the method for operating the data (property) managed by JavaBeans. To register the data, specify the set method (set + property-name). To reference the data, specify the get method (get + property-name).
An example implementation of the class that registers and references the JavaBeans resource is as follows:
package com.mycompany.mypackage; |
This section describes the implementation and definitions required in an application when you use the JavaBeans resources.
You obtain a JavaBeans resource by using lookup or DI. This section describes how to look up with the java:comp/env format.
Context initCtx = new InitialContext(); |
Like other resources, the range of JavaBeans resource lookup is the application in the same J2EE server process.
To use lookup to obtain a JavaBeans resource, you define the information on the name to be looked up and the implementation class name in the DD (ejb-jar.xml or web.xml). The tags to be specified are as follows:
Also, when you deploy a created application on the J2EE server, bind the reference name in lookup and the actual name with linked-to. To execute this operation, use the server management commands (cjsetappprop command).
The following is an example of the <resource-env-ref> tag in the property file passed by cjsetappprop:
<resource-env-ref> |
You start or terminate an application that uses a JavaBeans resource with the server management commands or Management Server. For details on how to start an application, see 10.2.1 Starting J2EE applications in the uCosminexus Application Server Application Setup Guide. For details on how to terminate an application, see 10.2.2 Stopping J2EE applications in the uCosminexus Application Server Application Setup Guide.
Application Server provides a sample program for JavaBeans resources. For an overview and the execution method of the sample program, see Appendix M.6 Sample program for JavaBeans resources in the uCosminexus Application Server System Setup and Operation Guide.