Java Reference
In-Depth Information
For brevity, we didn't list the whole servlet code for the creation of the HTML page (see the
ellipsis in the
doGet
method). It is important to know that the servlet embeds in the OBJECT
tag (needed for the Plug-In support) a special applet parameter (“
name
”), whose value is used
by the client deploylet applet to look up its related server-side deploylet (such a value is
fetched by the client deploylet at line 33 in Listing 7.10). For more details on the embedded
code produced by the
LaunchServlet
,see the source code provided on the Companion Web
site for this topic.
The
deployletRepositoryLookup
method (starting at line 39 of Listing 7.12) performs the
RMI server lookup, and it is invoked during servlet initialization. Afterward, when a Web
browser requests the
AccountApplet
page (in this simple implementation, the
LaunchServlet
serves only such an applet independently from the client's request parameters), the servlet pre-
pares the HTML page, and requests the
ServerRepositoryImpl
RMI server to create a new
ServerDeploylet
instance (line 27).
7
We used servlet technology here (rather than other, better-suited server-side technologies such
as JSP) because it was used extensively throughout all the rest of the topic.
In Listing 7.13, the
ServerRepositoryImpl
class is shown. This class implements a simple
RMI-based management server for centralizing
ServerDeploylet
s control. It is required to be
successfully running when the
LaunchServlet
is requested for an applet Web page.
L
ISTING
7.13
The
ServerRepositoryImpl
Class
package com.marinilli.b2.c7.deploylet;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.util.*;
/**
* Chapter 7 - ServerDeploylet manager server
* Don't forget: -Djava.security.policy=<full path to new policy file>
*
* @author Mauro Marinilli
* @version 1.0
*/
public class ServerRepositoryImpl extends UnicastRemoteObject implements
ServerRepository{
private HashMap repository = new HashMap();
/**
* Constructor
*/