コード例 #1
0
ファイル: ContextImpl.java プロジェクト: dlitz/resin
  public void unbind(Name name) throws NamingException {
    if (name.size() == 0) throw new NamingException(L.l("can't unbind root"));

    AbstractModel model = _model;

    int i = 0;
    for (; i + 1 < name.size(); i++) {
      String first = name.get(i);

      Object value = model.lookup(first);

      if (value instanceof AbstractModel) {
        model = (AbstractModel) value;
        continue;
      }

      value = dereference(value, null, model);

      if (value instanceof Context) {
        ((Context) value).unbind(name.getSuffix(i + 1));
        return;
      } else if (value != null)
        throw new NotContextException(
            L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value));
      else throw new NameNotFoundException(getFullPath(name));
    }

    String first = name.get(i);

    model.unbind(first);
  }
コード例 #2
0
 public void unbind(String name) throws NamingException {
   ResolveResult res = getRootURLContext(name, myEnv);
   Context ctx = (Context) res.getResolvedObj();
   try {
     ctx.unbind(res.getRemainingName());
   } finally {
     ctx.close();
   }
 }
コード例 #3
0
 public void unbind(Name name) throws NamingException {
   if (name.size() == 1) {
     unbind(name.get(0));
   } else {
     Context ctx = getContinuationContext(name);
     try {
       ctx.unbind(name.getSuffix(1));
     } finally {
       ctx.close();
     }
   }
 }
コード例 #4
0
ファイル: JndiTest.java プロジェクト: odedns/oded-repo
  public static void foo() throws Exception {
    String url = "iiop://localhost:2809";
    //  		String url = "corbaloc:iiop:localhost:2809";
    // String factory = "com.ibm.ejs.ns.jndi.CNInitialContextFactory";
    String factory = "com.ibm.websphere.naming.WsnInitialContextFactory";

    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY, factory);
    prop.put(Context.PROVIDER_URL, url);
    // prop.put("java.naming.factory.url.pkgs","com.ibm.websphere.naming");
    Context ctx = new InitialContext(prop);
    ctx.bind("test", new String("test"));
    String s = (String) ctx.lookup("test");
    ctx.unbind("test");
    System.out.println("\nEnd Mytest session.Client...\n");
  }
コード例 #5
0
ファイル: ContextImpl.java プロジェクト: dlitz/resin
  private void unbindImpl(String name, boolean isRename) throws NamingException {
    String tail = name;
    AbstractModel model = _model;

    while (true) {
      String first = parseFirst(tail);
      String rest = parseRest(tail);

      if (first == null) throw new NamingException(L.l("can't unbind root"));

      if (rest == null) {
        if (!isRename && model.lookup(name) instanceof AbstractModel)
          throw new NamingException(L.l("can't unbind subcontext; use destroySubcontext"));

        model.unbind(first);
        return;
      }

      Object value = model.lookup(first);

      if (value instanceof AbstractModel) {
        model = (AbstractModel) value;
        tail = rest;
        continue;
      }

      value = dereference(value, null, model);

      if (value instanceof Context) {
        ((Context) value).unbind(rest);
        return;
      } else if (value != null)
        throw new NotContextException(
            L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value));
      else throw new NameNotFoundException(getFullPath(name));
    }
  }