public abstract class ReferralException extends NamingException
服务提供商通过提供getReferralInfo()和getReferralContext() (以及适当的构造函数和/或相应的“设置”方法)的实现来提供ReferralException的子类。
以下代码示例显示了如何使用ReferralException 。
while (true) { try { bindings = ctx.listBindings(name); while (bindings.hasMore()) { b = bindings.next(); ... } break; } catch (ReferralException e) { ctx = e.getReferralContext(); } }
ReferralException是一个抽象类。 具体实现确定其同步和序列化属性。
传递给getReferralContext()方法的环境参数由调用者拥有。 服务提供商不会修改对象或保留对它的引用,但可以保留对其的克隆的引用。
remainingName, resolvedName, resolvedObj, rootException| Modifier | Constructor and Description |
|---|---|
protected |
ReferralException()
构造一个新的ReferralException实例。
|
protected |
ReferralException(String explanation)
使用提供的说明构造一个新的ReferralException实例。
|
| Modifier and Type | Method and Description |
|---|---|
abstract Context |
getReferralContext()
检索继续该方法的上下文。
|
abstract Context |
getReferralContext(Hashtable<?,?> env)
检索使用环境属性继续该方法的上下文。
|
abstract Object |
getReferralInfo()
检索与此推介相关的信息(如URL)。
|
abstract void |
retryReferral()
重试目前正在处理的推介。
|
abstract boolean |
skipReferral()
丢弃有待处理的转介。
|
appendRemainingComponent, appendRemainingName, getCause, getExplanation, getRemainingName, getResolvedName, getResolvedObj, getRootCause, initCause, setRemainingName, setResolvedName, setResolvedObj, setRootCause, toString, toStringaddSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTraceprotected ReferralException(String explanation)
explanation - 有关此异常的其他详细信息。
可以为null。
Throwable.getMessage()
protected ReferralException()
public abstract Object getReferralInfo()
public abstract Context getReferralContext() throws NamingException
要继续操作,客户端程序应该使用与原始调用相同的参数重新调用该方法。
NamingException - 如果遇到命名异常。
致电retryReferral()或skipReferral()以继续处理转介。
public abstract Context getReferralContext(Hashtable<?,?> env) throws NamingException
引用上下文是使用env作为其环境属性创建的。 当调用者需要为引用上下文使用不同的环境属性时,应该使用此方法而不是无参数重载的形式。 它可能需要这样做,例如,当需要向引用的服务器提供不同的身份验证信息以创建引用上下文。
要继续操作,客户端程序应该使用与原始调用相同的参数重新调用该方法。
env - 检索引荐上下文时可能使用的空闲环境。
如果为空,则不会使用环境属性。
NamingException - 如果遇到命名异常。
致电retryReferral()或skipReferral()以继续处理转介。
public abstract boolean skipReferral()
getReferralContext以允许处理其他引用继续。
以下代码片段显示了典型的使用模式。
} catch (ReferralException e) {
if (!shallIFollow(e.getReferralInfo())) {
if (!e.skipReferral()) {
return;
}
}
ctx = e.getReferralContext();
}
public abstract void retryReferral()
getReferralContext以允许重试当前的引用。
以下代码片段显示了典型的使用模式。
} catch (ReferralException e) {
while (true) {
try {
ctx = e.getReferralContext(env);
break;
} catch (NamingException ne) {
if (! shallIRetry()) {
return;
}
// modify environment properties (env), if necessary
e.retryReferral();
}
}
}
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.