Пример #1
0
  public void rebind_context(NameComponent[] nc, NamingContext obj)
      throws NotFound, CannotProceed, InvalidName {
    if (this.destroyed) throw new CannotProceed();

    if (nc == null || nc.length == 0) throw new InvalidName();

    if (obj == null) throw new org.omg.CORBA.BAD_PARAM();

    Name n = new Name(nc);
    Name ctx = n.ctxName();
    NameComponent nb = n.baseNameComponent();

    if (ctx == null) {
      // the name is bound, but it is bound to an object - the client should have been using
      // rebind().
      if (this.names.containsKey(n))
        throw new NotFound(NotFoundReason.not_context, new NameComponent[] {nb});

      // try to remove an existing context binding.
      org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.contexts.remove(n);
      if (ref != null) {
        ref._release();
        // remove the old context from the implementation cache.
        String oid = this.getObjectOID(ref);
        if (oid != null) contextImpls.remove(oid);
      }

      this.contexts.put(n, obj);
      log.debugf("Re-Bound context: " + n.baseNameComponent().id);
    } else {
      // rebind in the correct context
      NameComponent[] ncx = new NameComponent[] {nb};
      org.omg.CORBA.Object context = this.resolve(ctx.components());

      // try first to call the context implementation object directly.
      String contextOID = this.getObjectOID(context);
      JBossNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
      if (jbossContext != null) jbossContext.rebind_context(ncx, obj);
      else NamingContextExtHelper.narrow(context).rebind_context(ncx, obj);
    }
  }
Пример #2
0
  public void bind_context(NameComponent[] nc, NamingContext obj)
      throws NotFound, CannotProceed, InvalidName, AlreadyBound {
    if (this.destroyed) throw new CannotProceed();

    Name n = new Name(nc);
    Name ctx = n.ctxName();
    NameComponent nb = n.baseNameComponent();

    if (ctx == null) {
      if (this.names.containsKey(n)) {
        // if the name is still in use, try to ping the object
        org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.names.get(n);
        if (isDead(ref)) unbind(n.components());
        else throw new AlreadyBound();
      } else if (this.contexts.containsKey(n)) {
        // if the name is still in use, try to ping the object
        org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.contexts.get(n);
        if (isDead(ref)) {
          rebind_context(n.components(), obj);
          return;
        }
        throw new AlreadyBound();
      }

      if ((this.contexts.put(n, obj)) != null) throw new CannotProceed(_this(), n.components());

      log.debugf("Bound context: " + n.toString());
    } else {
      NameComponent[] ncx = new NameComponent[] {nb};
      org.omg.CORBA.Object context = this.resolve(ctx.components());

      // try first to call the context implementation object directly.
      String contextOID = this.getObjectOID(context);
      JBossNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
      if (jbossContext != null) jbossContext.bind_context(ncx, obj);
      else NamingContextExtHelper.narrow(context).bind_context(ncx, obj);
    }
  }