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 sections of the IBM RAD 7 pdf that apply to
us who are using Eclipse are under the following
headings.


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

Java in general and applications developed to the
J2EE specification use zip files under names such
as jar, war and ear files depending on which part
of the enterprise application they represent.

All these archives files described are compressed files
that use the compression scheme invented Phil  Katz,
(PKZip) who donated the compression scheme to the
public domain. Jar, tar and zip files all use this
compression scheme.

Following is the overall component package of
an EAR file, called an 'Enterprise Application
Resource'  but is also known as an 'Enterprise
Archive File.'

You will note that Eclipse is saving all your work
in just such a directory system, ready to package
when needed.

SubComponents of EAR Files
// Enterprise Application Resource Files


Simplified Diagram of the Enterprise Application Resource

// Enterprise Archive File

  EAR
   |__0+_WAR(s)
   |     
|__0+_JAR(s)
        |
   |__0+_RAR(s)
   |     
|__0+_JAR(s)
   |
   |__0+_JAR(s)

  
// each has it's own XML descriptor

Each of these major compressed container files has
it's own specially named XML descriptor file and may
additionally hold other 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 a J2EE
server such as 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:

WAR Files

WAR files are typical sub-components of an EAR file.
Web archive (WAR) files contain the components used
by a deployable web application. These components
may include the following.


Web Application Components


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



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.

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 project // from Eclipse Documentation

To delete a project and remove its contents from the file system:

  1. Select the project in one of the navigation views.
  2. Click Delete on the pop-up menu.
  3. In the dialog which opens select ' Also delete contents under..'
  4. Click Yes.

To delete a project from the workspace without removing
its contents from the file system:

  1. Select the project in one of the navigation views.
  2. Click Delete on the pop-up menu.
  3. In the dialog which opens select Do not delete contents.
  4. Click Yes.

Project Interchange Files

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:
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.



Eclipse Projects


The following is summary of the wizards listed in the
new project window of Eclipse. Each wizard creates
an empty project. This includes the the structures, files,
folders, supporting libraries, and references needed
to support the 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.

A sub-project of the Java Project is one built on an
Ant Buildfile.
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
The following are sub-projects of the EJB Project

JPA, Java Persistence API
// http://en.wikipedia.org/wiki/Java_Persistence_API


Entities
A persistence entity is a lightweight Java class that typically represents a table in a relational database. Entity instances correspond to individual rows in the table. Entities typically have relationships with other entities, and these relationships are expressed through object/relational metadata. Object/relational metadata can be specified directly in the entity class file by using annotations, or in a separate XML descriptor file distributed with the application.

The Java Persistence Query Language
The Java Persistence Query Language (JPQL) is used to make queries against entities stored in a relational database. Queries resemble SQL queries in syntax, but operate against entity objects rather than directly with database tables.

// reference site: http://www.eclipseplugincentral.com


Available for Eclipse But Need to be Added
// other project types can be found

// refer to http://eclipse.org/birt/phoenix/project


Application Developer J2EE Projects

Eclipse 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 Eclipse 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
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:
Following is a quick list of other features the web
project wizard supports.

Features Supported by the Web Project Wizard
"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:
// More in Chapter 12, “Develop Web applications . . ."


EJB Project


EJB projects contain the resources for EJB
applications, including:
The wizard allows configuring:
// 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:

 Java Project


A Java project contains:
The associated Java builder:
Java projects are used for:
// 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 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:
A configuration may include:
// 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:
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.

Otherwise make selections and click Finish.


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:

In the Properties dialog most project attributes can
be edited. Different types of projects have different
options available.

Enterprise Application Project Options:



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.