FileDocCategorySizeDatePackage
ConvertClient.javaAPI DocExample3423Thu Mar 16 11:52:24 GMT 2000None

ConvertClient

public class ConvertClient extends Object

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

        System.setSecurityManager(new RMISecurityManager());

        // Find the service by its interface type
        ServiceFinder sf = new ServiceFinder(ConvertService.class);
        ConvertService cs = (ConvertService) sf.getObject();

        LeaseRenewalManager lrm = new LeaseRenewalManager();

        // Sign up to be notified of all conversions
        RemoteEventListener rel = new ConvertEventHandler();
        EventRegistration er = cs.trackConversions(Lease.FOREVER, rel, null);
        lrm.renewUntil(er.getLease(), Lease.FOREVER, null);

        // Administer the service registration object
        JoinAdmin joinadmin = null;
        // See if it has a join admin object
        if (cs instanceof Administrable) {
            Object admin = ((Administrable) cs).getAdmin();
            if (admin instanceof JoinAdmin)
                joinadmin = (JoinAdmin) admin;
        }
        // It it does, print out its attributes
        if (joinadmin != null) {
            Object[] attrib = joinadmin.getLookupAttributes();
            for (int i = 0; i < attrib.length; i++)
                System.out.println("Attribute: " + attrib[i]);
        }

        // Now do a conversion for ourself
        ConvertServiceRegistration csr = cs.getInstance(Lease.FOREVER);
        lrm.renewUntil(csr.getLease(), Lease.FOREVER, null);

        // Now invoke methods on the service object
        System.out.println(csr.convert(5));

        // We'll sit here, waiting forever for other event notifications
        // to happen.
        try {
            Thread.sleep(Integer.MAX_VALUE);
        } catch (InterruptedException ie) {}

        // If you want to exit, you should clean up the leases first, e.g., 
        // lrm.cancel(er.getLease());
        // lrm.cancel(csr.getLease());
        // System.exit(0);