New York
University
Computer
Science Department
Courant
Institute of Mathematical Sciences
Course Title: Application Servers Course
Number: g22.3033-011
Instructor: Jean-Claude Franchitti Session:
4
1. Ongoing
Project Background
This homework follows the course on-going project approach described in the homework #1 specification. You should keep enriching your framework-based enterprise application design, and take advantage of the application server platforms used to implement/deploy your application. Your application should be developed in such a way as to be shielded as much as possible from the underlying software infrastructure. For that reason, it is a good idea to build your applications around a portable application framework. As portability issues arise, you will learn how to improve the design of your applications to make them more portable across application server platforms.
2.
Introduction to Distributed Object Computing Platforms
Distributed Object Computing platforms such as
CORBA, RMI, and DCOM are designed to hide complex "plumbing" issues
from corporate users, software suppliers, and system integrators. Java
application interoperability was initially accomplished via Remote Method
Invocation (RMI) technology. RMI was extended to become compatible with the
Internet Inter-ORB Protocol (IIOP) and the newer technology is referred to as
RMI/IIOP. Later on, JavaSoft released JavaIDL which makes it possible to bridge
the gap between interface specifications put together using the Object
Management Group (OMG) Interface Definition Language (IDL) and Java application
stubs. To relate to the aforementioned technology, and understand its role in
the Application Server technology domain, this homework extends the simple
Application Server configuration developed in the first homework to operate on
top of RMI technology.
The goal of the homework is to deploy the
framework-based application developed as part of homework #1 on top of a
distributed object computing platform, and extend it to make use of services
provided by such platforms. You will study two different application
architectures as part of this exercise. The first architecture involves a
combination of TCP/IP and RMI (ORB) components. The second architecture only
involves RMI (ORB) components. These simplistic client/server implementations
will show how easy it is to build sophisticated web applications on top of
distributed computing platforms.
2.1. Software Infrastructure Provided:
1.
Environment
used for homework #1 (as needed)
2.
Other
development tools best suited for distributed computing platform development
environments (as identified in homework #4a)
3.
All
the application software needed for this homework is contained in an archive
posted on the course Web site under demos. The distribution archive contains
programs for the two types of architectures described earlier in this section.
1.
A
small CGI Client program which could be written in any language. This program
connects via TCP/IP to the main application program described in the following.
2.
A
main application program that performs template parsing and routes object requests
(i.e., AppServer.java).
3.
An
Application Server which is multithreaded and is written in Java (i.e.,
OBJExec.java). This program acts as a remote “object proxy” that performs
naming lookup for object references and remote method calls. The object proxy communicates
via RMI (ORB) with two other application servers as described below.
4.
Two
Application Servers (StockServer.java and CustomerServer.java). StockServer
uses Stock.java as a remote interface, and StockImpl.java as a remote object
implementation. Similarly, CustomerServer.java uses Customer.java as a remote
interface, and CustomerImpl.java as a remote object implementation.
Model 2 is made up of the following components:
1.
A
CGIRMIClient which connects via RMI (ORB) to the application servers.
CGIRMIClient.java performs template parsing and route object requests.
2.
An
Application Server which is multithreaded and is written in Java (i.e.,
OBJExec.java). This program acts as a remote “object proxy” that performs
naming lookup for object references and remote method calls. The object proxy
communicates via RMI (ORB) with two other application servers as described
below.
3.
Two
Application Servers (StockServer.java and CustomerServer.java) as per the
previous described architecture.
Templates (some files must be placed
in the same directory where AppServer has been started)
1.
Login.html
2.
Main.html
3.
Screen1.html
4.
Screen2.html
Additional
Sample Applications
1.
No
additional sample applications are provided for this homework
2.2. Installing and Running the Homework Software Infrastructure:
Note: A machine with a dedicated
IP address is required to test Model 1 and Model 2 from a browser. If you do
not have a dedicated IP address (e.g., dialup connection), the CGIRMIClient
will need to be run as an application.
1.
Make
sure that a web server is installed on your machine (the following uses use the
Apache Web server on Windows for illustration purpose):
ü Download and install the
Apache Web server distribution as needed
ü Get the hostname of your
machine by either:
§
Running
ipconfig /all from the DOS command line
§
Getting
into the Network - Identification tab under Settings - Control Panel
ü Obtain the IP address of
your machine by either:
§ Running ipconfig /all from the DOS command line (the subnet mask, and the gateway IP will also be needed)
§
In
the case of Win 95/98, use the IP provided by your ISP and configured under
Settings - Control Panel - Network - TCP/IP - IP Address
ü Set the
"ServerName" variable in the "httpd.conf" file located
under Apache Group\Apache\conf to the hostname of your machine
ü Disable the DHCP IP
resolution, and specify the actual machine IP address (can run "ipconfig
/release" from a command prompt under Windows when starting Apache from
the command line)
ü Start the Apache Server from
the Apache Program Group
ü Test the Apache Server via
your preferred browser (you will need to disable Proxy)
2. Development Directory Setup:
ü Place all the source files in the directory:
"Apache Group\Apache\src\examples\AppServer"
ü The source files archives can be downloaded from the class Web site.
ü The name of the archive for homework #4 is "g22_3033_011_appsrv4.zip"
3.
Take
a look at the comments in the Java and template (HTML) files to understand how
they work
4.
Modify
ObjExec.java to use the correct machine name for the RMI lookup statements
5.
Modify
the HTML files to use the correct machine name and port in the HTML FORM tags
6.
Set
the CLASSPATH variable to contain:
ü
c:\jdk1.3\lib;
(or appropriate version of JDK as needed)
ü
c:\Program
Files\Apache Group\Apache\distribution\myclasses;
To do so, follow the appropriate instructions below:
ü Win NT/2000: Set the
CLASSPATH variable via Settings|Control Panel|System|Environment
ü Win 95/98: Modify the "autoexec.bat" file to set the CLASSPATH variable (will need to restart all DOS windows, so they can see the global change in path. As an alternative, you can issue the following command in a particular DOS command line window prior to using it for Step 7 below:
"set CLASSPATH=%CLASSPATH%;c:\jdk1.2.1\lib;
c:\progra~1\apache~1\apache\distribution\myclasses;"
7.
Compile
the source code from the src\examples\AppServer directory:
ü Create the directory
distribution\myclasses under the Apache root directory
ü Run the following
compilation commands:
javac -d
..\..\..\distribution\myclasses Stock.java StockImpl.java
javac -d
..\..\..\distribution\myclasses Customer.java CustomerImpl.java
javac -d
..\..\..\distribution\myclasses AppServer.java OBJExec.java
javac -d
..\..\..\distribution\myclasses CGIRmiClient.java
This creates the distribution\myclasses directory under the Apache root directory. Note that the various servers are built separately to illustrate which files are required for each of them (a global build is also possible by running "java" on all ".java" files). The separate build will not work properly if Step 6 has not been followed (i.e., CLASSPATH variable must be properly set up).
8.
Generate
skeletons and stubs from the src\examples\AppServer directory:
ü
rmic
-d ..\..\..\distribution\myclasses examples.AppServer.StockImpl
ü
rmic
-d ..\..\..\distribution\myclasses examples.AppServer.CustomerImpl
This will create the following files in the
directory ..\..\..\distribution\myclasses
ü
StockImpl_Stub.class
ü
StockImpl_Skel.class
ü
CustomerImpl_Stub.class
ü
CustomerImpl_Skel.class
The stub/skeleton layer is the interface between the Stock, and Customer client/server applications and the RMI system. The rmic compiler generates proxy classes that act as remote object placeholders. Client applications use stubs that correspond with server-side skeletons. RMI dynamically downloads stubs on demand to make them available as needed on the client machines.
9.
Run
the Registry
ü
Win
2000/NT: "start
rmiregistry" or "rmiregistry &"
ü
Win
95/98: rmiregistry
ü Clients will look up the
server name in the registry to establish remote references. In order for remote
clients to invoke methods (e.g., StockServer.getStock( ) ) on the server, the
server must first bind its name to the registry. This will be done in step 12.
10.
Copy
the java.policy file from the jdk1.2\jre\lib\security directory into src as a
new file called "policy"
11.
Add
the following section to the "grant {" portion of the policy file) to
open up permissions:
// Allow
everything for now
permission
java.security.AllPermission;
// Allow
anyone to connect, and accept connections on port 80 and on
permission
java.net.SocketPermission "localhost:80-65535",
"connect,accept";
Note 1: "localhost" or "*" are
ok in the above line.
Note 2: with NotePad/WordPad, make sure that the
file is saved without the .txt extension.
12.
Start
the StockServer and CustomerServer from the "src" directory:
ü
java
-Djava.rmi.server.codebase=http://host/distribution/myclasses/
-Djava.security.policy=policy
examples.AppServer.StockImpl hostname
ü
java
-Djava.rmi.server.codebase=http://host/distribution/myclasses/
-Djava.security.policy=policy
examples.AppServer.CustomerImpl hostname
13.
Place
the main.html, screen1.html, and screen2.html templates in the
"myclasses\examples\AppServer" subdirectory
The templates can be found
in the src\examples\AppServer as part of the earlier installation.
14.
To
test the RMI connection to the StockServer, run the CGIRMIClient as an
application from the "src" directory:
ü
java
-Djava.rmi.server.codebase=http://host/distribution/myclasses/
-Djava.security.policy=policy
examples.AppServer.CGIRmiClient main.html
A message should be returned to CGIRmiClient by
StockServer as follows:
"Stock Price : IBM 140 CSCO 103 EMC 117"
3. Questions
1.
Preparation
phase:
Architecture 1:
(1) Start the AppServer on port 7777 as follows
java
examples.AppServer.AppServer 7777
AppServer should be started
from the directory where the main.html,
screen1.html, and screen2.html are located (see step 13 above).
Note: there is no need for AppServer in Architecture #2.
(2) Copy "login.html" in the Apache Server
document root directory (htdocs)
(3) Copy "cgimodule.pl" from homework #1
into the Apache Server cgi-bin directory
Note that the first line of
the cgimodule.pl should be changed to #!/perl5/bin/perl
(it should point to the path
of the perl program on your machine as for homework #1). Also note that the
"host name" listed in the "cgimodule.pl" script should be
changed to reflect the hostname of the machine on which AppServer is running.
(4) Invoke http://host/login.html
(5) You should be able to cycle through the various
templates starting from login.html
Architecture 2:
(1) Shutdown AppServer if it is currently running.
(2) Suggest a way to call CGIRmiClient directly upon
request from a client browser.
(3) You should be able to invoke
htpp://host/login.html, and cycle through the templates.
2.
Prepare
a short report documenting your refined framework-based enterprise application
(using software engineering standards), and explaining its motivation.
3.
Prepare
a short report including functional diagrams and screenshots (as needed) to
demonstrate your understanding of the infrastructure software. Explain the
infrastructure software differences between the application you developed in
homework #1-#3 and the one you are developing for this homework.
4.
Develop
and deploy your framework-based enterprise application as follows. You must pick
at least two platforms (i.e., among RMI-IIOP, CORBA, and DCOM), and any
additional work beyond these two platforms will be treated as extra credit:
5. Explain how you would refine the “analyzer” tool you started designing in homework #1-#3 to capture information about the new version of your application deployed on top of the various DOC platforms, and re-deploy it as an XML-based web application such as: (a) the “SpyWeb” application provided as support material under demo programs on the course website, and (b) the Cocoon 2 XSP framework. Note that the target application should again maintain a strict separation between content, style, and logic. As for homework #1-#3, your analyzer should strive to extract and represent a generic model of your application using a suitable markup language.
6.
Extra
Credit: Implement a prototype of the analyzer tool described in question 5.
5.
Deliverables
6. Grading
All assignments are graded on a maximum scale of 10 points. Your grade will be based equally on:
a.
The
overall quality of your documentation.
b.
The
understanding and appropriate use of application server related technologies.
c.
Your
ability to submit working and well-commented code.
d.
Extra
credit may be granted for solutions that are particularly creative.
Please let the TA know as
soon as possible about teaming arrangements. You will need to stay with the
same team for the duration of the course. You should only submit one report/archive
per team for each assignment. To balance things out, the final grading in the
course will take into account the fact that you are working as a team instead
of individually, so you should feel free to work individually as well. Note
that the final take home examination will require individual work.