📄 foourlcontext.java
字号:
ctx.rebind(name.getSuffix(1), obj); } finally { ctx.close(); } } } 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(); } } 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(); } } } public void rename(String oldName, String newName) throws NamingException { String oldPrefix = getURLPrefix(oldName); String newPrefix = getURLPrefix(newName); if (!urlEquals(oldPrefix, newPrefix)) { throw new OperationNotSupportedException( "Renaming using different URL prefixes not supported : " + oldName + " " + newName); } ResolveResult res = getRootURLContext(oldName, myEnv); Context ctx = (Context)res.getResolvedObj(); try { ctx.rename(res.getRemainingName(), getURLSuffix(newPrefix, newName)); } finally { ctx.close(); } } public void rename(Name name, Name newName) throws NamingException { if (name.size() == 1) { if (newName.size() != 1) { throw new OperationNotSupportedException( "Renaming to a Name with more components not supported: " + newName); } rename(name.get(0), newName.get(0)); } else { // > 1 component with 1st one being URL // URLs must be identical; cannot deal with diff URLs if (!urlEquals(name.get(0), newName.get(0))) { throw new OperationNotSupportedException( "Renaming using different URLs as first components not supported: " + name + " " + newName); } Context ctx = getContinuationContext(name); try { ctx.rename(name.getSuffix(1), newName.getSuffix(1)); } finally { ctx.close(); } } } public NamingEnumeration list(String name) throws NamingException { ResolveResult res = getRootURLContext(name, myEnv); Context ctx = (Context)res.getResolvedObj(); try { return ctx.list(res.getRemainingName()); } finally { ctx.close(); } } public NamingEnumeration list(Name name) throws NamingException { if (name.size() == 1) { return list(name.get(0)); } else { Context ctx = getContinuationContext(name); try { return ctx.list(name.getSuffix(1)); } finally { ctx.close(); } } } public NamingEnumeration listBindings(String name) throws NamingException { ResolveResult res = getRootURLContext(name, myEnv); Context ctx = (Context)res.getResolvedObj(); try { return ctx.listBindings(res.getRemainingName()); } finally { ctx.close(); } } public NamingEnumeration listBindings(Name name) throws NamingException { if (name.size() == 1) { return listBindings(name.get(0)); } else { Context ctx = getContinuationContext(name); try { return ctx.listBindings(name.getSuffix(1)); } finally { ctx.close(); } } } public void destroySubcontext(String name) throws NamingException { ResolveResult res = getRootURLContext(name, myEnv); Context ctx = (Context)res.getResolvedObj(); try { ctx.destroySubcontext(res.getRemainingName()); } finally { ctx.close(); } } public void destroySubcontext(Name name) throws NamingException { if (name.size() == 1) { destroySubcontext(name.get(0)); } else { Context ctx = getContinuationContext(name); try { ctx.destroySubcontext(name.getSuffix(1)); } finally { ctx.close(); } } } public Context createSubcontext(String name) throws NamingException { ResolveResult res = getRootURLContext(name, myEnv); Context ctx = (Context)res.getResolvedObj(); try { return ctx.createSubcontext(res.getRemainingName()); } finally { ctx.close(); } } public Context createSubcontext(Name name) throws NamingException { if (name.size() == 1) { return createSubcontext(name.get(0)); } else { Context ctx = getContinuationContext(name); try { return ctx.createSubcontext(name.getSuffix(1)); } finally { ctx.close(); } } } public Object lookupLink(String name) throws NamingException { ResolveResult res = getRootURLContext(name, myEnv); Context ctx = (Context)res.getResolvedObj(); try { return ctx.lookupLink(res.getRemainingName()); } finally { ctx.close(); } } public Object lookupLink(Name name) throws NamingException { if (name.size() == 1) { return lookupLink(name.get(0)); } else { Context ctx = getContinuationContext(name); try { return ctx.lookupLink(name.getSuffix(1)); } finally { ctx.close(); } } } public NameParser getNameParser(String name) throws NamingException { ResolveResult res = getRootURLContext(name, myEnv); Context ctx = (Context)res.getResolvedObj(); try { return ctx.getNameParser(res.getRemainingName()); } finally { ctx.close(); } } public NameParser getNameParser(Name name) throws NamingException { if (name.size() == 1) { return getNameParser(name.get(0)); } else { Context ctx = getContinuationContext(name); try { return ctx.getNameParser(name.getSuffix(1)); } finally { ctx.close(); } } } public String composeName(String name, String prefix) throws NamingException { if (prefix.equals("")) { return name; } else if (name.equals("")) { return prefix; } else { return (prefix + "/" + name); } } public Name composeName(Name name, Name prefix) throws NamingException { Name result = (Name)prefix.clone(); result.addAll(name); return result; } public String getNameInNamespace() throws NamingException { return ""; // A URL context's name is "" } public Object removeFromEnvironment(String propName) throws NamingException { if (myEnv == null) { return null; } myEnv = (Hashtable)myEnv.clone(); return myEnv.remove(propName); } public Object addToEnvironment(String propName, Object propVal) throws NamingException { myEnv = (myEnv == null) ? new Hashtable(11, 0.75f) : (Hashtable)myEnv.clone(); return myEnv.put(propName, propVal); } public Hashtable getEnvironment() throws NamingException { if (myEnv == null) { return new Hashtable(5, 0.75f); } else { return (Hashtable)myEnv.clone(); } } public void close() throws NamingException { }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -