You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/09/15 23:11:23 UTC
svn commit: r289318 - in /beehive/trunk/netui/src/tags-databinding:
build.xml org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java
Author: ekoneil
Date: Thu Sep 15 14:11:17 2005
New Revision: 289318
URL: http://svn.apache.org/viewcvs?rev=289318&view=rev
Log:
Remove the XMLBean dependency from the SerializeXML tag.
The use of XMLBeans is now done reflectively; if XMLBeans is not available, the tag reports an in-line JSP tag error.
BB: self
Test: NetUI BVT pass
Modified:
beehive/trunk/netui/src/tags-databinding/build.xml
beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java
Modified: beehive/trunk/netui/src/tags-databinding/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/tags-databinding/build.xml?rev=289318&r1=289317&r2=289318&view=diff
==============================================================================
--- beehive/trunk/netui/src/tags-databinding/build.xml (original)
+++ beehive/trunk/netui/src/tags-databinding/build.xml Thu Sep 15 14:11:17 2005
@@ -7,9 +7,9 @@
<property name="module.name" value="tags-databinding"/>
<property name="module.classes.dir" location="${classes.dir}/${module.name}"/>
<property name="module.dir" location="${src.dir}/${module.name}"/>
+
<path id="module.classpath">
<path refid="servlet.dependency.path"/>
- <path refid="xbean.dependency.path"/>
<path refid="${struts.dependency.path.ref}"/>
<pathelement path="${classes.dir}/util"/>
<pathelement path="${classes.dir}/tags-html"/>
@@ -70,7 +70,6 @@
functionPackage="org.apache.beehive.netui.databinding"
/>
</webdoclet>
-
</target>
<target name="clean">
Modified: beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java?rev=289318&r1=289317&r2=289318&view=diff
==============================================================================
--- beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java (original)
+++ beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java Thu Sep 15 14:11:17 2005
@@ -17,12 +17,13 @@
*/
package org.apache.beehive.netui.tags.databinding.xml;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import javax.servlet.jsp.JspException;
import org.apache.beehive.netui.tags.AbstractClassicTag;
import org.apache.beehive.netui.util.internal.InternalStringBuilder;
import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.xmlbeans.XmlObject;
/**
* <p>
@@ -37,6 +38,8 @@
extends AbstractClassicTag {
private static final Logger LOGGER = Logger.getInstance(SerializeXML.class);
+ private static final Object[] EMPTY_ARRAY = new Object[0];
+ private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
private Object _source;
private String _divName;
@@ -51,11 +54,11 @@
/**
* Set the source document to be serialized. The object referenced here should be an instance of
- * {@link XmlObject}.
+ * {@link org.apache.xmlbeans.XmlObject}.
* @param source the source
* @jsptagref.attributedescription
* Set the source document to be serialized. The object referenced here should be an instance of
- * {@link XmlObject}.
+ * {@link org.apache.xmlbeans.XmlObject}.
* @jsptagref.attributesyntaxvalue <i>object_source</i>
* @netui:attribute required="true" rtexprvalue="true"
*/
@@ -82,25 +85,58 @@
public int doEndTag()
throws JspException {
- if(_source instanceof XmlObject && _source != null) {
- XmlObject xmlObject = (XmlObject)_source;
- String xml = xmlObject.xmlText();
+ Object xmlText = null;
+ if(_source != null) {
+ Class xmlObject = null;
+ try {
+ xmlObject = Class.forName("org.apache.xmlbeans.XmlObject");
+
+ if(xmlObject.isAssignableFrom(_source.getClass())) {
+ Method method = xmlObject.getMethod("xmlText", EMPTY_CLASS_ARRAY);
+ xmlText = method.invoke(_source, EMPTY_ARRAY);
+ }
+ }
+ catch(ClassNotFoundException e) {
+ String msg = "Unable to serialize object; Apache XMLBeans is not available. To fix this problem, add XMLBeans to your project";
+ LOGGER.error(msg);
+ registerTagError(msg, e);
+ reportErrors();
+ localRelease();
+ return EVAL_PAGE;
+ }
+ catch(NoSuchMethodException e) {
+ String msg = "Unexpected exception occurred serializing supposed XMLBean. Caues: " + e;
+ assert false : msg;
+ LOGGER.error(msg);
+ localRelease();
+ return EVAL_PAGE;
+ }
+ catch(InvocationTargetException e) {
+ String msg = "Unexpected exception occurred serializing supposed XMLBean. Caues: " + e;
+ assert false : msg;
+ LOGGER.error(msg);
+ localRelease();
+ return EVAL_PAGE;
+ }
+ catch(IllegalAccessException e) {
+ String msg = "Unexpected exception occurred serializing supposed XMLBean. Caues: " + e;
+ assert false : msg;
+ LOGGER.error(msg);
+ localRelease();
+ return EVAL_PAGE;
+ }
InternalStringBuilder buf = new InternalStringBuilder();
buf.append("<div");
buf.append(" id=\"");
buf.append(_divName);
buf.append("\">\n<!--\n");
- buf.append(xml);
+ buf.append(xmlText);
buf.append("\n-->\n</div>");
write(buf.toString());
}
- else {
- // @todo: write anything to the page?
- if(LOGGER.isInfoEnabled())
- LOGGER.info("The expression \"" + _source + "\" resulted in an object that was not an XMLBean");
- }
+ else LOGGER.info("The object to serialize was not an XMLBean");
localRelease();