Java Reference
In-Depth Information
Note that applet-related lifecycle methods (namely start , stop , and init ) are declared final ,
so that client subclasses are forced to implement the Deploylet interface's corresponding
methods. At line 30 of Listing 7.10, the connection with the ServerDeploylet is created and
the logging service is initialized during the init method. After that, the initApplication
method of the ClientDeploylet subclass is invoked for performing business code applet ini-
tialization, as reported in Listing 7.8. The stop method implementation is similar (starting at
line 54).
In Listing 7.11, the ServerDeploylet class is listed. For simplicity, we kept the server-side
deploylet pretty simple. We didn't subclass it or override its lifecycle methods for providing
some special deployment functionalities on the server side.
L ISTING 7.11 The ServerDeploylet Class
package com.marinilli.b2.c7.deploylet;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.io.*;
import java.util.*;
/**
* Chapter 7 - ServerDeploylet
*
* The server-side of the Deploylet interface.
*
* @author Mauro Marinilli
* @version 1.0
*/
public class ServerDeploylet extends UnicastRemoteObject implements Deploylet {
private Deploylet client;
private String serverDeployletName;
/** constructor */
public ServerDeploylet(String deployletName) throws RemoteException {
if (System.getSecurityManager() == null) {
System.out.println(“new RMISecurityManager()”);
System.setSecurityManager(new RMISecurityManager());
}
try {
String name = “//localhost/deploylet/” + deployletName;
Naming.rebind(name, this);
System.out.println(“ServerDeploylet bound with name \””+name+”\””);
serverDeployletName = name;
} catch (Exception e) {
Search WWH ::




Custom Search