Package net.jini.core.discovery

Examples of net.jini.core.discovery.LookupLocator


            throws MalformedURLException {

        DistributedMasterBuilder masterBuilder = new DistributedMasterBuilder();

        final LookupLocator[] unicastLocators = new LookupLocator[] {
                new LookupLocator(DistributedMasterBuilderTest.JINI_URL_LOCALHOST)
        };

        final Entry[] entries = SearchablePropertyEntries.getPropertiesAsEntryArray(
                new SearchablePropertyEntries(testUserPropsFilename).getProperties()
        );
View Full Code Here


        return ("Hello World from MyService!");
    }

    public static void main (String[] args) {
        RoomLight myServer;
        LookupLocator lookup;
        ServiceRegistrar registrar;
        ServiceItem serviceItem;

        try {
/*        Set the security manager to allow the RMI class loader
          to go to the codebase for classes that are not available
          locally.  */

        System.setSecurityManager (new RMISecurityManager ());

/*      Create the attributes (an array of entry objects) that describe this
        server and use it to register this server with the lookup service.
        JoinManager finds and registers with the lookup service */

        Entry[] attr = new Entry[2];
        attr[0] = new Name("Neon Light");
        attr[1] = new ServiceInfo("Name", "Manufactor", "vendor","version","model","serial");
        myServer = new RoomLightNeon ();
        serviceItem = new ServiceItem(null, myServer, attr);

        lookup = new LookupLocator ("jini://localhost");
        registrar  = lookup.getRegistrar();
        registrar.register(serviceItem, Lease.FOREVER);

        System.out.println("Serrrrrrrrrrvice Ready ...");

        } catch (Exception e)
View Full Code Here


public class RoomLightTest {
     public static void main (String[] args) {
          Entry[] aeAttributes;
          LookupLocator lookup;
          ServiceRegistrar registrar;
          ServiceTemplate template;
          RoomLight myRoomLight;

          try {
  /*          Set the security manager to allow the RMI class loader to access
              the codebase for classes that are not available locally */

              System.setSecurityManager (new RMISecurityManager ());

  /*          Find the Jini lookup service (reggie) and print its location */

              lookup = new LookupLocator ("jini://localhost");

  /*          Get the lookup service's ServiceRegistrar and perform a search to find
              the service that has the name attribute name of "HelloWorldServer".
              The lookup service returns an Proxy object to the service */

              registrar  = lookup.getRegistrar();
              aeAttributes = new Entry[2];

              aeAttributes[0] = new Name("Neon Light");
              aeAttributes[1] = new ServiceInfo("Name", "Manufactor", "vendor","version","model","serial");
             
View Full Code Here

    protected void addItems(String[] items) {
      LookupLocator[] locs = new LookupLocator[items.length];
      for(int i = 0; i < items.length; i++) {
  try {
    locs[i] = new LookupLocator(items[i]);
  } catch (MalformedURLException e) {
    JOptionPane.showMessageDialog(LocatorLister.this,
          "\"" + items[i] + "\": " +
          e.getMessage(),
          "Bad Locator",
View Full Code Here

       */     
      pending = new CheckGroupsMarker(ann);
        }
    } else if (groupsOverlap(ann.getGroups())) {
        // newly discovered
        pending = new LookupLocator(ann.getHost(), ann.getPort());
    }
      }
      if (pending != null) {
    try {
        ann.checkConstraints();
View Full Code Here

                                ServiceRegistrar[] regs = e.getRegistrars();
                                logger.finest(eType+" event  -- "+regs.length
                                                                +" lookup(s)");
                                Map groupsMap = e.getGroups();
                                for(int i=0;i<regs.length;i++) {
                                    LookupLocator loc = null;
                                    try {
                                        loc = regs[i].getLocator();
                                    } catch (Throwable ex) { /* ignore */ }
                                    String[] groups =
                                             (String[])groupsMap.get(regs[i]);
View Full Code Here

      unicaster.start();
      unicastPort = port;
      myLocator = (proxy instanceof RemoteMethodControl) ?
    new ConstrainableLookupLocator(
        myLocator.getHost(), unicaster.port, null) :
    new LookupLocator(myLocator.getHost(), unicaster.port);
      synchronized (announcer) {
    announcer.notify();
      }
      addLogRecord(new UnicastPortSetLogObj(port));
      if (logger.isLoggable(Level.CONFIG)) {
View Full Code Here

  myRef = (Registrar) serverExporter.export(this);
  proxy = RegistrarProxy.getInstance(myRef, myServiceID);
  myLocator = (proxy instanceof RemoteMethodControl) ?
      new ConstrainableLookupLocator(
    unicastDiscoveryHost, unicaster.port, null) :
      new LookupLocator(unicastDiscoveryHost, unicaster.port);
  /* register myself */
  Item item = new Item(new ServiceItem(myServiceID,
               proxy,
               lookupAttrs));
  SvcReg reg = new SvcReg(item, myLeaseID, Long.MAX_VALUE);
View Full Code Here

        }
        maybeAddNewRegistrar(resp);
    } else if(req instanceof LookupLocator) {
        // Perform unicast discovery using the LookupLocator
        // host and port.
        LookupLocator loc = (LookupLocator)req;
        UnicastResponse resp = new MultiIPDiscovery() {
      protected UnicastResponse performDiscovery(
              Discovery disco,
              DiscoveryConstraints dc,
              Socket s)
          throws IOException, ClassNotFoundException
      {
          return doUnicastDiscovery(s, dc, disco);
      }
      protected void singleResponseException(Exception e,
                     InetAddress addr,
                     int port)
      {
          logger.log(
        Levels.HANDLED,
        "Exception occured during unicast discovery " +
        addr + ":" + port, e);
      }
        }.getResponse(loc.getHost(),
              loc.getPort(),
              rawUnicastDiscoveryConstraints);
        maybeAddNewRegistrar(resp);
    } else if(req instanceof CheckGroupsMarker) {
        // handle group changes
        announcement = ((CheckGroupsMarker)req).announcement;
        ServiceID srvcID = announcement.getServiceID();
        UnicastResponse resp = null;
        synchronized (registrars) {
      resp = (UnicastResponse)registrars.get(srvcID);
        }
        if(resp != null) {
      maybeSendEvent(resp, announcement.getGroups());
        }//endif
    } else if(req instanceof CheckReachabilityMarker) {
        // test reachability
        response = ((CheckReachabilityMarker)req).response;
        maybeSendEvent(response, null);
    }//endif
      } catch (InterruptedIOException e) {
    logger.log(Levels.HANDLED,
         "exception occurred during unicast discovery",
         e);
      } catch (Throwable e) {
    if (((req instanceof Socket) ||
        (req instanceof LookupLocator)) &&
        logger.isLoggable(Level.INFO)) {
        String logmsg =
      "exception occurred during unicast discovery to " +
      "{0}:{1,number,#} with constraints {2}";
        String methodName = "run";
        if (req instanceof Socket) {
      Socket sock = (Socket) req;
      LogUtil.logThrow(logger,
           Level.INFO,
           this.getClass(),
           methodName,
           logmsg,
           new Object[] {
              sock.getInetAddress().getHostName(),
              new Integer(sock.getPort()),
              rawUnicastDiscoveryConstraints
           },
           e);
        } else {
      LookupLocator loc = (LookupLocator) req;
      LogUtil.logThrow(logger,
           Level.INFO,
           this.getClass(),
           methodName,
           logmsg,
           new Object[] {
              loc.getHost(),
              new Integer(loc.getPort()),
              rawUnicastDiscoveryConstraints
           },
           e);
        }
    } else {
View Full Code Here

  item.setEnabled(false);
  menu.add(item);
    }

    private void addOne(ServiceRegistrar registrar) {
  LookupLocator loc;
  try {
      loc = registrar.getLocator();
  } catch (Throwable t) {
      logger.log(Level.INFO, "obtaining locator failed", t);
      return;
  }
  String host = loc.getHost();
  if (loc.getPort() != Constants.discoveryPort)
      host += ":" + loc.getPort();
  JRadioButtonMenuItem reg =
      new RegistrarMenuItem(host, registrar.getServiceID());
  reg.addActionListener(wrap(new Lookup(registrar)));
  if (!(registrars.getMenuComponent(0)
        instanceof JRadioButtonMenuItem))
View Full Code Here

TOP

Related Classes of net.jini.core.discovery.LookupLocator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.