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/16 21:59:44 UTC
svn commit: r289640 - in /beehive/trunk/system-controls/src:
jdbc/org/apache/beehive/controls/system/jdbc/TypeMappingsFactory.java
jms/org/apache/beehive/controls/system/jms/impl/JMSControlImpl.jcs
Author: ekoneil
Date: Fri Sep 16 12:59:38 2005
New Revision: 289640
URL: http://svn.apache.org/viewcvs?rev=289640&view=rev
Log:
Two more XMLBean changes in the system controls.
These are changes to late-load XMLBean functionality.
Contributions from Chad Schoettger.
BB: self
Test: system controls pass
Modified:
beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/TypeMappingsFactory.java
beehive/trunk/system-controls/src/jms/org/apache/beehive/controls/system/jms/impl/JMSControlImpl.jcs
Modified: beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/TypeMappingsFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/TypeMappingsFactory.java?rev=289640&r1=289639&r2=289640&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/TypeMappingsFactory.java (original)
+++ beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/TypeMappingsFactory.java Fri Sep 16 12:59:38 2005
@@ -34,8 +34,17 @@
//@todo: refactor!
public final class TypeMappingsFactory {
-
private static TypeMappingsFactory _instance;
+ private static Class<?> XMLBEANS_STRING_ENUM_ABSTRACT_BASE = null;
+
+ static {
+ try {
+ XMLBEANS_STRING_ENUM_ABSTRACT_BASE = Class.forName("org.apache.xmlbeans.StringEnumAbstractBase");
+ } catch (ClassNotFoundException e) {
+ // not an error, just means XmlBeans is not available
+ }
+ }
+
/**
* Get an instance of this class.
@@ -146,7 +155,9 @@
_typeMap.put(java.util.Date.class, new Integer(TYPE_DATE));
_typeMap.put(java.util.Calendar.class, new Integer(TYPE_CALENDAR));
_typeMap.put(java.util.GregorianCalendar.class, new Integer(TYPE_CALENDAR));
- _typeMap.put(org.apache.xmlbeans.StringEnumAbstractBase.class, new Integer(TYPE_XMLBEAN_ENUM));
+ if (XMLBEANS_STRING_ENUM_ABSTRACT_BASE != null) {
+ _typeMap.put(XMLBEANS_STRING_ENUM_ABSTRACT_BASE, new Integer(TYPE_XMLBEAN_ENUM));
+ }
// Class to java.sql.Types
_typeSqlMap = new HashMap<Class, Integer>(TYPE_MAX * 2);
@@ -178,7 +189,9 @@
_typeSqlMap.put(java.util.Date.class, new Integer(Types.TIMESTAMP));
_typeSqlMap.put(java.util.Calendar.class, new Integer(Types.TIMESTAMP));
_typeSqlMap.put(java.util.GregorianCalendar.class, new Integer(Types.TIMESTAMP));
- _typeSqlMap.put(org.apache.xmlbeans.StringEnumAbstractBase.class, new Integer(Types.VARCHAR));
+ if (XMLBEANS_STRING_ENUM_ABSTRACT_BASE != null) {
+ _typeSqlMap.put(XMLBEANS_STRING_ENUM_ABSTRACT_BASE, new Integer(Types.VARCHAR));
+ }
// String to java.sql.Types
_typeSqlNameMap = new HashMap<String, Integer>(TYPE_MAX * 2);
Modified: beehive/trunk/system-controls/src/jms/org/apache/beehive/controls/system/jms/impl/JMSControlImpl.jcs
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/jms/org/apache/beehive/controls/system/jms/impl/JMSControlImpl.jcs?rev=289640&r1=289639&r2=289640&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/jms/org/apache/beehive/controls/system/jms/impl/JMSControlImpl.jcs (original)
+++ beehive/trunk/system-controls/src/jms/org/apache/beehive/controls/system/jms/impl/JMSControlImpl.jcs Fri Sep 16 12:59:38 2005
@@ -19,6 +19,7 @@
import java.io.Serializable;
import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
@@ -50,7 +51,6 @@
import org.apache.beehive.controls.api.bean.Control;
import org.apache.beehive.controls.system.jms.JMSControl;
import org.apache.beehive.controls.system.jndi.JndiControlBean;
-import org.apache.xmlbeans.XmlObject;
/**
* <p>
@@ -61,6 +61,15 @@
public class JMSControlImpl
implements JMSControl, Extensible, java.io.Serializable {
+ private static Class XMLOBJ_CLASS = null;
+ static {
+ try {
+ XMLOBJ_CLASS = Class.forName("org.apache.xmlbeans.XmlObject");
+ } catch (ClassNotFoundException e) {
+ // NOOP if apache xml beans not present
+ }
+ }
+
/**
* Implementation of the {@link org.apache.beehive.controls.system.jms.JMSControl#getSession()} method.
* @return the {@link Session}
@@ -357,11 +366,15 @@
{
type = MessageType.Map;
}
- else if(body instanceof String || body instanceof XmlObject)
+ else if(body instanceof String)
{
type = MessageType.Text;
}
- else if(body instanceof javax.jms.Message)
+ else if (XMLOBJ_CLASS != null && XMLOBJ_CLASS.isAssignableFrom(body.getClass()))
+ {
+ type = MessageType.Text;
+ }
+ else if(body instanceof javax.jms.Message)
{
type = MessageType.JMSMessage;
}
@@ -387,9 +400,18 @@
sm.writeBytes((byte[])body);
break;
case Text:
- if (body instanceof XmlObject)
+ if (XMLOBJ_CLASS != null && XMLOBJ_CLASS.isAssignableFrom(body.getClass()))
{
- body = (((XmlObject)body)).xmlText();
+ try {
+ Method xmlText = XMLOBJ_CLASS.getMethod("xmlText", new Class[] {});
+ body = xmlText.invoke(body, new Object[] {});
+ } catch (NoSuchMethodException e) {
+ throw new ControlException(e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ throw new ControlException(e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ throw new ControlException(e.getMessage(), e);
+ }
}
checkBody(body,String.class);
m = session.createTextMessage((String)body);