antelder 2002/06/12 14:07:50
Modified: java/src/org/apache/wsif/providers/jms JMSMessage.java
WSIFOperation_Jms.java
PrimitiveTypeFormatHandler.java
Log:
Latest native JMS provider changes from Norman
Revision Changes Path
1.4 +13 -9
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSMessage.java
Index: JMSMessage.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSMessage.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JMSMessage.java 12 Jun 2002 10:27:23 -0000 1.3
+++ JMSMessage.java 12 Jun 2002 21:07:50 -0000 1.4
@@ -99,12 +99,12 @@
private static String XML_ENCODING = "XML";
private static String JAVA_ENCODING = "Java";
- private static String XML_SCHEMA_1999 = "http://www.w3.org/1999/XMLSchema";
- private static String XML_SCHEMA_2000_10 =
+ static String XML_SCHEMA_1999 = "http://www.w3.org/1999/XMLSchema";
+ static String XML_SCHEMA_2000_10 =
"http://www.w3.org/2000/10/XMLSchema";
- private static String XML_SCHEMA_2001 = "http://www.w3.org/2001/XMLSchema";
+ static String XML_SCHEMA_2001 = "http://www.w3.org/2001/XMLSchema";
- private static final java.util.HashMap PRIMITIVE_JAVA_MAPPING =
+ static final java.util.HashMap PRIMITIVE_JAVA_MAPPING =
new java.util.HashMap();
// Maps the XSD Type to the equivalent Java class
@@ -666,14 +666,18 @@
javax.wsdl.Part partModel = fieldMessageModel.getPart(partName);
org.apache.wsif.format.jms.JMSFormatHandler fh = null;
+ javax.wsdl.QName partType = partModel.getTypeName();
+ if(partType == null)
+ partType = partModel.getElementName();
+
try {
// no type exists or it is not a XSD primitive type
- if (isSchemaNamespace(partModel.getTypeName().getNamespaceURI())
- && isXSDPrimitiveType(partModel.getTypeName().getLocalPart()))
+ if (isSchemaNamespace(partType.getNamespaceURI())
+ && isXSDPrimitiveType(partType.getLocalPart()))
fh =
new PrimitiveTypeFormatHandler(
(Class) PRIMITIVE_JAVA_MAPPING.get(
- partModel.getTypeName().getLocalPart().toLowerCase()));
+
partType.getLocalPart().toLowerCase()));
else
fh = (org.apache.wsif.format.jms.JMSFormatHandler)
//antxxx
org.apache.wsif.jca.util.JCAUtil.getFormatHandler(
@@ -690,13 +694,13 @@
/**
* Returns true if the namespace is one of the existing XML Schema namespaces
*/
- private boolean isSchemaNamespace(String namespaceURI) {
+ static boolean isSchemaNamespace(String namespaceURI) {
return XML_SCHEMA_1999.equals(namespaceURI)
|| XML_SCHEMA_2000_10.equals(namespaceURI)
|| XML_SCHEMA_2001.equals(namespaceURI);
}
- private boolean isXSDPrimitiveType(String type) {
+ static boolean isXSDPrimitiveType(String type) {
Object[] types = PRIMITIVE_JAVA_MAPPING.keySet().toArray();
for (int i = 0; i < types.length; i++) {
if (types[i].toString().equalsIgnoreCase(type))
1.3 +39 -8
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java
Index: WSIFOperation_Jms.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WSIFOperation_Jms.java 12 Jun 2002 10:27:23 -0000 1.2
+++ WSIFOperation_Jms.java 12 Jun 2002 21:07:50 -0000 1.3
@@ -448,6 +448,9 @@
WSIFJMSDestination jmsDest)
throws WSIFException {
+ if (!(responseObject instanceof javax.jms.Message))
+ throw new WSIFException("Object is not of type javax.jms.Message");
+
JMSFormatter formatter = (JMSFormatter) fieldJmsPort.getFormatter();
WSIFResponse resp =
formatter.unformatResponse((javax.jms.Message) responseObject);
@@ -580,15 +583,43 @@
return fieldOperation;
}
- private Object getObjectValue(QName type, String value) {
- //FIXME
- // Need to factor in property the type assigned
- if (type.equals(new QName("http://www.w3.org/2001/XMLSchema", "string")))
- return value;
- else
- return null;
- }
+ private Object getObjectValue(QName type, String value) throws WSIFException {
+ Object primitiveType = null;
+
+ if (JMSMessage.isSchemaNamespace(type.getNamespaceURI()) &&
JMSMessage.isXSDPrimitiveType(type.getLocalPart())) {
+ Class cls =
(Class)JMSMessage.PRIMITIVE_JAVA_MAPPING.get(type.getLocalPart().toLowerCase());
+
+ if (cls == String.class) {
+ primitiveType = value;
+ }
+ // For byte array class
+ else if (cls == byte[].class) {
+ primitiveType = value.getBytes();
+ }
+ // For Gregorian Calendar && Date
+ else if
(java.util.GregorianCalendar.class.isAssignableFrom(cls) ||
+ java.util.Date.class.isAssignableFrom(cls)) {
+ // DON"T DO ANYTHING since unable to know what the
format is
+ }
+ // For all the rest
+ else {
+ try {
+ java.lang.reflect.Constructor constructor =
cls.getConstructor(
+ new Class[] {String.class});
+ primitiveType = constructor.newInstance(new
Object[] {value});
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+
+ if (primitiveType != null)
+ return primitiveType;
+ else
+ throw new WSIFException("Unable to create the java object for
XSD Type '" + type.toString() + "' using value '" + value + "'");
+ }
+
//FIXME - Should I place somewhere else??
public int getJMSMessageType() {
Tr.entry(this);
1.2 +8 -8
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/PrimitiveTypeFormatHandler.java
Index: PrimitiveTypeFormatHandler.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/PrimitiveTypeFormatHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PrimitiveTypeFormatHandler.java 6 Jun 2002 08:28:51 -0000 1.1
+++ PrimitiveTypeFormatHandler.java 12 Jun 2002 21:07:50 -0000 1.2
@@ -74,11 +74,11 @@
public class PrimitiveTypeFormatHandler implements JMSFormatHandler {
- protected static DateFormat gregorianCalandarDateFormat =
+ protected static DateFormat GREGORIAN_CALENDAR_DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd");
- protected static DateFormat standardDateFormat =
+ protected static DateFormat STANDARD_DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- protected static DateFormat preciseDateFormat =
+ protected static DateFormat PRECISE_DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'");
Object primitiveType;
@@ -270,10 +270,10 @@
value = "";
else if (primitiveType instanceof java.util.GregorianCalendar)
value =
- gregorianCalandarDateFormat.format(
+ GREGORIAN_CALENDAR_DATE_FORMAT.format(
((java.util.GregorianCalendar) primitiveType).getTime());
else if (primitiveType instanceof java.util.Date)
- value = standardDateFormat.format((java.util.Date) primitiveType);
+ value = STANDARD_DATE_FORMAT.format((java.util.Date) primitiveType);
else if (primitiveType instanceof byte[])
value = new String((byte[]) primitiveType);
else {
@@ -305,16 +305,16 @@
// For Gregorian Calendar
else if (java.util.GregorianCalendar.class.isAssignableFrom(cls)) {
java.util.GregorianCalendar result = new
java.util.GregorianCalendar();
- result.setTime(gregorianCalandarDateFormat.parse(value));
+ result.setTime(GREGORIAN_CALENDAR_DATE_FORMAT.parse(value));
primitiveType = result;
}
// For Date
else if (java.util.Date.class.isAssignableFrom(cls)) {
java.util.Date result = new java.util.Date();
try {
- result = standardDateFormat.parse(value);
+ result = STANDARD_DATE_FORMAT.parse(value);
} catch (java.text.ParseException standardException) {
- result = preciseDateFormat.parse(value);
+ result = PRECISE_DATE_FORMAT.parse(value);
}
primitiveType = result;
}