gt:         _referenceFactory = _referenceFactory.setDefaultRouter(router);
context: // **********************************************************************
  //
  // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
  //
  // This copy of Ice is licensed to you under the terms described in the
  // ICE_LICENSE file included in this distribution.
  //
  // **********************************************************************
  
  package IceInternal;
  
  public final class Instance
  {
      public Ice.InitializationData
      initializationData()
      {
          //
          // No check for destruction. It must be possible to access the
          // initialization data after destruction.
          //
          // No mutex lock, immutable.
          //
          return _initData;
      }
  
      public TraceLevels
      traceLevels()
      {
          // No mutex lock, immutable.
          assert(_traceLevels != null);
          return _traceLevels;
      }
  
      public DefaultsAndOverrides
      defaultsAndOverrides()
      {
          // No mutex lock, immutable.
          assert(_defaultsAndOverrides != null);
          return _defaultsAndOverrides;
      }
  
      public synchronized RouterManager
      routerManager()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_routerManager != null);
          return _routerManager;
      }
  
      public synchronized LocatorManager
      locatorManager()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_locatorManager != null);
          return _locatorManager;
      }
  
      public synchronized ReferenceFactory
      referenceFactory()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_referenceFactory != null);
          return _referenceFactory;
      }
  
      public synchronized ProxyFactory
      proxyFactory()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_proxyFactory != null);
          return _proxyFactory;
      }
  
      public synchronized OutgoingConnectionFactory
      outgoingConnectionFactory()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_outgoingConnectionFactory != null);
          return _outgoingConnectionFactory;
      }
  
      public synchronized ConnectionMonitor
      connectionMonitor()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_connectionMonitor != null);
          return _connectionMonitor;
      }
  
      public synchronized ObjectFactoryManager
      servantFactoryManager()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_servantFactoryManager != null);
          return _servantFactoryManager;
      }
  
      public synchronized ObjectAdapterFactory
      objectAdapterFactory()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_objectAdapterFactory != null);
          return _objectAdapterFactory;
      }
  
      public synchronized int
      protocolSupport()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          return _protocolSupport;
      }
  
      public synchronized ThreadPool
      clientThreadPool()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_clientThreadPool != null);
          return _clientThreadPool;
      }
  
      public synchronized ThreadPool
      serverThreadPool()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          if(_serverThreadPool == null) // Lazy initialization.
          {
              int timeout = _initData.properties.getPropertyAsInt("Ice.ServerIdleTime");
              _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
          }
  
          return _serverThreadPool;
      }
  
      public synchronized EndpointHostResolver
      endpointHostResolver()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_endpointHostResolver != null);
          return _endpointHostResolver;
      }
  
      synchronized public RetryQueue
      retryQueue()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_retryQueue != null);
          return _retryQueue;
      }
  
      synchronized public Timer
      timer()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_timer != null);
          return _timer;
      }
  
      public synchronized EndpointFactoryManager
      endpointFactoryManager()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_endpointFactoryManager != null);
          return _endpointFactoryManager;
      }
  
      public synchronized Ice.PluginManager
      pluginManager()
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          assert(_pluginManager != null);
          return _pluginManager;
      }
  
      public int
      messageSizeMax()
      {
          // No mutex lock, immutable.
          return _messageSizeMax;
      }
  
      public int
      cacheMessageBuffers()
      {
          // No mutex lock, immutable.
          return _cacheMessageBuffers;
      }
  
      public int
      clientACM()
      {
          // No mutex lock, immutable.
          return _clientACM;
      }
  
      public int
      serverACM()
      {
          // No mutex lock, immutable.
          return _serverACM;
      }
  
      public Ice.ImplicitContextI
      getImplicitContext()
      {
          return _implicitContext;
      }
  
      public Ice.Identity
      stringToIdentity(String s)
      {
          return Ice.Util.stringToIdentity(s);
      }
  
      public String
      identityToString(Ice.Identity ident)
      {
          return Ice.Util.identityToString(ident);
      }
  
      public Ice.ObjectPrx
      getAdmin()
      {
          Ice.ObjectAdapter adapter = null;
          String serverId = null;
          Ice.LocatorPrx defaultLocator = null;
  
          synchronized(this)
          {
              if(_state == StateDestroyed)
              {
                  throw new Ice.CommunicatorDestroyedException();
              }
  
              final String adminOA = "Ice.Admin";
  
              if(_adminAdapter != null)
              {
                  return _adminAdapter.createProxy(_adminIdentity);
              }
              else if(_initData.properties.getProperty(adminOA + ".Endpoints").length() == 0)
              {
                  return null;
              }
              else
              {
                  serverId = _initData.properties.getProperty("Ice.Admin.ServerId");
                  String instanceName = _initData.properties.getProperty("Ice.Admin.InstanceName");
  
                  defaultLocator = _referenceFactory.getDefaultLocator();
  
                  if((defaultLocator != null && serverId.length() > 0) || instanceName.length() > 0)
                  {
                      if(_adminIdentity == null)
                      {
                          if(instanceName.length() == 0)
                          {
                              instanceName = java.util.UUID.randomUUID().toString();
                          }
                          _adminIdentity = new Ice.Identity("admin", instanceName);
                          //
                          // Afterwards, _adminIdentity is read-only
                          //
                      }
  
                      //
                      // Create OA
                      //
                      _adminAdapter = _objectAdapterFactory.createObjectAdapter(adminOA, null);
  
                      //
                      // Add all facets to OA
                      //
                      java.util.Map<String, Ice.Object> filteredFacets = new java.util.HashMap<String, Ice.Object>();
                      for(java.util.Map.Entry<String, Ice.Object> p : _adminFacets.entrySet())
                      {
                          if(_adminFacetFilter.isEmpty() || _adminFacetFilter.contains(p.getKey()))
                          {
                              _adminAdapter.addFacet(p.getValue(), _adminIdentity, p.getKey());
                          }
                          else
                          {
                              filteredFacets.put(p.getKey(), p.getValue());
                          }
                      }
                      _adminFacets = filteredFacets;
  
                      adapter = _adminAdapter;
                  }
              }
          }
  
          if(adapter == null)
          {
              return null;
          }
          else
          {
              try
              {
                  adapter.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
                  //
                  adapter.destroy();
                  synchronized(this)
                  {
                      _adminAdapter = null;
                  }
                  throw ex;
              }
  
              Ice.ObjectPrx admin = adapter.createProxy(_adminIdentity);
              if(defaultLocator != null && serverId.length() > 0)
              {
                  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.
                      //
                      defaultLocator.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());
                  }
              }
              return admin;
          }
      }
  
      public synchronized void
      addAdminFacet(Ice.Object servant, String facet)
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          if(_adminAdapter == null || (!_adminFacetFilter.isEmpty() && !_adminFacetFilter.contains(facet)))
          {
              if(_adminFacets.get(facet) != null)
              {
                  throw new Ice.AlreadyRegisteredException("facet", facet);
              }
              _adminFacets.put(facet, servant);
          }
          else
          {
              _adminAdapter.addFacet(servant, _adminIdentity, facet);
          }
      }
  
      public synchronized Ice.Object
      removeAdminFacet(String facet)
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          Ice.Object result = null;
          if(_adminAdapter == null || (!_adminFacetFilter.isEmpty() && !_adminFacetFilter.contains(facet)))
          {
              result = _adminFacets.remove(facet);
  
              if(result == null)
              {
                  throw new Ice.NotRegisteredException("facet", facet);
              }
          }
          else
          {
              result = _adminAdapter.removeFacet(_adminIdentity, facet);
          }
          return result;
      }
  
      public synchronized void
      setDefaultLocator(Ice.LocatorPrx locator)
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
          _referenceFactory = _referenceFactory.setDefaultLocator(locator);
      }
  
      public synchronized void
      setDefaultRouter(Ice.RouterPrx router)
      {
          if(_state == StateDestroyed)
          {
              throw new Ice.CommunicatorDestroyedException();
          }
  
  