EndpointHostResolver(Instance instance) {
   _instance = instance;
   _protocol = instance.protocolSupport();
   _preferIPv6 = instance.preferIPv6();
   try {
     _threadName =
         Util.createThreadName(_instance.initializationData().properties, "Ice.HostResolver");
     _executor =
         java.util.concurrent.Executors.newFixedThreadPool(
             1, Util.createThreadFactory(_instance.initializationData().properties, _threadName));
     updateObserver();
   } catch (RuntimeException ex) {
     String s = "cannot create thread for endpoint host resolver thread:\n" + Ex.toString(ex);
     _instance.initializationData().logger.error(s);
     throw ex;
   }
 }
Beispiel #2
0
  public void finishSetup(Ice.StringSeqHolder args, Ice.Communicator communicator) {
    //
    // Load plug-ins.
    //
    assert (_serverThreadPool == null);
    Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI) _pluginManager;
    pluginManagerImpl.loadPlugins(args);

    //
    // Add WS and WSS endpoint factories if TCP/SSL factories are installed.
    //
    final EndpointFactory tcpFactory = _endpointFactoryManager.get(Ice.TCPEndpointType.value);
    if (tcpFactory != null) {
      final ProtocolInstance instance =
          new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
      _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance)));
    }
    final EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value);
    if (sslFactory != null) {
      final ProtocolInstance instance =
          new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
      _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance)));
    }

    //
    // Create Admin facets, if enabled.
    //
    // Note that any logger-dependent admin facet must be created after we load all plugins,
    // since one of these plugins can be a Logger plugin that sets a new logger during loading
    //

    if (_initData.properties.getProperty("Ice.Admin.Enabled").isEmpty()) {
      _adminEnabled = !_initData.properties.getProperty("Ice.Admin.Endpoints").isEmpty();
    } else {
      _adminEnabled = _initData.properties.getPropertyAsInt("Ice.Admin.Enabled") > 0;
    }

    String[] facetFilter = _initData.properties.getPropertyAsList("Ice.Admin.Facets");
    if (facetFilter.length > 0) {
      _adminFacetFilter.addAll(java.util.Arrays.asList(facetFilter));
    }

    if (_adminEnabled) {
      //
      // Process facet
      //
      String processFacetName = "Process";
      if (_adminFacetFilter.isEmpty() || _adminFacetFilter.contains(processFacetName)) {
        _adminFacets.put(processFacetName, new ProcessI(communicator));
      }

      //
      // Logger facet
      //
      String loggerFacetName = "Logger";
      if (_adminFacetFilter.isEmpty() || _adminFacetFilter.contains(loggerFacetName)) {
        LoggerAdminLogger logger = new LoggerAdminLoggerI(_initData.properties, _initData.logger);
        setLogger(logger);
        _adminFacets.put(loggerFacetName, logger.getFacet());
      }

      //
      // Properties facet
      //
      String propertiesFacetName = "Properties";
      PropertiesAdminI propsAdmin = null;
      if (_adminFacetFilter.isEmpty() || _adminFacetFilter.contains(propertiesFacetName)) {
        propsAdmin = new PropertiesAdminI(_initData.properties, _initData.logger);
        _adminFacets.put(propertiesFacetName, propsAdmin);
      }

      //
      // Metrics facet
      //
      String metricsFacetName = "Metrics";
      if (_adminFacetFilter.isEmpty() || _adminFacetFilter.contains(metricsFacetName)) {
        CommunicatorObserverI observer = new CommunicatorObserverI(_initData);
        _initData.observer = observer;
        _adminFacets.put(metricsFacetName, observer.getFacet());

        //
        // Make sure the admin plugin receives property updates.
        //
        if (propsAdmin != null) {
          propsAdmin.addUpdateCallback(observer.getFacet());
        }
      }
    }

    //
    // Set observer updater
    //
    if (_initData.observer != null) {
      _initData.observer.setObserverUpdater(new ObserverUpdaterI());
    }

    //
    // Create threads.
    //
    try {
      _timer =
          new Timer(_initData.properties, Util.createThreadName(_initData.properties, "Ice.Timer"));
    } catch (RuntimeException ex) {
      String s = "cannot create thread for timer:\n" + Ex.toString(ex);
      _initData.logger.error(s);
      throw ex;
    }

    try {
      _endpointHostResolver = new EndpointHostResolver(this);
    } catch (RuntimeException ex) {
      String s = "cannot create thread for endpoint host resolver:\n" + Ex.toString(ex);
      _initData.logger.error(s);
      throw ex;
    }

    _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);

    //
    // The default router/locator may have been set during the loading of plugins.
    // Therefore we make sure it is not already set before checking the property.
    //
    if (_referenceFactory.getDefaultRouter() == null) {
      Ice.RouterPrx router =
          Ice.RouterPrxHelper.uncheckedCast(_proxyFactory.propertyToProxy("Ice.Default.Router"));
      if (router != null) {
        _referenceFactory = _referenceFactory.setDefaultRouter(router);
      }
    }

    if (_referenceFactory.getDefaultLocator() == null) {
      Ice.LocatorPrx loc =
          Ice.LocatorPrxHelper.uncheckedCast(_proxyFactory.propertyToProxy("Ice.Default.Locator"));
      if (loc != null) {
        _referenceFactory = _referenceFactory.setDefaultLocator(loc);
      }
    }

    //
    // Server thread pool initialization is lazy in serverThreadPool().
    //

    //
    // An application can set Ice.InitPlugins=0 if it wants to postpone
    // initialization until after it has interacted directly with the
    // plug-ins.
    //
    if (_initData.properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0) {
      pluginManagerImpl.initializePlugins();
    }

    //
    // This must be done last as this call creates the Ice.Admin object adapter
    // and eventually registers a process proxy with the Ice locator (allowing
    // remote clients to invoke on Ice.Admin facets as soon as it's registered).
    //
    if (_initData.properties.getPropertyAsIntWithDefault("Ice.Admin.DelayCreation", 0) <= 0) {
      getAdmin();
    }
  }