1. Trang chủ
  2. » Công Nghệ Thông Tin

WebSphere Studio Application Developer Version 5 Programming Guide part 12 docx

10 261 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 217,89 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

There are two types of Web projects: ? Static Web project ? J2EE Web project A static Web project contains only static content such as HTML pages or images, and any associated metadata..

Trang 1

Web project

A Web project contains resources needed for Web applications, such as source files and metadata, that correspond to the hierarchy of files necessary to deploy

a Web page or Web application There are two types of Web projects:

򐂰 Static Web project

򐂰 J2EE Web project

A static Web project contains only static content such as HTML pages or images, and any associated metadata In addition to static content, J2EE Web projects can contain additional kinds of resources for Web applications, including servlets, JSP files, and Java files J2EE Web projects incur more system overhead because of additional validation and Java compilation that is automatically performed by the Workbench A Web project is deployed as a WAR file

A step-by-step description of how to create a new Web project is provided in

“Creating a Web project” on page 185 Also, some detailed information regarding the structure of a Web project is given in “Web project directory structure” on page 190

Struts project

With Application Developer Version 5, a Web project with Struts support can be created Such a project is tailored to provide an organization suitable for Struts development, including the Struts runtime, configuration file, a Web diagram editor, and wizards to create Struts components

Refer to Chapter 10, “Developing Struts applications” on page 293 for details about Struts and the support in Application Developer

EJB project

Enterprise JavaBeans (EJB) projects contain the resources for EJB applications The EJB project contains the metadata files (such as the deployment descriptor, IBM extensions, and RDB mappings) for the EJB application, Java source files, compiled code for the enterprise beans, and stubs for the beans An EJB project

is deployed as an EJB JAR file

EJB projects allow you to organize your enterprise beans logically As you develop EJB applications in the Workbench, your source and output files are kept in the ejbModule folder of the EJB project As you make changes and generate deployment code, the Java classes are compiled into the ejbModule

Trang 2

Application Client project

Application Client projects contain the resources needed for application client modules An application client module is used to contain a full-function client Java application (non Web-based) that connects to and uses the J2EE resources defined in your server

When you place the client code in an application client module instead of a simple JAR file, the application client benefits from the server's resources (it does not need to re-specify the class path to J2EE and server JAR files), as well as benefiting from easier JNDI lookup (the server fills in the initial context and other parameters) The application client project allows you to work as if you are creating a standalone Java application in a Java project

An application client project enables you to do the following things:

򐂰 Develop the Java classes that implement the client EJB module

򐂰 Set the application client deployment descriptor

򐂰 Test the application client When creating a new Application Client project, you can choose between these two project types:

򐂰 J2EE 1.2 Application Client project

򐂰 J2EE 1.3 Application Client project Application client projects allow you to organize your client applications logically

As you develop client applications in the Workbench, your source files will be kept in the appClientModule folder of the application client project and the binary files will be kept in the bin folder

Refer to “Building an application client module” on page 614 for an example

Server project

A Server project stores information about test and deployment servers and their configurations To test an EJB or Web project, you have to define a server with a server configuration to publish and run the code Servers identify where you can test your projects, and server configurations contain setup information

See the section “Creating a Server project” on page 519 in Chapter 15, “Servers and server configurations” on page 513 for a detailed instruction of how to create

a Server project and a server

Trang 3

Creating a new project

You normally start developing a new application by creating one or more projects The Workbench provides wizards to create each specific type of project

As we work with a number of projects in this book, we provide more detailed information regarding the creation of projects in the appropriate chapters For now we only want to demonstrate how to launch the new project wizard by selecting File -> New -> Project from the menu bar The New Project wizard is shown in Figure 4-3

Figure 4-3 New Project wizard

In this example we select the Enterprise Application Project, which is categorized

as a J2EE project Depending on what project you choose in the New Project dialog, Application Developer shows a tailored dialog after clicking Next

In general (it differs, depending on what type of project is created), when you create a new project, you have to specify the following:

򐂰 Name—Project name (we will use ItsoProGuideXxxxx)

򐂰 Location—By default projects are store in the workspace directory, but

another location may be specified

򐂰 Organization—Directories for source and compiled files (unless this is

dictated by J2EE standards)

Trang 4

򐂰 Build path—Projects, folders, and JAR files that have to be in the build path

For some project types this can only be changed after the project has been created

After creation of a project, the appropriate perspective opens and displays a view

of the project

Project properties

To make changes to the definition of a project, select the project and Properties

from the context menu Figure 4-4 shows the properties dialog for a Web project

Figure 4-4 Project properties

In the properties dialog you may want to change:

򐂰 Java Build Path—Project dependencies and JAR files

򐂰 Server Preference—Which test server to start when testing the project

򐂰 Validation—What validation tools should run after making changes

򐂰 Web—J2EE level, context root, and tag libraries

Trang 5

Using templates to create application projects

Application Developer provides an Application Template Wizard that creates projects containing complete model applications based on application templates

An application template is the skeleton of an application It includes the entire application and may be either fully configured or may have certain parts that remain to be specified The Application Template Wizard guides you through a step-by-step process where you can easily specify the parameters required by the template to generate the desired application This enables users with minimal

or no programming skills to quickly build a fully operational application based on simple wizard guided settings

The Application Template Wizard currently includes a small set of pre-defined templates Each available template stores a description of an application along with customized settings that enable wizard-driven specification of parameters and automatic code generation that will produce a complete operational application

Running the Application Template Wizard

To generate a template-based application, select File -> New -> Other -> Web -> Template Application The Application Template Wizard (or Template Application Wizard) opens as shown in Figure 4-5:

򐂰 There are three sets of templates to choose from:

– Solution Templates—provides four template applications (see

Figure 4-5)

– IT Templates—provides two template applications: List - Details, Login – Tutorial—provides one template application: Shopping Cart

򐂰 To create an application, select a template and progress through the dialog

򐂰 Depending on the template, you have to configure the application in a variable number of steps, providing information for properties, data sources, titles, and Web page content A sample dialog for the Self Service Insurance template is shown in Figure 4-6

򐂰 In the Application Developer Help you can find a tutorial for the Shopping Cart template

򐂰 A future update to Application Developer will deliver a Template Builder that enables users to create there own templates

Trang 6

Figure 4-5 Template wizard: template selection

Figure 4-6 Template wizard: example

Configure each step in the list while progressing through the wizard.

Trang 7

In this chapter we described the type of projects provided by Application Developer for the development of J2EE applications

We also touched briefly on the Application Template Wizard

Trang 8

Part 2 Developing

applications

Part 2 describes how to develop applications These chapters are provided:

򐂰 Developing Java applications

򐂰 Developing database applications

򐂰 Developing Web applications

򐂰 Developing Web applications with database access

򐂰 Developing applications with stored procedures

򐂰 Developing XML applications

򐂰 Developing EJBs

򐂰 Developing Web services

򐂰 Developing Struts applications

򐂰 Developing GUI applications

Part 2

Note: See Appendix C, “Additional material” on page 809 for instructions on

how to download the sample code and set up the database that is used in our examples In addition, see “Installing DB2 UDB” on page 786 for instructions

on how to enable JDBC 2.0

Trang 10

Chapter 5. Developing Java

applications

This chapter provides an introduction in the Java development capabilities of the Application Developer The chapter is divided into four major sections:

򐂰 Creating and working with a Java project—This section demonstrates how to create and work with a Java project A simple Java class that reads a DB2 database table to retrieve information about customers is used

򐂰 Preparing a utility project—This section shows how to prepare a utility project that is available to multiple modules of an enterprise application

򐂰 Programming assists—This section describes the main Java programming assist features and capabilities of Application Developer

򐂰 Javadoc—This section explains how to generate Javadoc for a project or a set of packages

The sample Java code used in this chapter is provided in the directory:

\sg246957\sampcode\dev-java

5

Ngày đăng: 03/07/2014, 20:20

TỪ KHÓA LIÊN QUAN