WSAD5 entry

zhaozj2021-02-16  48

WSAD5 entry

First, the start of the workbench:

First, learn about the hierarchy of WSAD: Workbench -> Perspective (Perspective) -> WorksSpace -> Engineering (Project). The workbench is the general name of the entire development of the integrated environment, and it is used to the use of different roles to be organized into different perspective, such as the J2EE perspective, Java perspective, etc. Through the use of perspective, the Web developer, Java programmer, EJB developers, and administrators share the same development tools, but also focus on their own tools. The toolbar and right-click menu in different perspective are different. In order to perform an action, you must find the correct position of the correct perspective. Although some operations can be implemented in several perspectives, execution is performed in one perspective, such as new Java packets, can be implemented in a web perspective and Java perspective, But it is more convenient to achieve in the latter. Workspace is composed of many projects and their shared resources. Its organizations have corresponding to the underlying directory structure of the document system. After the WSAD creation project, you can be in the workspace directory (default in WSAD 5.0) "WSAD installation directory -> Workspace", and allow you to modify when started) Find the corresponding directory structure, if you want to successfully change the file system to work space, in the resource perspective, right-click the project name, Select "Refresh". The project may be a summary of all related resources for your actual project. Generally, you can choose different engineering types according to the actual situation of your own project. In addition, in the Workspace directory, there is a directory ".Metadata" that stores the log file, you can get the WSAD log information by files such .log and loggingutil.log, which will be large for your debugging. A concept similar to the help and hierarchy is the engineering directory structure, which indicates how the elements in the project are organized in WSAD. Figure 2 is a J2EE view including a typical enterprise application engineering with an EJB module, a web module, which we can clearly see that the second needs of WSAD's directory structure is server engineering. For the convenience of debugging, the feature of Test JSPS, Servlets, HTML, and EJBs is available in WSAD. You can test the completed part of the completed part at this time that the server acts as analog to the final deployment environment. You can use a variety of ways to implement this test, such as using WSAD 5.0's built-in WebSphere Version 5.0 test environment or Apache Tomcat test environment. This can be specified when creating a new server instance and configuration. Server engineering consists of server instances and server configurations, server configuration represents some configuration information related to the server, such as port information, data source information, and the like. The server instance represents the specific test server associated with the server, such as whether you can set whether the server instance allows JavaScript debugging. Server configuration and server instances are one-to-many relationship, you can specify different server configurations for server instances, in order to test your project, you must add your project to a specific server configuration. After installing WSAD5, if you don't do anything else, start WSAD5, there will be a workshop selected window, developers can choose the path you interested in. There is a selection box below, as shown below:

If you select the following selection box, you will enter the default work path next time. In this way, if you want to change the working path, you must modify the start shortcut: In the shortcut target box, in the last plus -showlocation -data . Second, create a project

1. Create "Enterprise Application": In the J2EE Hierarchy view, right-click Enterprise Applications, select "New-> Enterprise Application Project", as follows:

Select "Create J2EE1.3 Enterprise Application Project" in the pop-up window, click "Next". Then fill in the relevant options, as shown below:

If you do not choose to create additional additional modules in the Creating Enterprise Applications, you can create the same method in the "J2EE Hierarchy". No longer accumulate

2. Creating EJBs up soon in real-world development, often based on the original system or has developed a good database, then the creation method from the bottom up is good to meet your requirements. The steps are: First: Create an EJB project, you can click on the J2EE Hierarchy view. Step 2: Create a connection to the database. Click on the perspective -> Data, as shown below:

This opens "Data Perspective". Click Right-click on the blank area in the "Database Server" in the lower left, select "New Connection", as follows:

In the pop-up window, fill in the corresponding content, as shown below:

After completing, the results are as follows:

After selecting the table to create an EJB, click Right-click, select "Import to Folder", as shown below:

After filling in the corresponding content, as shown below:

This completes the preparation of the database. Make sure the above is successful. Back to "J2EE Hierarchy", right click in the EJB project to create EJB, select "Generate -> Mapping from EJB to RDB", as shown below:

In the pop-up window, keep the default settings, click Next, as shown below:

In the next step, it can only be "bottom up", so click Next, as shown below:

Fill in the package in the last step is OK, as shown below:

The creation of "Since the top" EJB is completed.

This is generated "Local Client View", if you want to generate "Remote Client View", you can double-click the appropriate EJB and control it by "Add" or "Remove" in the "EJB Deployment Descriptor". EJB's Find and SELECT methods and transactions can increase in the "EJB deployment descriptor".

3, manually created the bean, then associated with the table in the database: First, create a bean. In the J2EE Hierarchy, right-click the EJB project under "EJB module", select "Enterprise Bean", as shown below:

Select the EJB project in the pop-up window, click Next, as shown below:

In the next step, the corresponding filing is performed, as shown below:

In the next step, select the remote or local client view as needed, and add the CMP attribute, as shown below: It is completed.

Refer to the "Create Database Connection" to create a connection to the database and import it into the folder of the corresponding EJB project. Back to "J2EE Hierarchy". Right-click the EJB project, select "Generate -> Mapping from EJB to RDB", as shown below

Switch to the J2EE view, in the J2EE VIEW window, right-click the EJB project we created, select [Generate] / [From EJB to RDB Mapping], select [Use the existing backend folder] mode in the pop-up window. Click [FINISH] to establish a mapping.

On the left

J2EE VIEW

At the bottom of the window, you can click "

J2EE

Navigator tab, switch to "

J2EE

Navigator window mode. In the project

META-INF

Find in the catalog

Map.mapxmi

Item, double-click open mapping editor, as shown below:

First on the left "enterprise

bean

"The window is selected in the window."

Company

of

Entity Bean

, Then on the right

"

table

"

Right-click on the form of the same name, select [Match Match by Name], establish a mapping, the result is as follows:

This completes the first EJB and database connections, and then realize the mapping of both.

4. Establish service selection "Open Perspective -> Other -> Server". Switch to the service perspective. In the Server Configuration view, right-click the Services folder, select New => Service => Server and Server Configuration. As shown below:

This will open the Create New Server and Server Configuration wizard, as shown below:

enter"

server nickname

","

folder

","

Server type

(

Expand

WebSphere Version 5

And choose

test environment

)

"And keep all other values ​​for default. After the server and server configuration are created, the item is added to the server, as shown below:

In the lower right window, select the Server tab, right-click the server you want to start, select Start, so you can start the server. As shown below:

5, establish a data source and deploy double-click the established server, select the Security tab, as shown below:

Create a Jaas (Java Authentication and Authorization Extension) alias, as shown below:

Switch to the "Data Source" card, as shown below:

in"

JDBC

Provider list selection

DB2JDBCDRIVER

Drive, in the "Data Source" area defined in the JDBC provider selected above, click the [Add] button, add

Data Source

, As shown:

The first step is the default selection, the next step, as shown below:

Enter the name, JNDI name, and "Component Manage Other Name (E)", "The Human Care Alias ​​(L)" of the Container Manage (L) "set ERPDB alias (which is the alias created in JASS), and make sure" Use this Data Source (O) "check box in Persistence (CMP) of Container Management (O) check box is selected, and the rest is set. Click Next, enter DatabaseName: as shown below:

Add resource characteristics: The resource feature that needs to be set is related to the database selected. DB2 does not have to process, if it is Oracle to add:

name:

DatabaseName Type:

Java.lang.string value: SHDV (replace with your own database name)

"Equired" checkbox: Select

with

name:

URL type:

Java.lang.string value:

JDBC: Oracle: Thin: @ 192.168.0.137: 1521: SHDV It is similar to JDBC: Oracle: Thin: @serverip: 1521: Database_name, where ServerIP is the machine IP address where the Oracle database is located, Database_name is the database name.

Required

Check box: Select

Set the default data source of the EJB container:

Select the EJB tab to set the "provincial data source" to "DB2DATASOSOURCE" (DB2DataSource is just added). As shown below:

Bind the CMP Bean with the data source just configured:

If you run the project on the server at this time, you will find that there is an error, that is, you have not specified the actual data source for the CMP bean. The Bean container naturally cannot map the Bean persistent field to the actual table field, so The last step is required, here we complete the binding by setting the data source JNDI name. In WSAD 5.0, you can set a default data source JNDI name for the entire EJB module, so that each bean in the module will use the JNDI name. Go to the J2EE perspective, open the corresponding EJB project with "Deploy Descriptor Editor", such as CompanyEJB, and select "Overview" tab, find one "JNDI - CMP Builder Connection Bind" in the lower right of the page. Set the JNDI name to JDBC / Erpdb (that is, the JNDI name set in the server configuration is set). As shown below:

In addition, the JNDI name can be set separately to each bean to cover the default settings. Select the "Beans" tab, select the bean you need to set, and find the "WebSphere Bind" on the right side, set the "CMP container generation JNDI name" to a specific JNDI name. As shown below:

6. Publish and Test In the Server tab, right click on the service you want to publish, select "Publish", as shown below:

Start the service and run the general test client with the same method. As shown below:

转载请注明原文地址:https://www.9cbs.com/read-28178.html

New Post(0)