Package info.walnutstreet.vs.ps05vt

Source Code of info.walnutstreet.vs.ps05vt.RoomLightTest

package info.walnutstreet.vs.ps05vt;

import java.rmi.RMISecurityManager;

import net.jini.core.entry.Entry;
import net.jini.core.discovery.LookupLocator;
import net.jini.core.lookup.ServiceRegistrar;
import net.jini.core.lookup.ServiceTemplate;
import net.jini.lookup.entry.Name;
import net.jini.lookup.entry.ServiceInfo;


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");
             
              template = new ServiceTemplate (null, null, aeAttributes);

              myRoomLight = (RoomLight) registrar.lookup (template);

              System.out.println (" ist das Licht an? ->" + myRoomLight.isOn() + "<-");
          } catch (Exception e) {
              System.out.println ("client: MyClient.main() exception: " + e);
          }
      }

}
TOP

Related Classes of info.walnutstreet.vs.ps05vt.RoomLightTest

TOP
Copyright © 2018 www.massapi.com. 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.