01: package clime.messadmin.taglib;
02:
03: import javax.servlet.jsp.JspException;
04: import javax.servlet.jsp.tagext.BodyTagSupport;
05: import javax.servlet.jsp.tagext.TryCatchFinally;
06:
07: import clime.messadmin.providers.spi.SerializableProvider;
08:
09: /**
10: * JSP Tag <code>serializable</code>, used to get the serializable state of an object.
11: *
12: * @author Cédrik LIME
13: */
14:
15: public class NotSerializableTag extends BodyTagSupport implements
16: TryCatchFinally {
17: protected Object object;
18:
19: /**
20: * Print the requested object size.
21: *
22: * @return EVAL_PAGE
23: */
24: public final int doStartTag() throws JspException {
25: if (object == null && id != null && !"".equals(id.trim())) {//$NON-NLS-1$
26: object = pageContext.findAttribute(id);
27: }
28: boolean serializable;
29: try {
30: serializable = !SerializableProvider.Util.isSerializable(
31: object, null);
32: } catch (RuntimeException rte) {
33: serializable = false;
34: }
35: return serializable ? EVAL_BODY_INCLUDE : SKIP_BODY;
36: }
37:
38: /** {@inheritDoc} */
39: public void release() {
40: object = null;
41: super .release();
42: }
43:
44: /**
45: * @param object The object to set.
46: */
47: public void setObject(Object object) {
48: this .object = object;
49: }
50:
51: /** {@inheritDoc} */
52: public void doCatch(Throwable t) throws Throwable {
53: if (!(t instanceof IllegalStateException)) {
54: throw t;
55: }
56: }
57:
58: /** {@inheritDoc} */
59: public void doFinally() {
60: release();
61: }
62: }
|