Bootstraping using Discovery Protocol

In this example the client program will bootstrap itself by loacting a service on the network using the Object Multicast feature of the ORB.

1 Client

Instead of using the COS Naming, the client conjures up the multicast object reference "out of thin air" using the Group.getObjref API. Using this object reference, it then, locates the "hello" service on the net.

package discovery2;
                                                                           
import util.Util;
                                                                           
import java.util.Hashtable;
import java.net.InetAddress;
                                                                           
import javax.naming.Context;
import javax.naming.InitialContext;
                                                                           
import org.omg.CORBA.ORB;
                                                                           
import com.sssw.jbroker.api.multicast.Group;
                                                                           
import discovery.Discoverable;
import discovery.DiscovererImpl;
                                                                           
public class Client
{
    public static void main(String[] args)
    {
    |   try {
    |   |   // create the jBroker ORB
    |   |   ORB orb = ORB.init(args, null);
    |   |                                                                  
    |   |   // create the Group
    |   |   Group group = Group.createGroup(orb, InetAddress.
    |   |       getByName("230.0.0.1"), "discover");
    |   |                                                                  
    |   |   // get object reference of type Discoverable
    |   |   Discoverable discoverable = (Discoverable) group.createObjref(
    |   |       Discoverable.class);
    |   |                                                                  
    |   |   // discover hello object(s)
    |   |   discoverable.discover("hello", new DiscovererImpl());
    |   |                                                                  
    |   } catch (Exception ex) {
    |   |   ex.printStackTrace();
    |   }
    }
}
Copyright © 2000-2003, Novell, Inc. All rights reserved.