Author: heiko.braun(a)jboss.com
Date: 2007-03-07 11:02:15 -0500 (Wed, 07 Mar 2007)
New Revision: 2546
Added:
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java
Removed:
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveXOPScanner.java
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/CIDGenerator.java
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/XOPContext.java
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentMarshallerImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentUnmarshallerImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java
Log:
Fix JBCTS-466. Fix JBWS-1564 (Support swaRef for JAX-WS)
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-03-07
15:59:41 UTC (rev 2545)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -173,6 +173,7 @@
if (paramMetaData.isSwA())
{
+ // NOTE: swa:ref is handled by the AttachmentMarshaller callback
CIDGenerator cidGenerator = reqMessage.getCidGenerator();
AttachmentPart part = createAttachmentPart(paramMetaData, value,
cidGenerator);
reqMessage.addAttachmentPart(part);
@@ -231,7 +232,7 @@
try
{
// Read the SOAPEnvelope from the reqMessage
- SOAPMessage reqMessage = (SOAPMessage)payload;
+ SOAPMessageImpl reqMessage = (SOAPMessageImpl)payload;
SOAPEnvelope soapEnvelope = reqMessage.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnvelope.getHeader();
SOAPBody soapBody = soapEnvelope.getBody();
@@ -428,7 +429,7 @@
}
// WS-Addressing might redirect the response, which results in an empty
envelope
- SOAPMessage resMessage = (SOAPMessage)payload;
+ SOAPMessageImpl resMessage = (SOAPMessageImpl)payload;
SOAPEnvelope soapEnvelope = resMessage.getSOAPPart().getEnvelope();
if (soapEnvelope == null)
{
@@ -684,6 +685,12 @@
SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
soapMessage.setXOPMessage(true);
}
+ else if(paramMetaData.isSwaRef())
+ {
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
+ soapMessage.setSWARefMessage(true);
+ }
contentElement.setObjectValue(value);
@@ -782,6 +789,12 @@
SOAPMessageImpl soapMessage =
(SOAPMessageImpl)MessageContextAssociation.peekMessageContext().getSOAPMessage();
soapMessage.setXOPMessage(true);
}
+ else if(paramMetaData.isSwaRef())
+ {
+ SOAPMessageImpl soapMessage =
(SOAPMessageImpl)MessageContextAssociation.peekMessageContext().getSOAPMessage();
+ soapMessage.setSWARefMessage(true);
+ }
+
return soapContentElement;
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2007-03-07
15:59:41 UTC (rev 2545)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -67,6 +67,7 @@
private List<AttachmentPart> attachments = new
LinkedList<AttachmentPart>();
private CIDGenerator cidGenerator = new CIDGenerator();
private boolean isXOPMessage;
+ private boolean isSWARefMessage;
private SOAPPartImpl soapPart;
private MultipartRelatedEncoder multipartRelatedEncoder;
@@ -95,6 +96,16 @@
this.isXOPMessage = isXOPMessage;
}
+ public boolean isSWARefMessage()
+ {
+ return isSWARefMessage;
+ }
+
+ public void setSWARefMessage(boolean isSWAMessage)
+ {
+ this.isSWARefMessage = isSWAMessage;
+ }
+
public void setAttachments(Collection<AttachmentPart> parts) throws
SOAPException
{
for (AttachmentPart part : parts)
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/CIDGenerator.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/CIDGenerator.java 2007-03-07
15:59:41 UTC (rev 2545)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/CIDGenerator.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -47,7 +47,7 @@
StringBuilder cid = new StringBuilder();
long time = System.currentTimeMillis();
-
cid.append("cid:").append(count++).append("-").append(time).append("-")
+ cid.append(count++).append("-").append(time).append("-")
.append(cid.hashCode()).append("(a)").append(MimeConstants.CID_DOMAIN);
if(log.isDebugEnabled()) log.debug("generateFromCount: " + cid);
Modified: trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/XOPContext.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/XOPContext.java 2007-03-07
15:59:41 UTC (rev 2545)
+++ trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/XOPContext.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -88,6 +88,18 @@
return isXOP;
}
+ public static boolean isSWARefMessage()
+ {
+ boolean isSWARef = false;
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ if (msgContext != null)
+ {
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
+ isSWARef = (soapMessage != null && soapMessage.isSWARefMessage());
+ }
+ return isSWARef;
+ }
+
/**
* Check if the wire format is actually a xop encoded multipart message
*/
@@ -195,7 +207,7 @@
*/
public static void eagerlyCreateAttachments()
{
- if (!isXOPMessage())
+ if (!isXOPMessage() && !isSWARefMessage())
return;
try
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentMarshallerImpl.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentMarshallerImpl.java 2007-03-07
15:59:41 UTC (rev 2545)
+++
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentMarshallerImpl.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -6,7 +6,6 @@
import javax.xml.soap.AttachmentPart;
import org.jboss.logging.Logger;
-import org.jboss.ws.WSException;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.SOAPMessageImpl;
@@ -79,7 +78,17 @@
public String addSwaRefAttachment(DataHandler dataHandler)
{
- throw new WSException("Not yet implemented");
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
+
+ String cid = soapMessage.getCidGenerator().generateFromCount();
+ AttachmentPart swaRefPart = soapMessage.createAttachmentPart(dataHandler);
+ swaRefPart.addMimeHeader(MimeConstants.CONTENT_ID, '<' + cid +
'>'); // RFC2392 requirement
+ soapMessage.addAttachmentPart(swaRefPart);
+
+ if(log.isDebugEnabled()) log.debug("Created attachment part " + cid +
", with content-type " + swaRefPart.getContentType());
+
+ return "cid:" + cid;
}
public boolean isXOPPackage()
Added:
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java
(rev 0)
+++
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentScanResult.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.xop.jaxws;
+
+/**
+ * @author Heiko.Braun(a)jboss.org
+ * @version $Id$
+ * @since Mar 7, 2007
+ */
+public final class AttachmentScanResult {
+
+ public enum Type {XOP, SWA_REF};
+
+ private String mimeType;
+ private Type type;
+
+ public AttachmentScanResult(String mimeType, Type type)
+ {
+ this.mimeType = mimeType;
+ this.type = type;
+ }
+
+ public String getMimeType()
+ {
+ return mimeType;
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentUnmarshallerImpl.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentUnmarshallerImpl.java 2007-03-07
15:59:41 UTC (rev 2545)
+++
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/AttachmentUnmarshallerImpl.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -10,6 +10,9 @@
import org.jboss.ws.WSException;
import org.jboss.ws.core.soap.attachment.ContentHandlerRegistry;
+import org.jboss.ws.core.soap.MessageContextAssociation;
+import org.jboss.ws.core.soap.SOAPMessageImpl;
+import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.extensions.xop.XOPContext;
public class AttachmentUnmarshallerImpl extends AttachmentUnmarshaller
@@ -28,7 +31,7 @@
public boolean isXOPPackage()
{
- return XOPContext.isXOPMessage();
+ return XOPContext.isXOPMessage();
}
public DataHandler getAttachmentAsDataHandler(String cid)
Added:
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java
(rev 0)
+++
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveAttachmentRefScanner.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -0,0 +1,176 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.ws.extensions.xop.jaxws;
+
+import java.awt.Image;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.transform.Source;
+
+import org.jboss.ws.core.utils.JavaUtils;
+
+/**
+ * Scans data types for MTOM and swaRef declarations.
+ * It basically searches for
+ * <ul>
+ * <li><code>@XmlMimeType</code>
+ * <li><code>@XmlAttachmentRef</code>
+ * </ul>
+ * and returns the appropriate mimetype.
+ * In order to re-use an instance of this class you need to invoke
<code>reset()</code>
+ * in between scans.
+ *
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @version $Id$
+ * @since 04.12.2006
+ *
+ */
+public class ReflectiveAttachmentRefScanner {
+
+ private static List<Class> SUPPORTED_TYPES = new ArrayList<Class>(5);
+
+ public static enum ResultType {XOP, SWA_REF};
+
+ static {
+ SUPPORTED_TYPES.add(String.class);
+ SUPPORTED_TYPES.add(byte[].class);
+ SUPPORTED_TYPES.add(Image.class);
+ SUPPORTED_TYPES.add(Source.class);
+ SUPPORTED_TYPES.add(DataHandler.class);
+ }
+
+ private List<Field> scannedFields = new ArrayList<Field>();
+
+ /**
+ * Scan java types for MTOM declarations
+ *
+ * @param xmlRoot
+ * @return the first matching XmlMimeType#value() or <code>null</code> if
none found
+ */
+ public AttachmentScanResult scan(Class xmlRoot)
+ {
+ if( isJDKType(xmlRoot) )
+ return null;
+
+ AttachmentScanResult result = null;
+
+ for(Field field : xmlRoot.getDeclaredFields())
+ {
+ Class<?> type = field.getType();
+
+ boolean exceptionToTheRule = isAttachmentDataType(type);
+
+ // only non JDK types are inspected except for byte[] and java.lang.String
+ if( !alreadyScanned(field) && (exceptionToTheRule || !isJDKType(type))
)
+ {
+
+ // Scan for swa:Ref type declarations first
+ if(field.isAnnotationPresent(XmlAttachmentRef.class))
+ {
+ // arbitrary, it's not used
+ result = new AttachmentScanResult("application/octet-stream",
AttachmentScanResult.Type.SWA_REF);
+ }
+
+ // Scan for XOP field annotations
+ else if(field.isAnnotationPresent(XmlMimeType.class))
+ {
+ XmlMimeType mimeTypeDecl = field.getAnnotation(XmlMimeType.class);
+ result = new AttachmentScanResult(mimeTypeDecl.value(),
AttachmentScanResult.Type.XOP);
+ }
+
+ if(null == result) // try getter methods
+ {
+ String mimeType = scanGetterAnnotation(xmlRoot, field);
+ if(mimeType!=null)
+ result = new AttachmentScanResult(mimeType,
AttachmentScanResult.Type.XOP);
+ }
+
+ // avoid recursive loops
+ if(!isAttachmentDataType(type))
+ scannedFields.add(field);
+
+ // drill down if none found so far
+ if(null == result)
+ result = scan(type);
+
+ }
+
+ }
+
+ return result;
+ }
+
+ private boolean alreadyScanned(Field field)
+ {
+
+ for(Field f : scannedFields)
+ {
+ if(f.equals(field))
+ return true;
+ }
+
+ return false;
+ }
+
+ public void reset()
+ {
+ scannedFields.clear();
+ }
+
+ private static boolean isAttachmentDataType(Class clazz) {
+ for(Class cl : SUPPORTED_TYPES)
+ {
+ if(JavaUtils.isAssignableFrom(cl, clazz))
+ return true;
+ }
+
+ return false;
+ }
+
+ private static boolean isJDKType(Class clazz)
+ {
+ return clazz.getPackage()!= null ?
clazz.getPackage().getName().startsWith("java") : true;
+ }
+
+ private static String scanGetterAnnotation(Class owner, Field field)
+ {
+ String getterMethodName = "get"+field.getName();
+ for(Method method : owner.getDeclaredMethods())
+ {
+ if(method.getName().equalsIgnoreCase(getterMethodName)
+ && method.isAnnotationPresent(XmlMimeType.class))
+ {
+ XmlMimeType mimeTypeDecl = method.getAnnotation(XmlMimeType.class);
+ return mimeTypeDecl.value();
+ }
+ }
+
+ return null;
+ }
+}
Deleted:
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveXOPScanner.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveXOPScanner.java 2007-03-07
15:59:41 UTC (rev 2545)
+++
trunk/jbossws-core/src/java/org/jboss/ws/extensions/xop/jaxws/ReflectiveXOPScanner.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -1,156 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.ws.extensions.xop.jaxws;
-
-import java.awt.Image;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.activation.DataHandler;
-import javax.xml.bind.annotation.XmlMimeType;
-import javax.xml.transform.Source;
-
-import org.jboss.ws.core.utils.JavaUtils;
-
-/**
- * Scans data types for MTOM declarations.
- * In order to re-use an instance of this class you need to invoke
<code>reset()</code>
- * in between scans.
- *
- * @author Heiko Braun <heiko.braun(a)jboss.com>
- * @version $Id$
- * @since 04.12.2006
- *
- */
-public class ReflectiveXOPScanner {
-
- private static List<Class> SUPPORTED_TYPES = new ArrayList<Class>(5);
-
- static {
- SUPPORTED_TYPES.add(String.class);
- SUPPORTED_TYPES.add(byte[].class);
- SUPPORTED_TYPES.add(Image.class);
- SUPPORTED_TYPES.add(Source.class);
- SUPPORTED_TYPES.add(DataHandler.class);
- }
-
- private List<Field> scannedFields = new ArrayList<Field>();
-
- /**
- * Scan java types for MTOM declarations
- *
- * @param xmlRoot
- * @return the first matching XmlMimeType#value() or <code>null</code> if
none found
- */
- public String scan(Class xmlRoot)
- {
-
- if( isJDKType(xmlRoot) )
- return null;
-
- String mimeType = null;
-
- for(Field field : xmlRoot.getDeclaredFields())
- {
- Class<?> type = field.getType();
-
- boolean exceptionToTheRule = isMTOMDataType(type);
-
- // only non JDK types are inspected except for byte[] and java.lang.String
- if( !alreadyScanned(field) && (exceptionToTheRule || !isJDKType(type))
)
- {
- if(field.isAnnotationPresent(XmlMimeType.class))
- {
- XmlMimeType mimeTypeDecl = field.getAnnotation(XmlMimeType.class);
- mimeType = mimeTypeDecl.value();
- }
-
- if(null == mimeType) // try getter methods
- {
- mimeType = scanGetterAnnotation(xmlRoot, field);
- }
-
- // avoid recursive loops
- if(!isMTOMDataType(type))
- scannedFields.add(field);
-
- // drill down if none found so far
- if(null == mimeType)
- mimeType = scan(type);
-
- }
-
- }
-
- return mimeType;
- }
-
- private boolean alreadyScanned(Field field)
- {
-
- for(Field f : scannedFields)
- {
- if(f.equals(field))
- return true;
- }
-
- return false;
- }
-
- public void reset()
- {
- scannedFields.clear();
- }
-
- private static boolean isMTOMDataType(Class clazz) {
- for(Class cl : SUPPORTED_TYPES)
- {
- if(JavaUtils.isAssignableFrom(cl, clazz))
- return true;
- }
-
- return false;
- }
-
- private static boolean isJDKType(Class clazz)
- {
- return clazz.getPackage()!= null ?
clazz.getPackage().getName().startsWith("java") : true;
- }
-
- private static String scanGetterAnnotation(Class owner, Field field)
- {
- String getterMethodName = "get"+field.getName();
- for(Method method : owner.getDeclaredMethods())
- {
- if(method.getName().equalsIgnoreCase(getterMethodName)
- && method.isAnnotationPresent(XmlMimeType.class))
- {
- XmlMimeType mimeTypeDecl = method.getAnnotation(XmlMimeType.class);
- return mimeTypeDecl.value();
- }
- }
-
- return null;
- }
-}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-03-07
15:59:41 UTC (rev 2545)
+++
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -758,7 +758,7 @@
if (!RemoteException.class.isAssignableFrom(exClass))
addFault(opMetaData, exClass);
- // process op meta data extension
+ // process operation meta data extension
processMetaExtensions(method, epMetaData, opMetaData);
}
@@ -788,9 +788,10 @@
String partName = mimePart.getPartName();
if(paramMetaData.getPartName().equals(partName))
{
- log.debug("Identified SWA parameter: " + partName +
", mimeTypes=" +mimePart.getMimeTypes());
+ log.debug("Identified 'mime:content' binding:
" + partName + ", mimeTypes=" +mimePart.getMimeTypes());
paramMetaData.setSwA(true);
paramMetaData.setMimeTypes(mimePart.getMimeTypes());
+ break;
}
}
}
@@ -798,6 +799,7 @@
}
}
}
+
}
protected void processWebMethods(EndpointMetaData epMetaData, Class wsClass)
Modified: trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-03-07
15:59:41 UTC (rev 2545)
+++
trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -40,7 +40,8 @@
import org.jboss.ws.core.jaxws.DynamicWrapperGenerator;
import org.jboss.ws.core.utils.HolderUtils;
import org.jboss.ws.core.utils.JavaUtils;
-import org.jboss.ws.extensions.xop.jaxws.ReflectiveXOPScanner;
+import org.jboss.ws.extensions.xop.jaxws.ReflectiveAttachmentRefScanner;
+import org.jboss.ws.extensions.xop.jaxws.AttachmentScanResult;
import org.jboss.ws.metadata.acessor.ReflectiveMethodAccessor;
import org.jboss.ws.metadata.umdm.EndpointMetaData.Type;
@@ -69,6 +70,7 @@
private boolean inHeader;
private boolean isSwA;
private boolean isXOP;
+ private boolean isSwaRef;
private List<WrappedParameter> wrappedParameters;
private int index;
@@ -330,6 +332,16 @@
this.isSwA = isSwA;
}
+ public boolean isSwaRef()
+ {
+ return isSwaRef;
+ }
+
+ public void setSwaRef(boolean swaRef)
+ {
+ isSwaRef = swaRef;
+ }
+
public boolean isXOP()
{
return isXOP;
@@ -458,15 +470,27 @@
if (javaType == null)
throw new WSException("Cannot load java type: " + javaTypeName);
- // check if the JavaType is an mtom parameter
- if (epType == EndpointMetaData.Type.JAXWS)
+ initializeAttachmentParameter(epType);
+ }
+
+ /**
+ * Identify MTOM and SWA:Ref parameter as these require special treatment.
+ * This only affects JAX-WS endpoints
+ * @param epType
+ */
+ private void initializeAttachmentParameter(Type epType)
+ {
+ if (epType == Type.JAXWS)
{
- ReflectiveXOPScanner scanner = new ReflectiveXOPScanner();
- String mimeType = scanner.scan(javaType);
- if (mimeType != null)
+ ReflectiveAttachmentRefScanner scanner = new ReflectiveAttachmentRefScanner();
+ AttachmentScanResult scanResult = scanner.scan(javaType);
+ if (scanResult != null)
{
- if(log.isDebugEnabled()) log.debug("MTOM parameter found: " +
xmlName);
- setXOP(true);
+ if(log.isDebugEnabled()) log.debug("Identified attachment reference:
" + xmlName + ", type="+scanResult.getType());
+ if(scanResult.getType() == AttachmentScanResult.Type.XOP)
+ setXOP(true);
+ else
+ setSwaRef(true);
}
}
}
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java 2007-03-07
15:59:41 UTC (rev 2545)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java 2007-03-07
16:02:15 UTC (rev 2546)
@@ -25,7 +25,8 @@
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.extensions.xop.XOPContext;
-import org.jboss.ws.extensions.xop.jaxws.ReflectiveXOPScanner;
+import org.jboss.ws.extensions.xop.jaxws.ReflectiveAttachmentRefScanner;
+import org.jboss.ws.extensions.xop.jaxws.AttachmentScanResult;
import javax.xml.bind.annotation.XmlMimeType;
import java.awt.*;
@@ -40,7 +41,7 @@
*/
public class MimeDeclarationTestCase extends TestCase {
- static ReflectiveXOPScanner SCANNER = new ReflectiveXOPScanner();
+ static ReflectiveAttachmentRefScanner SCANNER = new ReflectiveAttachmentRefScanner();
protected void setUp() throws Exception
@@ -50,20 +51,20 @@
public void testFieldAnnotation() throws Exception
{
- String mimeType = SCANNER.scan(FieldAnnotation.class);
+ AttachmentScanResult mimeType = SCANNER.scan(FieldAnnotation.class);
assertNotNull("Unable to find xop declaration", mimeType);
- assertEquals("text/xml", mimeType);
+ assertEquals("text/xml", mimeType.getMimeType());
}
public void testMethodAnnotation() throws Exception
{
- String mimeType = SCANNER.scan(MethodAnnotation.class);
+ AttachmentScanResult mimeType = SCANNER.scan(MethodAnnotation.class);
assertNotNull("Unable to find xop declaration", mimeType);
}
public void testAnnotationMissing() throws Exception
{
- String mimeType = SCANNER.scan(NoAnnotation.class);
+ AttachmentScanResult mimeType = SCANNER.scan(NoAnnotation.class);
assertNull("There should be no mimeType available", mimeType);
}
@@ -81,22 +82,22 @@
System.out.println(m.getParameterAnnotations().length);
- String mimeType = SCANNER.scan( m.getParameterTypes()[0]);
+ AttachmentScanResult mimeType = SCANNER.scan( m.getParameterTypes()[0]);
assertNotNull("Unable to find xop declaration", mimeType);
- assertEquals("text/xml", mimeType);
+ assertEquals("text/xml", mimeType.getMimeType());
}
public void testSimpleRecursion() throws Exception
{
- String mimeType = SCANNER.scan(SimpleRecursion.class);
+ AttachmentScanResult mimeType = SCANNER.scan(SimpleRecursion.class);
assertNull(mimeType);
}
public void testComplexRecursion() throws Exception
{
- String mimeType = SCANNER.scan(ComplexRecursion.class);
+ AttachmentScanResult mimeType = SCANNER.scan(ComplexRecursion.class);
assertNotNull("Unable to find xop declaration", mimeType);
- assertEquals("text/plain", mimeType);
+ assertEquals("text/plain", mimeType.getMimeType());
}
public void testXOPContext()