Projects
Peter Komisar © Conestoga
College version 1.1 Fall / 2007
Reference:
Third Draft Document for Review, Sept. 17,2007,
SG24-7501-00 'Rational Application Developer V7 Programming
Guide'.
This is a synopsis
of information found in the fifth chapter,
''Projects' found in the third draft Document for Review, dated
September 17, SG24-7501-00 Rational Application Developer
V7 Programming Guide. It has been prepared for private
academic purposes and is not an effort to publish the contained
material.
Any anonymous
quotes are from the
above noted reference.
J2EE Containment Architecture
The projects chapter in the IBM pdf is organized
under the following headings.
- J2EE architecture
- Project basics
- Rational Application Developer projects
- Creating a new project
- Project properties
- Rational Application Developer samples
J2EE
Architecture
"The Java 2 Platform Enterprise Edition (J2EE) is a
highly available, reliable, scalable, and secure platform
for developing web and client-server applications in
Java."
//
examples are based on J2EE1.4
J2EE
Containment System // J2EE Modules
All the archives files described are compressed files
that use the compression scheme developed by Phil
Katz, (PKZip). Jar, tar and zip files all use this compression
scheme.
The overall containment scheme is described in the
diagram in Figure 5-1 on page 151 of the IBM PDF
and is represented by the contents of the EAR file.
SubComponents of EAR Files
//
Enterprise Application Resource Files
- and 0 or more
- Resource Adapter Archive (RAR Files)
- Application Client Resource (JAR Files)
- EJB Resource (JAR Files)
- Web Application Resource (WAR Files)
- Utility Java Library (JAR File)
Each of these major compressed container files has
it's own specially named XML descriptor file and may
also hold standard JAR files containing Java classes.
Following are details regarding each archive type.
EAR Files
An Enterprise archive (EAR) files is used to hold
a J2EE application that may be deployed to WebSphere
Application Server. EAR files are standard Java archive
files that conform to a defined directory and file structure.
Application.xml
An EAR (.ear) file contains a deployment descriptor called
'application.xml'. This XML file describes the application's
content and holds instructions for running and deploying the
application.
The instructions include security settings and references to
Web applications contained within the application resource.
As noted earlier, the EAR file may include zero or more of
the following:
- Web modules—Packaged in a WAR file (.war)
- EJB modules—Packaged in an EJB JAR file (.jar)
- Application client modules—Packaged in a JAR file (.jar)
- Resource adapter modules—Packaged in a RAR file (.rar)
- Utility JAR files required by other modules—Packaged in a JAR
file (.jar)
WAR
Files
Web archive (WAR) files contain the components
used by a deployable web application. These
components may include the following.
Web Application Components
- HyperText Markup Language (HTML) files
- Cascading style sheets (CSS) files
- JavaServer Pages (JSP) files
- Compiled Java servlet classes
- Other compiled Java classes
- Image files
- Portlets (portal applications)
web.xml
The WAR file deployment descriptor is called 'web.xml'. It
describes how to deploy the components packaged within
the Web module and to map incoming Web requests to
the correct resources.
EJB
JAR files
An EJB JAR file is used to package EJB classes and
interfaces.
ejb-jar.xml
The EJB JAR deployment descriptor is called ejb-jar.xml.
It describes how the EJBs should be deployed.
J2EE
Application Client JAR files
A J2EE Application Client is also packaged in a
JAR file. The file
includes user interface files that
run
on a client machine and access resources
supplied by a J2EE server. This would include such
things as data sources, security services, and EJBs.
application-client.xml
The deployment descriptor that comes with the
client's JAR file is called application-client.xml.
RAR Files
The RAR, or Resource Access archive is used
to package J2EE resource adapters that access
back-end resources. The adapter uses services
provided by an application server to manage the
lookup of the resource and to
manage connections.
//
similar to JDBC drivers or CORBA Orb lookups
Resource adapters are often provided by vendors
of enterprise information systems, (EIS) to provide
access mainframe resources or non-Java applications.
The resource adapter may be installed as a stand-alone
module on the server so that it can be shared among
several applications. It can also come as a dedicated
part
of an enterprise application, available only to the
associated application and it's modules.
"The RAR file includes the
Java classes, providing the
Java-side of the resource adapter, and
platform-specific
code, providing the back-end connection functionality.
ra.xml
The deployment
descriptor for the RAR is called ra.xml.
Other Names for J2EE Resource Adapters
- Java 2 Connectors (J2C)
- J2EE Connector Architecture (JCA)
- J2EE Resource Adapter (RA)
Projects
Projects Basics
All resources are organized into projects. The project
contains the files, folders and properties required for
the application under construction.
Different kinds of projects can be created for
different applications as will be listed shortly.
Unless otherwise specified, projects are stored in
the Application Developer workspace directory.
Deleting
Projects
On deleting a workspace, RAD/Eclipse offers the
following choices.
- "Also delete contents under <directory>" or
- "Do not delete contents"
Selecting the second option which is the default, removes
the project from Rational Application Developer’s list of
projects, but leaves the file structure of the project intact.
These projects can later be imported by selecting:
Importing Projects
File → Import → General → Existing Projects Into Workspace.
A project that has been deleted from the workspace
takes up no memory and is not examined during builds,
so deleting projects in this way can improve the
performance of Application Developer.
Deleting
projects
// from Eclipse Documentation
To delete a project
and remove its contents from the file system:
- Select the project
in one of the navigation views.
- Click Delete on the pop-up menu.
- In the dialog which opens select Also delete contents
under ....
- Click Yes.
To delete a project
from the workspace without removing its contents from the file system:
- Select the project
in one of the navigation views.
- Click Delete on the pop-up menu.
- In the dialog which opens select Do not delete contents.
- Click Yes.
Project
Interchange File
Projects can be transferred between Workspaces
in the form of project interchange files. This is a zip
file that encapsulates the project.
Creating a Project Interchange File
Select File → Export → Other → Project Interchange
--> specify which projects to export and the location.
Importing projects Into a Workspace
Select File → Export → Other → Project Interchange
Note
"When exporting and importing a project, the project
interrelationships are also transferred but not the
referenced
projects; it may also be necessary to
export all related projects."
Closing
Projects
Closing projects locks their contents so they cannot
be edited. Other projects cannot reference
any of the
resources inside them.
This is done from the Project Explorer context menu
using either:
- the Close Project or
- Close Unrelated Projects
Closed
projects remain in the Project Explorer view,
but they cannot be expanded. Closing non-important
projects can speed up compilation times as the
underlying application builders only have to check
for resources in open projects.
Closed
projects can be re-opened by selecting
Open Project from Project
Explorer.
Rational
Application Developer Projects
The following is summary of the wizards listed in the
text for RAD 7. "Each wizard will create an empty
project of the specified type with the structures, files,
folders, supporting libraries, and references to support
such a project. Once created, it is still possible to change
aspects of the project through the project properties."
Invocation
of Wizards
Use File → New → Project
→ Select the appropriate project Wizard.
- Project
(General)
- simplest, just a collection of files and folders.
- no builders,
- useful for projects with no application code
- for example a project to store xml files
- Report Project
// BIRT
- (Business Intelligence and Reporting tools
- a Java open source reporting system
- has facilities to combine database information
- or content from XML into report templates.
//
refer to http://eclipse.org/birt/phoenix/project
- Crystal
Reports Web Project
- Creates a Web project
- with Crystal reports features activated.
- includes the Java Reporting Component libraries
- and support for Crystal Reports Viewer pages
//
Crystal reports must be selected on installation
// of Application Developer for this
to be available.
- User Function
Library (Crystal Reports)
- similar to a Java project but with links
- to the Crystal Reports Java libraries.
- Projects from
CVS
- wizard guide creating a new project
- by checking out an existing project within CVS.
- It is possible to check-out a complete project
- from CVS, or to create a new project as part
- of the check-out process.
- Data Design
Project
- creates a project to store data design artifacts
- including data designs
- data models
- and SQL statements.
- Data
Development Project
- a project that stores a connection to a database
- allows creation of resources
- to query & modify the associated database.
- Initially folders are created to store
- SQL scripts & stored procedures.
- Existing
RAD6.x Data Definition Project
- "The tooling which supports database definitions
has
changed since Application Developer V6.0.X and V5.1.2.
- data project with database definitions or objects
created
- in the Data definition view from previous versions of
RAD
must be migrated to work with V7.0."
- This wizard migrates an old format project folder to
V7.0.
- EMF Project
(Eclipse Modeling Framework)
- creates a new Java project based on an imported model
- either XML, Ecore, UM, or Rose class model.
- The new project includes the model documents
- has facilities to generate Java code from them.
- EJB
Project //
more details below under J2EE projects
- creates a project for containing EJBs.
- creates an empty EJB deployment descriptor
- associates the project with
- a containing
enterprise application project.
- Application
Client Project (J2EE) //
more details below
- creates an empty Application Client project
- prompts for the associated
EAR project and
- facets applicable for J2EE Application Client
projects.
- Connector
Project (J2EE) //
more details below under J2EE projects
- creates a J2EE connector project,
- prompts for associated enterprise application project and
- a set of facets applicable to it.
- Enterprise
Application Project (J2EE) //
more details below
- Creates a new EAR project.
- includes options for creating associated
- Web
- EJB &
- Application
Client
- Utility
Project (J2EE) //
more details below under J2EE projects
- Assists in the construction of a Java utility
library project
- prompts for associated Enterprise Application project.
- The product is a JAR file
- it is wrapped into the EAR file
on export
- Java Project
- Simple wizard for a Java project
- allow specifying the class path
- including project dependencies.
- Java Project
from Existing Ant Buildfile
- Given an Ant build file;
- the wizard create a new project based on it.
To export the
build settings of a project as an Ant file use
the following.
Exporting Build Settings as an
Ant File
Export → Export → General →
Ant Buildfiles
//
from the Project Explorer
- Jython Project
- Creates an empty project for developing Jython
resources.
- Plug-in
Development
- Feature Patch
- Feature Project
- Fragment Project
- Plug-in from
existing JAR archives
- Plug-in and
- Update Site Project (Plug-in development)
- wizards for creation of Eclipse plug-ins,
- to enhance existing Eclipse or RAD
- perspectives or create new perspectives.
//
reference site: http://www.eclipseplugincentral.com
- SIP Project
(Session Initiated Protocol Project)
- The
SIP protocol, extend J2EE servlets API
- for telecommunications apps such as VOIP
- creates a Web
project for constructing SIP applications
- Dynamic Web
Project
- a project for a Web application,
- which
may include
- JSPs,
- servlets, and
- other dynamic content.
- Static Web
Project
- a project for a Web application
- containing
only
- images
- html files
- other static Web resources.
Application Developer J2EE Projects
RAD 7 complies with the J2EE specifications for developing
enterprise and Web applications. This is a significant statement
and means that J2EE applications developed in this environment
will be portable and be able to run on any J2EE compliant
web or application server.
J2EE Packaging Happens at Export
The 'packaging rules' which were imaged earlier when
the J2EE containment hierarchy was described, are applied
by RAD 7 only when a J2EE application or module is
exported.
When being worked, applications and modules are stored
as projects within the workspace. RAD manages the migration
of the project into the J2EE package. For example, an enterprise
application is packaged as an .ear file.
Following is a diagram that shows the relationship between
the project and the J2EE module and it's associated archive
file type.
Project Mapping To Module Types
Enterprise
Application
Project |
→ → → |
→ |
Enterprise
Application
Resource |
EAR
File |
|
|
|
|
|
|
|______
|
|
Connector
Project |
→ |
Resource
Adapter Archive |
RAR
File |
|______
| |
Utility
JAR Project |
→ |
Utility
Java Library |
JAR
File |
|______
| |
Web
Project |
→ |
Web
Application Resource |
WAR
File |
|______
| |
Java
Project |
→ |
Standard
Java Archive |
JAR
File |
|______
| |
EJB
Project |
→ |
EJB
Resource |
JAR
File |
|______
|
Application
Client Project |
→ |
Application
Client Resource |
JAR
File |
Each of the J2EE Projects are further discussed in text
as summarized below.
Enterprise Application Project
Enterprise Application projects contain all the
resources needed for enterprise applications.
They can contain references to a combination of
- Web modules
- EJB modules
- application client modules
- resource adapter modules
- utility Java projects
- and JAR files.
These relationships can be specified when 'wizarding'
a new Enterprise Application project or through the
project properties
//
more info in Chapter 16
J2EE
Application Client project
J2EE Application Client projects contain the
resources needed for J2EE application client
modules. A client Java application is understood
to be a standalone application that is not web-
based which connects to a J2EE enterprise
application via an
application server.
EJBs and data sources are referenced via a
naming services such as JNDI, or Java Naming
and Directory Interface.
//
Chapter 17, Building J2EE Application Clients
Dynamic Web Project
A dynamic Web project contains resources
needed for Web applications. These are
elements such as JSPs, Java Servlets,
HTML and other files.
The project
wizard is used to configure:
- the version of the Java Servlet
specification
- target server
- EAR file name and context root.
Following is a quick list of other features the web
project wizard supports.
Features
Supported by the Web Project Wizard
- A CSS file
- Struts support
- A Web diagram
- JSP tag libraries
- Web page templates
- Struts support
- JSP support
"By
selecting the appropriate facets it is possible
to create a project which uses Struts
or Java Server
Faces as a framework for building a web application."
//
Chapter 12,
“Develop Web applications . . . "
Static Web Project
A static Web project, containing only static Web
content, (HTML, images, sounds, movies etc.) need
only a web server, and not need a J2EE application
server.
The wizard allows:
- the project CSS file to be selected
- a Web
page template can be
//
More in Chapter12,
“Develop Web applications . . ."
EJB Project
EJB projects contain the resources for EJB
applications, including:
- EJB classes and interfaces
- the module's deployment descriptor
- IBM extensions and bindings files
- files with entity-to-database mappings
The wizard allows configuring:
- the EJB version
- the target server
- the containing EAR
file
- a series of applicable EJB facets
- An EJB
Client JAR
//
more in Chapter 16, “Develop Web applications using EJBs”
Connector
Project
A connector project contains the resources required
for a J2EE resource
adapter. The wizard allows setting:
- a set of facets
- including the JCA version
- // J2EE Connector
Architecture
- the containing EAR file
Java Project
A Java project contains:
The associated Java builder:
- incrementally compiles
Java source files
- can export class files as JAR files
- into directory structure.
Java projects are used for:
- stand-alone applications or
- to build utility
JAR files for enterprise applications.
//
more on Chapter 7, “Develop
Java applications”
Creating a new
Project
A new application is normally started by building one
or more projects in the
RAD/Eclipse workspace. The
projects should be planned first. Then the wizards can
be used to create skeleton project sets.
For example to create a new
Enterprise application
project, the 'New Enterprise
Application' wizard is used.
Launching the New Enterprise
Application Wizard
Select File → New → Project
Select J2EE → Enterprise Application
Project.
// see pdf for a
picture or run. Websphere Studio,
// Eclipse J2EE version or RAD 7.
On the first page you can specify:
- Name
- Project contents
- By default, a workspace subdirectory for the project
- // another location can be specified
- Target Runtime
- Enterprise apps will run on an Application Server.
- allows the user to configure the target runtime
- Configuration
- A drop down providing a list of saved configurations
A configuration may include:
- a specific set of features
- available versions
// a good idea --> all similar projects
should use the same configuration.
"An existing configuration can be chosen on this option or
<custom> can be selected which means that the user has
the opportunity to specify their own selections in the next
screen of the wizard."
Project Facet's Page
The second page is the 'Project Facets' page used to
customize which features and versions will be available
in the new project. Configurations can be saved and
used for subsequent projects.
The same facets page appears when creating a new:
- Web
- EJB &
- Connector project
but with facet options
applicable to the given project type
The Final Page
The final page allows the user to select any projects
that will be part of the enterprise application. "The
dialog includes select boxes for all Java, EJB, Web
and Application Client projects in the current workspace."
The 'Content Directory' Field
This field allows specifying a folder to store contents. If left
empty, content is stored under the root directory.
The 'New Module' Button
This button allows creating empty projects / modules within
the new Enterprise Application project.
- Click Cancel
- if you do not want to create any modules.
Otherwise make selections nad click Finish.
Clicking Finish again.
RAD may offer to switch you to the relevant perspective from
which the project was created.
Project
Properties
To make changes to the properties of a project:
- Right-click the project
- Select Properties from the context menu.
In the Properties dialog most project attributes can
be edited. Different types of projects have different
options available.
Enterprise Application Project
Options:
- J2EE Module
Dependencies
- other projects (Web, Java or Resource)
- this project depends on
- Project Facets
- facets available for addition or removal
- Project
References
- Configure project dependencies & classpaths.
- Server
- Specifies the default application server
- used for running
this application.
- Validation
- select to run non-default validation tools
- if so
which ones
- Java Build
Path // not for an enterprise app
- specify the build
path for compiling project Java code
Rational
Application Developer Samples
Rational Application Developer provides a large number
of sample applications. Standard Eclipse is very sparse
in this respect. Samples can be helpful in exploring the
the platform's features and to investigate the different types
of projects that can be created.
Two Methods to Access the
Gallery
- From Help →
- Main Menu → Samples Gallery option
- From the Welcome screen
- Click the Samples icon*
- →Click 'Launch the Samples Gallery'.
//
a grey circle with a yellow ball, blue cube and green pyramid
Samples
Gallery
The samples gallery lists all the samples available
on the Eclipse platform. At the time that the redbook
draft was written, there were 26 sample
applications
within Application Developer and 46 links to tutorial
topics within IBM
developer works. The standard
Eclipse distribution has only a few samples.
Samples are arranged in four main categories:
Showcase
Samples
Showcase Samples are extensive, containing
complete multi-tier, end-to-end applications that
follow best practices
for application development.
Application
Samples
Application samples are created using more than
one tool or API and show how different tools within
Rational Application Developer
interact with each
other.
Technology
Samples
Technology samples are smaller code-based
examples that focus on a single tool or API.
developerWorks
Samples
These samples are available via links to the IBM
developerWorks Web site. These would include the
most current samples and require Internet access.
//
the example shown in the pdf is the the Auction Web
// application is one of the Web
application
Samples can be selected from a hierarchical list in
the left-hand
pane.
Assignment
Recall that Java supplies AWT and Swing Components.
IBM introduces us to SWT components. Do the ' SWT Hello
World Example' supplied in Eclipse 3.3. You will need to
download the library as the instructions will tell you.
Screenshot the display of HelloWorld as it appears in the
SWT GUI.