Ejemplo n.º 1
0
 public static void main(String[] args) {
   int status = 0;
   Ice.Communicator ic = null;
   try {
     // 初使化连接,args可以传一些初使化参数,如连接超时时间,初使化客户连接池的数量等
     ic = Ice.Util.initialize(args);
     // 创建名为SimplePrinterAdapter的适配器,并要求适配器使 用缺省的协议(TCP/IP侦听端口为10000的请求)
     Ice.ObjectAdapter adapter =
         ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
     // 实例化一个PrinterI对象,为Printer接口创建一个服务对象
     Ice.Object object = new PrinterI();
     // 将服务单元增加到适配器中,并给服务对象指定名称为 SimplePrinter,该名称用于唯一确定一个服务单元
     adapter.add(object, Ice.Util.stringToIdentity("SimplePrinter"));
     // 激活适配器,这样做的好处是可以等到所有资源就位后再触发
     adapter.activate();
     // 让服务在退出之前,一直持续对请求的监听
     ic.waitForShutdown();
   } catch (Ice.LocalException e) {
     e.printStackTrace();
     status = 1;
   } catch (Exception e) {
     System.err.println(e.getMessage());
     status = 1;
   } finally {
     if (ic != null) ic.destroy();
   }
   System.exit(status);
 }
Ejemplo n.º 2
0
  @Override
  public int run(String[] args) {
    args = communicator().getProperties().parseCommandLineOptions("Discover", args);

    Ice.ObjectAdapter adapter = communicator().createObjectAdapter("DiscoverReply");
    DiscoverReplyI replyI = new DiscoverReplyI();
    DiscoverReplyPrx reply = DiscoverReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI));
    adapter.activate();

    DiscoverPrx discover =
        DiscoverPrxHelper.uncheckedCast(
            communicator().propertyToProxy("Discover.Proxy").ice_datagram());
    discover.lookup(reply);
    Ice.ObjectPrx base = replyI.waitReply(2000);

    if (base == null) {
      System.err.println(appName() + ": no replies");
      return 1;
    }
    HelloPrx hello = HelloPrxHelper.checkedCast(base);
    if (hello == null) {
      System.err.println(appName() + ": invalid reply");
      return 1;
    }

    hello.sayHello();
    return 0;
  }
Ejemplo n.º 3
0
 public int run(String[] args) {
   Ice.Communicator communicator = communicator();
   Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
   Ice.Object object = new InitialI();
   adapter.add(object, communicator.stringToIdentity("initial"));
   adapter.activate();
   return WAIT;
 }
Ejemplo n.º 4
0
  @Override
  public int run(String[] args) {
    Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter");
    adapter.add(new MyClassI(), communicator().stringToIdentity("test"));
    adapter.activate();

    return WAIT;
  }
Ejemplo n.º 5
0
 @Override
 public int run(String[] args) {
   Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter");
   Ice.Object object = new TestI();
   adapter.add(object, Ice.Util.stringToIdentity("Test"));
   adapter.activate();
   return WAIT;
 }
Ejemplo n.º 6
0
  public synchronized Ice.ObjectPrx createAdmin(
      Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity) {
    if (Thread.interrupted()) {
      throw new Ice.OperationInterruptedException();
    }

    boolean createAdapter = (adminAdapter == null);

    synchronized (this) {
      if (_state == StateDestroyed) {
        throw new Ice.CommunicatorDestroyedException();
      }

      if (adminIdentity == null || adminIdentity.name == null || adminIdentity.name.isEmpty()) {
        throw new Ice.IllegalIdentityException(adminIdentity);
      }

      if (_adminAdapter != null) {
        throw new Ice.InitializationException("Admin already created");
      }

      if (!_adminEnabled) {
        throw new Ice.InitializationException("Admin is disabled");
      }

      if (createAdapter) {
        if (!_initData.properties.getProperty("Ice.Admin.Endpoints").isEmpty()) {
          adminAdapter = _objectAdapterFactory.createObjectAdapter("Ice.Admin", null);
        } else {
          throw new Ice.InitializationException("Ice.Admin.Endpoints is not set");
        }
      }

      _adminIdentity = adminIdentity;
      _adminAdapter = adminAdapter;
      addAllAdminFacets();
    }

    if (createAdapter) {
      try {
        adminAdapter.activate();
      } catch (Ice.LocalException ex) {
        //
        // We cleanup _adminAdapter, however this error is not recoverable
        // (can't call again getAdmin() after fixing the problem)
        // since all the facets (servants) in the adapter are lost
        //
        adminAdapter.destroy();
        synchronized (this) {
          _adminAdapter = null;
        }
        throw ex;
      }
    }
    setServerProcessProxy(adminAdapter, adminIdentity);
    return adminAdapter.createProxy(adminIdentity);
  }
Ejemplo n.º 7
0
  public Ice.ObjectPrx getAdmin() {
    if (Thread.interrupted()) {
      throw new Ice.OperationInterruptedException();
    }

    Ice.ObjectAdapter adminAdapter;
    Ice.Identity adminIdentity;

    synchronized (this) {
      if (_state == StateDestroyed) {
        throw new Ice.CommunicatorDestroyedException();
      }

      if (_adminAdapter != null) {
        return _adminAdapter.createProxy(_adminIdentity);
      } else if (_adminEnabled) {
        if (!_initData.properties.getProperty("Ice.Admin.Endpoints").isEmpty()) {
          adminAdapter = _objectAdapterFactory.createObjectAdapter("Ice.Admin", null);
        } else {
          return null;
        }
        adminIdentity =
            new Ice.Identity("admin", _initData.properties.getProperty("Ice.Admin.InstanceName"));
        if (adminIdentity.category.isEmpty()) {
          adminIdentity.category = java.util.UUID.randomUUID().toString();
        }

        _adminIdentity = adminIdentity;
        _adminAdapter = adminAdapter;
        addAllAdminFacets();
        // continue below outside synchronization
      } else {
        return null;
      }
    }

    try {
      adminAdapter.activate();
    } catch (Ice.LocalException ex) {
      //
      // We cleanup _adminAdapter, however this error is not recoverable
      // (can't call again getAdmin() after fixing the problem)
      // since all the facets (servants) in the adapter are lost
      //
      adminAdapter.destroy();
      synchronized (this) {
        _adminAdapter = null;
      }
      throw ex;
    }

    setServerProcessProxy(adminAdapter, adminIdentity);
    return adminAdapter.createProxy(adminIdentity);
  }
Ejemplo n.º 8
0
  public int run(String[] args) {
    if (args.length > 0) {
      System.err.println(appName() + ": too many arguments");
      return 1;
    }

    Ice.ObjectAdapter adapter = communicator().createObjectAdapter("ContactDB");
    adapter.add(new ContactDBI(), communicator().stringToIdentity("contactdb"));
    adapter.activate();
    communicator().waitForShutdown();
    return 0;
  }
Ejemplo n.º 9
0
 /** @param args */
 public static void main(String[] args) throws Exception {
   Ice.Communicator ic = null;
   try {
     ic = Ice.Util.initialize(args);
     Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("Demo", "default -p 2012");
     adapter.add(new CounterServiceI(), ic.stringToIdentity("Counter"));
     adapter.activate();
     ic.waitForShutdown();
   } finally {
     if (ic != null) ic.destroy();
   }
 }
Ejemplo n.º 10
0
  public int run(String[] args) {
    if (args.length > 0) {
      System.err.println(appName() + ": too many arguments");
      return 1;
    }

    Ice.Properties properties = communicator().getProperties();

    //
    // Create an object adapter
    //
    Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Library");

    //
    // Create an evictor for books.
    //
    Freeze.Evictor evictor =
        Freeze.Util.createBackgroundSaveEvictor(adapter, _envName, "books", null, null, true);
    int evictorSize = properties.getPropertyAsInt("EvictorSize");
    if (evictorSize > 0) {
      evictor.setSize(evictorSize);
    }

    adapter.addServantLocator(evictor, "book");

    //
    // Create the library, and add it to the object adapter.
    //
    LibraryI library = new LibraryI(communicator(), _envName, "authors", evictor);
    adapter.add(library, communicator().stringToIdentity("library"));

    //
    // Create and install a factory for books.
    //
    Ice.ObjectFactory bookFactory = new BookFactory(library);
    communicator().addObjectFactory(bookFactory, Demo.Book.ice_staticId());

    //
    // Everything ok, let's go.
    //
    adapter.activate();

    shutdownOnInterrupt();
    communicator().waitForShutdown();
    defaultInterrupt();

    library.close();
    return 0;
  }
Ejemplo n.º 11
0
  public ImportLibrary(
      OMEROMetadataStoreClient client,
      OMEROWrapper reader,
      FileTransfer transfer,
      List<FileExclusion> exclusions,
      int minutesToWait) {
    if (client == null || reader == null) {
      throw new NullPointerException("All arguments to ImportLibrary() must be non-null.");
    }

    this.store = client;
    this.transfer = transfer;
    if (exclusions != null) {
      this.exclusions.addAll(exclusions);
    }
    this.minutesToWait = minutesToWait;
    repo = lookupManagedRepository();
    // Adapter which should be used for callbacks. This is more
    // complicated than it needs to be at the moment. We're only sure that
    // the OMSClient has a ServiceFactory (and not necessarily a client)
    // so we have to inspect various fields to get the adapter.
    sf = store.getServiceFactory();
    oa = sf.ice_getConnection().getAdapter();
    final Ice.Communicator ic = oa.getCommunicator();
    category = omero.client.getRouter(ic).getCategoryForClient();
  }
Ejemplo n.º 12
0
  public int run(String[] args) {
    if (args.length > 0) {
      System.err.println(appName() + ": too many arguments");
      return 1;
    }

    Ice.ObjectFactory factory = new ObjectFactory();
    communicator().addObjectFactory(factory, Demo.Printer.ice_staticId());

    Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Value");
    Ice.Object object = new InitialI(adapter);
    adapter.add(object, communicator().stringToIdentity("initial"));
    adapter.activate();
    communicator().waitForShutdown();
    return 0;
  }
Ejemplo n.º 13
0
  private void setServerProcessProxy(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity) {
    Ice.ObjectPrx admin = adminAdapter.createProxy(adminIdentity);
    Ice.LocatorPrx locator = adminAdapter.getLocator();
    String serverId = _initData.properties.getProperty("Ice.Admin.ServerId");

    if (locator != null && !serverId.isEmpty()) {
      Ice.ProcessPrx process = Ice.ProcessPrxHelper.uncheckedCast(admin.ice_facet("Process"));
      try {
        //
        // Note that as soon as the process proxy is registered, the communicator might be
        // shutdown by a remote client and admin facets might start receiving calls.
        //
        locator.getRegistry().setServerProcessProxy(serverId, process);
      } catch (Ice.ServerNotFoundException ex) {
        if (_traceLevels.location >= 1) {
          StringBuilder s = new StringBuilder(128);
          s.append("couldn't register server `");
          s.append(serverId);
          s.append("' with the locator registry:\n");
          s.append("the server is not known to the locator registry");
          _initData.logger.trace(_traceLevels.locationCat, s.toString());
        }

        throw new Ice.InitializationException(
            "Locator knows nothing about server `" + serverId + "'");
      } catch (Ice.LocalException ex) {
        if (_traceLevels.location >= 1) {
          StringBuilder s = new StringBuilder(128);
          s.append("couldn't register server `");
          s.append(serverId);
          s.append("' with the locator registry:\n");
          s.append(ex.toString());
          _initData.logger.trace(_traceLevels.locationCat, s.toString());
        }
        throw ex;
      }

      if (_traceLevels.location >= 1) {
        StringBuilder s = new StringBuilder(128);
        s.append("registered server `");
        s.append(serverId);
        s.append("' with the locator registry");
        _initData.logger.trace(_traceLevels.locationCat, s.toString());
      }
    }
  }
Ejemplo n.º 14
0
  public int run(String[] args) {

    Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter");
    adapter.addServantLocator(new AMDServantLocatorI("category"), "category");
    adapter.addServantLocator(new AMDServantLocatorI(""), "");
    adapter.add(new AMDTestI(), communicator().stringToIdentity("asm"));
    adapter.add(new AMDTestActivationI(), communicator().stringToIdentity("test/activation"));
    adapter.activate();
    return WAIT;
  }
Ejemplo n.º 15
0
  public int run(String[] args) {
    Ice.Communicator communicator = communicator();
    Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
    Ice.Object d = new DI();
    adapter.add(d, communicator.stringToIdentity("d"));
    adapter.addFacet(d, communicator.stringToIdentity("d"), "facetABCD");
    Ice.Object f = new FI();
    adapter.addFacet(f, communicator.stringToIdentity("d"), "facetEF");
    Ice.Object h = new HI(communicator);
    adapter.addFacet(h, communicator.stringToIdentity("d"), "facetGH");

    adapter.activate();

    return WAIT;
  }
Ejemplo n.º 16
0
 private BookPrx isbnToBook(String isbn, Ice.ObjectAdapter adapter) {
   return BookPrxHelper.uncheckedCast(adapter.createProxy(createBookIdentity(isbn)));
 }
Ejemplo n.º 17
0
  @Override
  public int run(String[] args) {
    args = communicator().getProperties().parseCommandLineOptions("Clock", args);

    String topicName = "time";
    String option = "None";
    boolean batch = false;
    String id = null;
    String retryCount = null;
    int i;
    for (i = 0; i < args.length; ++i) {
      String oldoption = option;
      if (args[i].equals("--datagram")) {
        option = "Datagram";
      } else if (args[i].equals("--twoway")) {
        option = "Twoway";
      } else if (args[i].equals("--ordered")) {
        option = "Ordered";
      } else if (args[i].equals("--oneway")) {
        option = "Oneway";
      } else if (args[i].equals("--batch")) {
        batch = true;
      } else if (args[i].equals("--id")) {
        ++i;
        if (i >= args.length) {
          usage();
          return 1;
        }
        id = args[i];
      } else if (args[i].equals("--retryCount")) {
        ++i;
        if (i >= args.length) {
          usage();
          return 1;
        }
        retryCount = args[i];
      } else if (args[i].startsWith("--")) {
        usage();
        return 1;
      } else {
        topicName = args[i++];
        break;
      }

      if (!oldoption.equals(option) && !oldoption.equals("None")) {
        usage();
        return 1;
      }
    }

    if (i != args.length) {
      usage();
      return 1;
    }

    if (retryCount != null) {
      if (option.equals("None")) {
        option = "Twoway";
      } else if (!option.equals("Twoway") && !option.equals("Ordered")) {
        usage();
        return 1;
      }
    }

    if (batch && (option.equals("Twoway") || option.equals("Ordered"))) {
      System.err.println(appName() + ": batch can only be set with oneway or datagram");
      return 1;
    }

    IceStorm.TopicManagerPrx manager =
        IceStorm.TopicManagerPrxHelper.checkedCast(
            communicator().propertyToProxy("TopicManager.Proxy"));
    if (manager == null) {
      System.err.println("invalid proxy");
      return 1;
    }

    //
    // Retrieve the topic.
    //
    IceStorm.TopicPrx topic;
    try {
      topic = manager.retrieve(topicName);
    } catch (IceStorm.NoSuchTopic e) {
      try {
        topic = manager.create(topicName);
      } catch (IceStorm.TopicExists ex) {
        System.err.println(appName() + ": temporary failure, try again.");
        return 1;
      }
    }

    Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Clock.Subscriber");

    //
    // Add a servant for the Ice object. If --id is used the
    // identity comes from the command line, otherwise a UUID is
    // used.
    //
    // id is not directly altered since it is used below to detect
    // whether subscribeAndGetPublisher can raise
    // AlreadySubscribed.
    //
    Ice.Identity subId = new Ice.Identity(id, "");
    if (subId.name == null) {
      subId.name = java.util.UUID.randomUUID().toString();
    }
    Ice.ObjectPrx subscriber = adapter.add(new ClockI(), subId);

    //
    // Activate the object adapter before subscribing.
    //
    adapter.activate();

    java.util.Map<String, String> qos = new java.util.HashMap<String, String>();
    if (retryCount != null) {
      qos.put("retryCount", retryCount);
    }
    //
    // Set up the proxy.
    //
    if (option.equals("Datagram")) {
      if (batch) {
        subscriber = subscriber.ice_batchDatagram();
      } else {
        subscriber = subscriber.ice_datagram();
      }
    } else if (option.equals("Twoway")) {
      // Do nothing to the subscriber proxy. Its already twoway.
    } else if (option.equals("Ordered")) {
      // Do nothing to the subscriber proxy. Its already twoway.
      qos.put("reliability", "ordered");
    } else if (option.equals("Oneway") || option.equals("None")) {
      if (batch) {
        subscriber = subscriber.ice_batchOneway();
      } else {
        subscriber = subscriber.ice_oneway();
      }
    }

    try {
      topic.subscribeAndGetPublisher(qos, subscriber);
    } catch (IceStorm.AlreadySubscribed e) {
      // If we're manually setting the subscriber id ignore.
      if (id == null) {
        e.printStackTrace();
        return 1;
      } else {
        System.out.println("reactivating persistent subscriber");
      }
    } catch (IceStorm.InvalidSubscriber e) {
      e.printStackTrace();
      return 1;
    } catch (IceStorm.BadQoS e) {
      e.printStackTrace();
      return 1;
    }

    shutdownOnInterrupt();
    communicator().waitForShutdown();

    topic.unsubscribe(subscriber);

    return 0;
  }
Ejemplo n.º 18
0
  public int run(String[] args) {
    //
    // Terminate cleanly on receipt of a signal
    //
    shutdownOnInterrupt();

    //
    // Create an object adapter.
    //
    Ice.ObjectAdapter adapter =
        communicator()
            .createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h localhost -p 10000");

    //
    // Create the root directory (with name "/" and no parent)
    //
    DirectoryI root = new DirectoryI(communicator(), "/", null);
    root.activate(adapter);

    //
    // Create a file called "README" in the root directory
    //
    FileI file = new FileI(communicator(), "README", root);
    String[] text;
    text = new String[] {"This file system contains a collection of poetry."};
    try {
      file.write(text, null);
    } catch (GenericError e) {
      System.err.println(e.reason);
    }
    file.activate(adapter);

    //
    // Create a directory called "Coleridge" in the root directory
    //
    DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
    coleridge.activate(adapter);

    //
    // Create a file called "Kubla_Khan" in the Coleridge directory
    //
    file = new FileI(communicator(), "Kubla_Khan", coleridge);
    text =
        new String[] {
          "In Xanadu did Kubla Khan",
          "A stately pleasure-dome decree:",
          "Where Alph, the sacred river, ran",
          "Through caverns measureless to man",
          "Down to a sunless sea."
        };
    try {
      file.write(text, null);
    } catch (GenericError e) {
      System.err.println(e.reason);
    }
    file.activate(adapter);

    //
    // All objects are created, allow client requests now
    //
    adapter.activate();

    //
    // Wait until we are done
    //
    communicator().waitForShutdown();

    if (interrupted()) {
      System.err.println(appName() + ": terminating");
    }

    return 0;
  }
Ejemplo n.º 19
0
  public int run() {
    try {
      Ice.Properties properties = _communicator.getProperties();

      //
      // Create an object adapter. Services probably should NOT share
      // this object adapter, as the endpoint(s) for this object adapter
      // will most likely need to be firewalled for security reasons.
      //
      Ice.ObjectAdapter adapter = null;
      if (!properties.getProperty("IceBox.ServiceManager.Endpoints").equals("")) {
        adapter = _communicator.createObjectAdapter("IceBox.ServiceManager");

        Ice.Identity identity = new Ice.Identity();
        identity.category = properties.getPropertyWithDefault("IceBox.InstanceName", "IceBox");
        identity.name = "ServiceManager";
        adapter.add(this, identity);
      }

      //
      // Parse the property set with the prefix "IceBox.Service.". These
      // properties should have the following format:
      //
      // IceBox.Service.Foo=Package.Foo [args]
      //
      // We parse the service properties specified in IceBox.LoadOrder
      // first, then the ones from remaining services.
      //
      final String prefix = "IceBox.Service.";
      java.util.Map<String, String> services = properties.getPropertiesForPrefix(prefix);
      String[] loadOrder = properties.getPropertyAsList("IceBox.LoadOrder");
      java.util.List<StartServiceInfo> servicesInfo = new java.util.ArrayList<StartServiceInfo>();
      for (String name : loadOrder) {
        if (name.length() > 0) {
          String key = prefix + name;
          String value = services.get(key);
          if (value == null) {
            FailureException ex = new FailureException();
            ex.reason = "ServiceManager: no service definition for `" + name + "'";
            throw ex;
          }
          servicesInfo.add(new StartServiceInfo(name, value, _argv));
          services.remove(key);
        }
      }
      for (java.util.Map.Entry<String, String> p : services.entrySet()) {
        String name = p.getKey().substring(prefix.length());
        String value = p.getValue();
        servicesInfo.add(new StartServiceInfo(name, value, _argv));
      }

      //
      // Check if some services are using the shared communicator in which
      // case we create the shared communicator now with a property set which
      // is the union of all the service properties (services which are using
      // the shared communicator).
      //
      if (properties.getPropertiesForPrefix("IceBox.UseSharedCommunicator.").size() > 0) {
        Ice.InitializationData initData = new Ice.InitializationData();
        initData.properties = createServiceProperties("SharedCommunicator");
        for (StartServiceInfo service : servicesInfo) {
          if (properties.getPropertyAsInt("IceBox.UseSharedCommunicator." + service.name) <= 0) {
            continue;
          }

          //
          // Load the service properties using the shared communicator properties as
          // the default properties.
          //
          Ice.StringSeqHolder serviceArgs = new Ice.StringSeqHolder(service.args);
          Ice.Properties svcProperties =
              Ice.Util.createProperties(serviceArgs, initData.properties);
          service.args = serviceArgs.value;

          //
          // Erase properties from the shared communicator which don't exist in the
          // service properties (which include the shared communicator properties
          // overriden by the service properties).
          //
          java.util.Map<String, String> allProps = initData.properties.getPropertiesForPrefix("");
          for (String key : allProps.keySet()) {
            if (svcProperties.getProperty(key).length() == 0) {
              initData.properties.setProperty(key, "");
            }
          }

          //
          // Add the service properties to the shared communicator properties.
          //
          for (java.util.Map.Entry<String, String> p :
              svcProperties.getPropertiesForPrefix("").entrySet()) {
            initData.properties.setProperty(p.getKey(), p.getValue());
          }

          //
          // Parse <service>.* command line options (the Ice command line options
          // were parsed by the createProperties above)
          //
          service.args = initData.properties.parseCommandLineOptions(service.name, service.args);
        }
        _sharedCommunicator = Ice.Util.initialize(initData);
      }

      for (StartServiceInfo s : servicesInfo) {
        start(s.name, s.className, s.args);
      }

      //
      // We may want to notify external scripts that the services
      // have started. This is done by defining the property:
      //
      // IceBox.PrintServicesReady=bundleName
      //
      // Where bundleName is whatever you choose to call this set of
      // services. It will be echoed back as "bundleName ready".
      //
      // This must be done after start() has been invoked on the
      // services.
      //
      String bundleName = properties.getProperty("IceBox.PrintServicesReady");
      if (bundleName.length() > 0) {
        System.out.println(bundleName + " ready");
      }

      //
      // Don't move after the adapter activation. This allows
      // applications to wait for the service manager to be
      // reachable before sending a signal to shutdown the
      // IceBox.
      //
      Ice.Application.shutdownOnInterrupt();

      //
      // Register "this" as a facet to the Admin object and
      // create Admin object
      //
      try {
        _communicator.addAdminFacet(this, "IceBox.ServiceManager");

        //
        // Add a Properties facet for each service
        //
        for (ServiceInfo info : _services) {
          Ice.Communicator communicator =
              info.communicator != null ? info.communicator : _sharedCommunicator;
          _communicator.addAdminFacet(
              new PropertiesAdminI(communicator.getProperties()),
              "IceBox.Service." + info.name + ".Properties");
        }

        _communicator.getAdmin();
      } catch (Ice.ObjectAdapterDeactivatedException ex) {
        //
        // Expected if the communicator has been shutdown.
        //
      }

      //
      // Start request dispatching after we've started the services.
      //
      if (adapter != null) {
        try {
          adapter.activate();
        } catch (Ice.ObjectAdapterDeactivatedException ex) {
          //
          // Expected if the communicator has been shutdown.
          //
        }
      }

      _communicator.waitForShutdown();
      Ice.Application.defaultInterrupt();

      //
      // Invoke stop() on the services.
      //
      stopAll();
    } catch (FailureException ex) {
      java.io.StringWriter sw = new java.io.StringWriter();
      java.io.PrintWriter pw = new java.io.PrintWriter(sw);
      pw.println(ex.reason);
      ex.printStackTrace(pw);
      pw.flush();
      _logger.error(sw.toString());
      stopAll();
      return 1;
    } catch (Ice.LocalException ex) {
      java.io.StringWriter sw = new java.io.StringWriter();
      java.io.PrintWriter pw = new java.io.PrintWriter(sw);
      ex.printStackTrace(pw);
      pw.flush();
      _logger.error("ServiceManager: " + ex + "\n" + sw.toString());
      stopAll();
      return 1;
    } catch (java.lang.Exception ex) {
      java.io.StringWriter sw = new java.io.StringWriter();
      java.io.PrintWriter pw = new java.io.PrintWriter(sw);
      ex.printStackTrace(pw);
      pw.flush();
      _logger.error("ServiceManager: unknown exception\n" + sw.toString());
      stopAll();
      return 1;
    }

    return 0;
  }