本文整理匯總了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());
}
}