|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.servlet.jsp.tagext Interface TryCatchFinally
public interface TryCatchFinally
想使用其他挂钩 (hook) 管理资源的 Tag、IterationTag 或 BodyTag 标记处理程序的辅助接口。
此接口提供了两个新方法:doCatch(Throwable) 和 doFinally()。原型调用如下所示:
h = get a Tag(); // get a tag handler, perhaps from pool h.setPageContext(pc); // initialize as desired h.setParent(null); h.setFoo("foo"); // tag invocation protocol; see Tag.java try { doStartTag()... .... doEndTag()... } catch (Throwable t) { // react to exceptional condition h.doCatch(t); } finally { // restore data invariants and release per-invocation resources h.doFinally(); } ... other invocations perhaps with some new setters ... h.release(); // release long-term resources
The auxiliary interface of a Tag, IterationTag or BodyTag tag handler that wants additional hooks for managing resources.
This interface provides two new methods: doCatch(Throwable) and doFinally(). The prototypical invocation is as follows:
h = get a Tag(); // get a tag handler, perhaps from pool h.setPageContext(pc); // initialize as desired h.setParent(null); h.setFoo("foo"); // tag invocation protocol; see Tag.java try { doStartTag()... .... doEndTag()... } catch (Throwable t) { // react to exceptional condition h.doCatch(t); } finally { // restore data invariants and release per-invocation resources h.doFinally(); } ... other invocations perhaps with some new setters ... h.release(); // release long-term resources
Method Summary | |
---|---|
void |
doCatch(Throwable t)
Invoked if a Throwable occurs while evaluating the BODY inside a tag or in any of the following methods: Tag.doStartTag(), Tag.doEndTag(), IterationTag.doAfterBody() and BodyTag.doInitBody(). |
void |
doFinally()
Invoked in all cases after doEndTag() for any class implementing Tag, IterationTag or BodyTag. |
Method Detail |
---|
public void
doCatch(Throwable t) throws Throwable
如果在某个标记内或在以下任何方法:Tag.doStartTag()、Tag.doEndTag()、IterationTag.doAfterBody() 和 BodyTag.doInitBody() 中对正文求值时发生 Throwable,则调用此方法。
如果某个 setter 方法发生 Throwable,则不调用此方法。
此方法可能抛出一个将沿嵌套链进一步向上传播的异常(同一异常或新异常)。如果抛出异常,则将调用 doFinally()。
此方法旨在用于响应异常条件。
t | 在此标记中导航的 throwable 异常。 |
Throws | Throwable: 如果将沿嵌套链进一步向上重新抛出该异常。 |
doCatch
void doCatch(Throwable t) throws Throwable
- Invoked if a Throwable occurs while evaluating the BODY
inside a tag or in any of the following methods:
Tag.doStartTag(), Tag.doEndTag(),
IterationTag.doAfterBody() and BodyTag.doInitBody().
This method is not invoked if the Throwable occurs during one of the setter methods.
This method may throw an exception (the same or a new one) that will be propagated further up the nest chain. If an exception is thrown, doFinally() will be invoked.
This method is intended to be used to respond to an exceptional condition.
- Parameters:
t
- The throwable exception navigating through this tag.- Throws:
Throwable
- if the exception is to be rethrown further up the nest chain.
public void
doFinally()
在对任何实现 Tag、IterationTag 或 BodyTag 的类调用 doEndTag() 之后的任何情况下都可调用此方法。即使标记 BODY 中或以下任何方法:Tag.doStartTag()、Tag.doEndTag()、IterationTag.doAfterBody() 和 BodyTag.doInitBody() 中已经发生异常,也可以调用此方法。
如果某个 setter 方法发生 Throwable,则不调用此方法。
此方法不应抛出 Exception。
此方法旨在维护每次调用的数据完整性和资源管理操作。
doFinally
void doFinally()
- Invoked in all cases after doEndTag() for any class implementing
Tag, IterationTag or BodyTag. This method is invoked even if
an exception has occurred in the BODY of the tag,
or in any of the following methods:
Tag.doStartTag(), Tag.doEndTag(),
IterationTag.doAfterBody() and BodyTag.doInitBody().
This method is not invoked if the Throwable occurs during one of the setter methods.
This method should not throw an Exception.
This method is intended to maintain per-invocation data integrity and resource management actions.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!