Exemplo n.º 1
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);
  }
Exemplo n.º 2
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);
  }