本文整理汇总了Java中javax.naming.Context.unbind方法的典型用法代码示例。如果您正苦于以下问题:Java Context.unbind方法的具体用法?Java Context.unbind怎么用?Java Context.unbind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.Context
的用法示例。
在下文中一共展示了Context.unbind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeInstance
import javax.naming.Context; //导入方法依赖的package包/类
public static void removeInstance(String uid, String name, Properties properties) {
//TODO: theoretically non-threadsafe...
if (name!=null) {
log.info("Unbinding factory from JNDI name: " + name);
try {
Context ctx = NamingHelper.getInitialContext(properties);
ctx.unbind(name);
log.info("Unbound factory from JNDI name: " + name);
}
catch (InvalidNameException ine) {
log.error("Invalid JNDI name: " + name, ine);
}
catch (NamingException ne) {
log.warn("Could not unbind factory from JNDI", ne);
}
NAMED_INSTANCES.remove(name);
}
INSTANCES.remove(uid);
}
示例2: clearContext
import javax.naming.Context; //导入方法依赖的package包/类
/**
* Removes all entries from the specified context, including subcontexts.
*
* @param context context to clear
*/
private void clearContext(Context context) throws NamingException {
for (NamingEnumeration e = context.listBindings(""); e.hasMoreElements();) {
Binding binding = (Binding) e.nextElement();
if (binding.getObject() instanceof Context) {
clearContext((Context) binding.getObject());
}
context.unbind(binding.getName());
}
}