Java Reference
In-Depth Information
L
ISTING
7.13
Continued
public void remove(String clientHost) throws RemoteException {
//removes it from the repository
repository.remove(clientHost);
System.out.println(“ServerRepositoryImpl - removed: “+clientHost);
}
/**
* Server Repository Main
*/
static public void main(String[] args) {
try {
ServerRepositoryImpl sri = new ServerRepositoryImpl();
} catch (Exception e) {
System.err.println(“main(): “ + e.toString() );
7
}
}
}
The
ServerRepositoryImpl
server implements the remote
ServerRepository
interface (for
brevity, we do not list it here). Its implementation is simple and rather fragile. Note that the
ServerDeploylet
repository is implemented with a
HashMap
instance. See the following RMI
recommendations before launching this server class.
For simplicity, we didn't implement server-to-client communication, which is needed to com-
plete the communication flow between the client and the server deploylet. Thus, the deploy-
ment-related communication is only unidirectional—from client to server—and not all the
invocation sequences detailed in Table 7.1 are implemented. For example, see the commented
client invocation at line 51 of Listing 7.11.
Setting Up the Deployment Circuit and Executing the Code
As you have seen, implementing a full-fledged, complete deployment circuit over a real-world
network environment is not that simple. Before Java, it would have taken not a single chapter,
but a whole topic to describe it.
We have employed several Java technologies to implement this framework:
• The Plug-In technology, to provide full-fledged J2SE applet support. If you have run the
previous example successfully, you don't need to do other configuration settings on your
JRE (this example, too, needs to have unrestricted security access).
•A Web server that features a servlet container able to run our
LaunchServlet
. We used
Tomcat. For details on how to set up such a servlet container (that acts as a basic Web
server, too), see Chapter 12, “Server-Side Deployment Support.”