FileDocCategorySizeDatePackage
Client.javaAPI DocExample3066Wed Apr 19 11:20:22 BST 2000examples.activation

Client

public class Client extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


	String server = "localhost";
	if (args.length < 1) {
	    System.out.println ("Usage: java Client <rmihost>");
	    System.exit(1);
	} else {
	    server = args[0];
	}

	// Set a security manager so that the client can 
	// download the activatable object's stub
	//
	System.setSecurityManager(new RMISecurityManager());

	try {

	    String location = "rmi://" + server + "/ActivatableImplementation";

	    // Since you can't create an instance of an interface, what we get 
	    // back from the lookup method is a remote reference to an object
	    // that implements MyRemoteInterface.
	    //  
	    // Then we cast the remote reference (serialized stub instance)
	    // returned from Naming.lookup to a "MyRemoteInterface" so we can
	    // call the interface method(s).    
            //         
	    MyRemoteInterface mri = (MyRemoteInterface)Naming.lookup(location);
	    System.out.println("Got a remote reference to the object that" + 
		" extends Activatable.");

	    // The String "result" will be changed to "Success" by the remote 
	    // method call
	    //
	    String result = "failure";
	    System.out.println("Making remote call to the server");

	    result = (String)mri.callMeRemotely();
	    System.out.println("Returned from remote call");
	    System.out.println("Result: " + result);

	} catch (Exception e) {
		e.printStackTrace();
	}