Author: heiko.braun(a)jboss.com
Date: 2006-12-04 12:35:57 -0500 (Mon, 04 Dec 2006)
New Revision: 1549
Added:
trunk/src/main/java/org/jboss/ws/xop/jaxrpc/
trunk/src/main/java/org/jboss/ws/xop/jaxrpc/JBossXBContentAdapter.java
trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPMarshallerImpl.java
trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPScanner.java
trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPUnmarshallerImpl.java
trunk/src/main/java/org/jboss/ws/xop/jaxws/
trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentMarshallerImpl.java
trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentUnmarshallerImpl.java
trunk/src/main/java/org/jboss/ws/xop/jaxws/ReflectiveXOPScanner.java
trunk/src/test/java/org/jboss/test/ws/Runner.java
trunk/src/test/java/org/jboss/test/ws/jaxws/xop/
trunk/src/test/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java
Removed:
trunk/src/main/java/org/jboss/ws/xop/JBossXBContentAdapter.java
trunk/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java
trunk/src/main/java/org/jboss/ws/xop/XOPScanner.java
trunk/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java
Modified:
trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Deserializer.java
trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Serializer.java
trunk/src/main/java/org/jboss/ws/jaxws/JAXBDeserializer.java
trunk/src/main/java/org/jboss/ws/jaxws/JAXBSerializer.java
trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBMarshallerImpl.java
trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBUnmarshallerImpl.java
trunk/src/main/java/org/jboss/ws/jbossxb/SchemaBindingBuilder.java
trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/xop/XOPContext.java
trunk/src/test/java/org/jboss/test/ws/jaxrpc/xop/XOPTypeDefTestCase.java
Log:
added reflective XOP scanner for JAXWS
Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Deserializer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Deserializer.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Deserializer.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -30,7 +30,7 @@
import org.jboss.ws.binding.DeserializerSupport;
import org.jboss.ws.binding.SerializationContext;
import org.jboss.ws.xop.XOPContext;
-import org.jboss.ws.xop.XOPUnmarshallerImpl;
+import org.jboss.ws.xop.jaxrpc.XOPUnmarshallerImpl;
import org.jboss.ws.utils.DOMUtils;
import org.jboss.ws.WSException;
import org.jboss.xb.binding.SimpleTypeBindings;
Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Serializer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Serializer.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/encoding/Base64Serializer.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -31,7 +31,7 @@
import org.jboss.ws.binding.SerializerSupport;
import org.jboss.ws.utils.JavaUtils;
import org.jboss.ws.xop.XOPContext;
-import org.jboss.ws.xop.XOPMarshallerImpl;
+import org.jboss.ws.xop.jaxrpc.XOPMarshallerImpl;
import org.jboss.xb.binding.NamespaceRegistry;
import org.jboss.xb.binding.SimpleTypeBindings;
import org.jboss.xb.binding.sunday.xop.XOPMarshaller;
Modified: trunk/src/main/java/org/jboss/ws/jaxws/JAXBDeserializer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/JAXBDeserializer.java 2006-12-04 17:05:16 UTC
(rev 1548)
+++ trunk/src/main/java/org/jboss/ws/jaxws/JAXBDeserializer.java 2006-12-04 17:35:57 UTC
(rev 1549)
@@ -37,6 +37,7 @@
import org.jboss.ws.binding.ComplexTypeDeserializer;
import org.jboss.ws.binding.SerializationContext;
import org.jboss.ws.jaxrpc.TypeMappingImpl;
+import org.jboss.ws.xop.jaxws.AttachmentUnmarshallerImpl;
/**
* A Deserializer that can handle complex types by delegating to JAXB.
@@ -65,7 +66,8 @@
Class javaType = typeMapping.getJavaType(xmlType);
JAXBContext jaxbContext = JAXBContext.newInstance(javaType);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-
+ unmarshaller.setAttachmentUnmarshaller( new AttachmentUnmarshallerImpl());
+
ByteArrayInputStream ins = new
ByteArrayInputStream(val.getBytes("UTF-8"));
JAXBElement jbe = unmarshaller.unmarshal(new StreamSource(ins), javaType);
value = jbe.getValue();
Modified: trunk/src/main/java/org/jboss/ws/jaxws/JAXBSerializer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/JAXBSerializer.java 2006-12-04 17:05:16 UTC
(rev 1548)
+++ trunk/src/main/java/org/jboss/ws/jaxws/JAXBSerializer.java 2006-12-04 17:35:57 UTC
(rev 1549)
@@ -36,6 +36,7 @@
import org.jboss.ws.binding.ComplexTypeSerializer;
import org.jboss.ws.binding.SerializationContext;
import org.jboss.ws.jaxrpc.TypeMappingImpl;
+import org.jboss.ws.xop.jaxws.AttachmentMarshallerImpl;
import org.w3c.dom.NamedNodeMap;
/**
@@ -66,8 +67,9 @@
JAXBContext jaxbContext = JAXBContext.newInstance(javaType);
Marshaller marshaller = jaxbContext.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
-
+ marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
+ marshaller.setAttachmentMarshaller(new AttachmentMarshallerImpl());
+
StringWriter strwr = new StringWriter();
marshaller.marshal(new JAXBElement(xmlName, javaType, value), strwr);
xmlFragment = strwr.toString();
Modified: trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBMarshallerImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBMarshallerImpl.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBMarshallerImpl.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -30,7 +30,7 @@
import org.jboss.ws.metadata.jaxrpcmapping.JavaXmlTypeMapping;
import org.jboss.ws.metadata.jaxrpcmapping.VariableMapping;
import org.jboss.ws.utils.JavaUtils;
-import org.jboss.ws.xop.XOPMarshallerImpl;
+import org.jboss.ws.xop.jaxrpc.XOPMarshallerImpl;
import org.jboss.xb.binding.Constants;
import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
Modified: trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBUnmarshallerImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBUnmarshallerImpl.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/jbossxb/JBossXBUnmarshallerImpl.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -24,7 +24,7 @@
// $Id$
import org.jboss.ws.WSException;
-import org.jboss.ws.xop.XOPUnmarshallerImpl;
+import org.jboss.ws.xop.jaxrpc.XOPUnmarshallerImpl;
import org.jboss.xb.binding.JBossXBException;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
Modified: trunk/src/main/java/org/jboss/ws/jbossxb/SchemaBindingBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jbossxb/SchemaBindingBuilder.java 2006-12-04 17:05:16
UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/jbossxb/SchemaBindingBuilder.java 2006-12-04 17:35:57
UTC (rev 1549)
@@ -30,7 +30,7 @@
import org.jboss.ws.WSException;
import org.jboss.ws.metadata.jaxrpcmapping.*;
import org.jboss.ws.utils.JBossWSEntityResolver;
-import org.jboss.ws.xop.JBossXBContentAdapter;
+import org.jboss.ws.xop.jaxrpc.JBossXBContentAdapter;
import org.jboss.xb.binding.metadata.ClassMetaData;
import org.jboss.xb.binding.metadata.PackageMetaData;
import org.jboss.xb.binding.metadata.PropertyMetaData;
Modified: trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java 2006-12-04 17:05:16
UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/metadata/ParameterMetaData.java 2006-12-04 17:35:57
UTC (rev 1549)
@@ -172,6 +172,11 @@
setMimeTypes(mimeType);
this.isSwA = true;
}
+ else if(Constants.NS_SCHEMA_XSD.equals(xmlType.getNamespaceURI())
+ && "base64Binary".equals(xmlType.getLocalPart()))
+ {
+ setXOP(true);
+ }
}
public String getJavaTypeName()
Modified:
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java 2006-12-04
17:05:16 UTC (rev 1548)
+++
trunk/src/main/java/org/jboss/ws/metadata/builder/jaxrpc/JAXRPCMetaDataBuilder.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -32,14 +32,12 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.encoding.TypeMappingRegistry;
-import javax.xml.ws.addressing.AddressingConstants;
import javax.xml.ws.addressing.AddressingProperties;
import org.apache.xerces.xs.XSTypeDefinition;
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
-import org.jboss.ws.addressing.AddressingConstantsImpl;
import org.jboss.ws.addressing.AddressingPropertiesImpl;
import org.jboss.ws.addressing.metadata.AddressingOpMetaExt;
import org.jboss.ws.eventing.EventingConstants;
@@ -93,7 +91,7 @@
import org.jboss.ws.metadata.wsdl.WSDLRPCSignatureItem.Direction;
import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
import org.jboss.ws.utils.JavaUtils;
-import org.jboss.ws.xop.XOPScanner;
+import org.jboss.ws.xop.jaxrpc.XOPScanner;
/**
* A meta data builder that is based on webservices.xml.
Deleted: trunk/src/main/java/org/jboss/ws/xop/JBossXBContentAdapter.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/JBossXBContentAdapter.java 2006-12-04 17:05:16
UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/xop/JBossXBContentAdapter.java 2006-12-04 17:35:57
UTC (rev 1549)
@@ -1,234 +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.xop;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.Constants;
-import org.jboss.ws.WSException;
-import org.jboss.ws.soap.attachment.ContentHandlerRegistry;
-import org.jboss.ws.soap.attachment.SwapableMemoryDataSource;
-import org.jboss.ws.utils.IOUtils;
-import org.jboss.ws.utils.MimeUtils;
-import org.jboss.xb.binding.sunday.marshalling.MarshallingContext;
-import org.jboss.xb.binding.sunday.marshalling.TermBeforeMarshallingCallback;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.TermBeforeSetParentCallback;
-import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.UnmarshallingContext;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.xml.namespace.QName;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Adopts raw binary contents to java types.
- * This class works in conjunction with the <code>XOPUnmarshallerImpl</code>
- * and <code>XOPMarshallerImpl</code>.
- *
- * @see XOPUnmarshallerImpl
- * @see XOPMarshallerImpl
- *
- * @author Heiko Braun <heiko.braun(a)jboss.com>
- * @version $Id: JBossXBContentAdapter.java 1322 2006-10-27 13:27:04Z
heiko.braun(a)jboss.com $
- * @since Oct 19, 2006
- */
-public class JBossXBContentAdapter implements TermBeforeMarshallingCallback,
TermBeforeSetParentCallback {
-
- private static final Logger log = Logger.getLogger(JBossXBContentAdapter.class);
- private static final QName XMIME_BASE_64 = new QName(Constants.NS_XML_MIME,
"base64Binary");
- private static final QName XOP_INCLUDE = new QName(Constants.NS_XOP,
"Include");
-
- static
- {
- // Load JAF content handlers
- ContentHandlerRegistry.register();
- }
-
- /**
- * When XOP is disabled we need to convert java types to byte[]
- * before handing off to XB.
- */
- public Object beforeMarshalling(Object object, MarshallingContext marshallingContext)
{
-
- boolean mtomDisabled = !XOPContext.isMTOMEnabled();
- boolean convertableType = object!=null && !(object instanceof byte[]);
-
- if( mtomDisabled && convertableType )
- {
- String contentType = MimeUtils.resolveMimeType(object);
- log.debug("Adopt " + object.getClass() + " to byte[], contentType
" + contentType);
-
- DataHandler dh = new DataHandler(object, contentType);
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- try
- {
- IOUtils.copyStream(bout, dh.getInputStream());
- object = bout.toByteArray();
- }
- catch (IOException e)
- {
- throw new WSException("Failed to adopt XOP content type", e);
- }
- }
-
- return object;
- }
-
- /**
- * When XOP is disabled (inlined request) we receive a byte[] from XB
- * that needs to be converted in to java type
- */
- public Object beforeSetParent(Object object, UnmarshallingContext ctx) {
-
- if(null==object)
- return object;
-
- // may be null when it's actually an encoded request ?!
- Class targetClass = ctx.resolvePropertyType();
-
- if(null==targetClass) {
- throw new WSException("Failed to resolve target property type on "+
ctx.getParticle());
- }
-
- boolean isRegularMessage = !XOPContext.isXOPMessage();
- boolean isSimpleType = (object instanceof byte[]);
- boolean doTypesMatch = ( targetClass.equals(object.getClass()) );
-
- // Handle inlined requests.
- // In this case XB treats binaries as simple types that are unmarshalled to byte[]
- // Still type conversion will be necessary.
- if( isRegularMessage && isSimpleType && !doTypesMatch)
- {
- String contentType = MimeUtils.resolveMimeType(targetClass);
- log.debug("Adopt byte[] to " + targetClass +", contentType
"+ contentType);
-
- try
- {
- DataHandler dh = new DataHandler(
- wrapAsDataSource(object, contentType)
- );
-
- if(targetClass.equals(DataHandler.class))
- object = dh;
- else
- object = dh.getContent();
- }
- catch (IOException e)
- {
- throw new WSException("Failed to adopt XOP content type", e);
- }
- }
-
- // Handle XOP encoded requests.
- // XB will use the XOPUnmarshaller callback and receive a DataHandler instance.
- // In this case we are be able to instantiate the correct content object
- // from the data handler, with the exception of content-type
'application/octet-stream'.
- // These attachments will be returned as DataHandler instances.
- else if(XOPContext.isXOPMessage() && (object instanceof DataHandler)
&& !doTypesMatch)
- {
- try
- {
- String contentType = MimeUtils.resolveMimeType(targetClass);
- log.debug("Adopt DataHandler to " + targetClass +",
contentType "+ contentType);
-
- DataHandler dh = new DataHandler(
- wrapAsDataSource(object, contentType)
- );
- object = dh.getContent();
-
- // 'application/octet-stream' will return a byte[] instead fo the
stream
- if(object instanceof InputStream)
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- dh.writeTo(bout);
- object = bout.toByteArray();
- }
- }
- catch (IOException e)
- {
- throw new WSException("Failed to adopt XOP content type", e);
- }
- }
-
- return object;
- }
-
- private DataSource wrapAsDataSource(Object object, String contentType) throws
IOException {
-
- DataSource ds;
-
- if(object instanceof byte[])
- {
- ds = new SwapableMemoryDataSource(new ByteArrayInputStream((byte[])object),
contentType);
- }
- else if(object instanceof DataHandler)
- {
- ds = new SwapableMemoryDataSource(((DataHandler)object).getInputStream(),
contentType);
- }
- else
- {
- throw new IllegalArgumentException("Failed to wrap as data source:
"+object.getClass());
- }
-
- return ds;
- }
-
- /**
- * A factory method that registers the XB (un)marshalling adapters with schema
binding.
- * These adapters convert java types into byte[] and reverse,
- * in order to match the jaxrpc-mapping declaration in case we receive or send an
inlined request.
- */
- public static void register(SchemaBinding schemaBinding)
- {
- JBossXBContentAdapter contentAdapter = new JBossXBContentAdapter();
-
- // base64 simple types
- TypeBinding base64Type =
schemaBinding.getType(org.jboss.xb.binding.Constants.QNAME_BASE64BINARY);
- base64Type.setBeforeMarshallingCallback( contentAdapter );
- base64Type.setBeforeSetParentCallback( contentAdapter );
-
- // xmime complex types
- TypeBinding xmimeBase64Type = schemaBinding.getType(XMIME_BASE_64);
- if(xmimeBase64Type!=null)
- {
- xmimeBase64Type.setBeforeMarshallingCallback( contentAdapter );
- xmimeBase64Type.setBeforeSetParentCallback( contentAdapter );
-
- // xop:Include
- /*ModelGroupBinding modelGroup =
(ModelGroupBinding)xmimeBase64Type.getParticle().getTerm();
- ParticleBinding particle =
(ParticleBinding)modelGroup.getParticles().iterator().next();
- ElementBinding xopInclude = (ElementBinding)particle.getTerm();
-
- if(! xopInclude.getQName().equals(XOP_INCLUDE))
- throw new WSException("Looks like the JBossXB XOP implementation has
changed, please open a JIRA issue");
-
- xopInclude.setBeforeMarshallingCallback(contentAdapter);
- xopInclude.setBeforeSetParentCallback(contentAdapter);
- */
- }
- }
-
-}
Modified: trunk/src/main/java/org/jboss/ws/xop/XOPContext.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/XOPContext.java 2006-12-04 17:05:16 UTC (rev
1548)
+++ trunk/src/main/java/org/jboss/ws/xop/XOPContext.java 2006-12-04 17:35:57 UTC (rev
1549)
@@ -24,6 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
+import org.jboss.ws.xop.jaxrpc.XOPMarshallerImpl;
import org.jboss.ws.common.CommonMessageContext;
import org.jboss.ws.jaxrpc.StubExt;
import org.jboss.ws.soap.MessageContextAssociation;
@@ -52,7 +53,7 @@
* look at the SOAPContentElement implementation.
*
* @see org.jboss.ws.soap.SOAPContentElement#handleMTOMTransitions()
- * @see XOPUnmarshallerImpl
+ * @see org.jboss.ws.xop.jaxrpc.XOPUnmarshallerImpl
* @see XOPMarshallerImpl
*
* @author Heiko Braun <heiko.braun(a)jboss.com>
Deleted: trunk/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java 2006-12-04 17:05:16 UTC
(rev 1548)
+++ trunk/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java 2006-12-04 17:35:57 UTC
(rev 1549)
@@ -1,105 +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.xop;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
-import org.jboss.ws.common.CommonMessageContext;
-import org.jboss.ws.soap.MessageContextAssociation;
-import org.jboss.ws.soap.SOAPMessageImpl;
-import org.jboss.ws.soap.attachment.ContentHandlerRegistry;
-import org.jboss.ws.soap.attachment.MimeConstants;
-import org.jboss.xb.binding.sunday.xop.XOPMarshaller;
-import org.jboss.xb.binding.sunday.xop.XOPObject;
-
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import javax.xml.soap.AttachmentPart;
-
-/**
- * The XOPUnmarshallerImpl allows callbacks from the binding layer towards the
- * soap processing components in order to optimize binary processing.
- *
- * @see org.jboss.ws.xop.XOPUnmarshallerImpl
- *
- * @author Heiko Braun <heiko.braun(a)jboss.com>
- * @since May 9, 2006
- * @version $Id$
- */
-public class XOPMarshallerImpl implements XOPMarshaller {
-
- private static final Logger log = Logger.getLogger(XOPMarshallerImpl.class);
-
- static
- {
- // Load JAF content handlers
- ContentHandlerRegistry.register();
- }
-
- public boolean isXOPPackage()
- {
- return XOPContext.isXOPMessage();
- }
-
- public String addMtomAttachment(XOPObject obj, String elementNamespace, String
elementName)
- {
-
- CommonMessageContext msgContext =
(CommonMessageContext)MessageContextAssociation.peekMessageContext();
- SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
-
- QName xmlName = new QName(elementNamespace, elementName);
- log.debug("serialize: [xmlName=" + xmlName + "]");
-
- String cid =
soapMessage.getCidGenerator().generateFromName(xmlName.getLocalPart());
-
- DataHandler dataHandler = XOPContext.createDataHandler(obj);
- AttachmentPart xopPart = soapMessage.createAttachmentPart(dataHandler);
- xopPart.addMimeHeader(MimeConstants.CONTENT_ID, '<'+cid+'>');
// RFC2392 requirement
- soapMessage.addAttachmentPart(xopPart);
-
- log.debug("Created attachment part " +cid+", with content-type
" +xopPart.getContentType());
-
- return "cid:" + cid;
-
- }
-
- public String addMtomAttachment(byte[] data, String elementNamespace, String
elementName)
- {
- /*
- TODO: this requires a java mail upgrade
- ByteArrayDataSource ds = new ByteArrayDataSource(data,
MimeConstants.TYPE_APPLICATION_OCTET_STREAM);
- return addMtomAttachment(
- new DataHandler(
- ds, MimeConstants.TYPE_APPLICATION_OCTET_STREAM),
- elementNamespace, elementName
- );*/
-
- throw new NotImplementedException("Not implemented yet");
- }
-
- public String addSwaRefAttachment(Object obj)
- {
- throw new NotImplementedException();
- }
-
-
-}
Deleted: trunk/src/main/java/org/jboss/ws/xop/XOPScanner.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/XOPScanner.java 2006-12-04 17:05:16 UTC (rev
1548)
+++ trunk/src/main/java/org/jboss/ws/xop/XOPScanner.java 2006-12-04 17:35:57 UTC (rev
1549)
@@ -1,146 +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.xop;
-
-import org.apache.xerces.xs.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Scans complex type definitions for nested XOP type declarations.
- * A XOP type declaration is identified as a complex type
- * that derives from xsd:base64Binary, i.e:
- *
- * <code> <pre>
- * <xs:complexType name="MyXOPElement" >
- * <xs:simpleContent>
- * <xs:extension base="xs:base64Binary" >
- * <xs:attribute ref="xmime:contentType" />
- * </xs:extension>
- * </xs:simpleContent>
- * </xs:complexType>
- * </pre></code>
- *
- * @author Heiko Braun <heiko.braun(a)jboss.com>
- * @since Jun 9, 2006
- * @version $Id$
- */
-public class XOPScanner {
-
- // avoid circular scans
- private List<String> scannedItems = new ArrayList<String>();
- private static final String BASE64_BINARY = "base64Binary";
-
- /**
- * Query a complex type for nested XOP type definitions.
- */
- public XSTypeDefinition findXOPTypeDef(XSTypeDefinition typeDef)
- {
- if(typeDef==null)
- return typeDef;
- XSTypeDefinition result = null;
- String name = typeDef.getName();
- String namespace = typeDef.getNamespace()!=null ?
typeDef.getNamespace():"";
-
- if(typeDef instanceof XSSimpleTypeDefinition &&
BASE64_BINARY.equals(name))
- {
- return typeDef;
- }
- else if(typeDef instanceof XSComplexTypeDefinition)
- {
- XSComplexTypeDefinition complexTypeDef = (XSComplexTypeDefinition)typeDef;
- if(name!=null)
- {
- String typeKey = namespace+":"+name;
-
- if(scannedItems.contains(typeKey))
- {
- return null;
- }
- else
- {
- scannedItems.add(typeKey);
- }
- }
-
- // An XOP parameter is detected if it is a complex type
- // that derives from xsd:base64Binary
- if (complexTypeDef.getSimpleType() != null)
- {
- String typeName = complexTypeDef.getSimpleType().getName();
- if (BASE64_BINARY.equals(typeName))
- return complexTypeDef;
- }
- else
- {
-
- XSModelGroup xm = null;
- if(complexTypeDef.getContentType() !=
XSComplexTypeDefinition.CONTENTTYPE_EMPTY)
- {
- XSParticle xp = complexTypeDef.getParticle();
- if (xp != null)
- {
- XSTerm xterm = xp.getTerm();
- if(xterm instanceof XSModelGroup)
- {
- xm = (XSModelGroup)xterm;
- //System.out.println("xm -> " + xm);
-
- XSObjectList xo = xm.getParticles();
-
- // interate over nested particles
- for(int i=0; i<xm.getParticles().getLength(); i++ )
- {
- XSTerm xsterm = ((XSParticle)xo.item(i)).getTerm();
-
- // Can be either XSModelGroup, XSWildcard, XSElementDeclaration
- // We only proceed with XSElementDeclaration
- if(xsterm instanceof XSElementDeclaration)
- {
- XSElementDeclaration xe = (XSElementDeclaration)xsterm;
- XSTypeDefinition nestedTypeDef = xe.getTypeDefinition();
-
- //System.out.println("Query nested -> " +
xe.getName());
- result = findXOPTypeDef(nestedTypeDef);
- }
- }
- }
- }
- }
-
- }
-
- //System.out.println("result -> " + result);
-
- }
-
- return result;
-
- }
-
- public void reset()
- {
- scannedItems.clear();
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java 2006-12-04 17:05:16 UTC
(rev 1548)
+++ trunk/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java 2006-12-04 17:35:57 UTC
(rev 1549)
@@ -1,105 +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.xop;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.Constants;
-import org.jboss.ws.WSException;
-import org.jboss.ws.soap.attachment.ContentHandlerRegistry;
-import org.jboss.xb.binding.sunday.xop.XOPObject;
-import org.jboss.xb.binding.sunday.xop.XOPUnmarshaller;
-
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import javax.xml.soap.AttachmentPart;
-import javax.xml.soap.SOAPException;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-/**
- * The XOPUnmarshallerImpl allows callbacks from the binding layer towards the
- * soap processing components in order to optimize binary processing.
- *
- * @see XOPMarshallerImpl
- *
- * @author Heiko Braun <heiko.braun(a)jboss.com>
- * @since May 9, 2006
- * @version $Id$
- */
-public class XOPUnmarshallerImpl implements XOPUnmarshaller {
-
- private static final Logger log = Logger.getLogger(XOPUnmarshallerImpl.class);
- private static final QName XOP_INCLUDE = new QName(Constants.NS_XOP,
"Include");
-
- static
- {
- // Load JAF content handlers
- ContentHandlerRegistry.register();
- }
-
- public boolean isXOPPackage()
- {
- return XOPContext.isXOPMessage();
- }
-
- public XOPObject getAttachmentAsDataHandler(String cid)
- {
- try
- {
- AttachmentPart part = XOPContext.getAttachmentByCID(cid);
- DataHandler dataHandler = part.getDataHandler();
- String contentType = dataHandler.getContentType();
-
- // Wrapping the DataHandler shields XB from the JAF dependency
- XOPObject xopObject = new XOPObject(dataHandler);
- xopObject.setContentType(contentType);
-
- return xopObject;
- }
- catch(SOAPException e)
- {
- throw new WSException("Failed to access attachment part", e);
- }
- }
-
- public byte[] getAttachmentAsByteArray(String cid)
- {
- try
- {
- AttachmentPart part = XOPContext.getAttachmentByCID(cid);
- DataHandler dh = part.getDataHandler();
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- dh.writeTo(bout);
-
- return bout.toByteArray();
- }
- catch (SOAPException ex)
- {
- throw new WSException(ex);
- }
- catch(IOException e)
- {
- throw new WSException(e);
- }
-
- }
-}
Copied: trunk/src/main/java/org/jboss/ws/xop/jaxrpc/JBossXBContentAdapter.java (from rev
1545, trunk/src/main/java/org/jboss/ws/xop/JBossXBContentAdapter.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/JBossXBContentAdapter.java 2006-12-04 13:30:29
UTC (rev 1545)
+++ trunk/src/main/java/org/jboss/ws/xop/jaxrpc/JBossXBContentAdapter.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -0,0 +1,235 @@
+/*
+* 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.xop.jaxrpc;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+import org.jboss.ws.xop.XOPContext;
+import org.jboss.ws.soap.attachment.ContentHandlerRegistry;
+import org.jboss.ws.soap.attachment.SwapableMemoryDataSource;
+import org.jboss.ws.utils.IOUtils;
+import org.jboss.ws.utils.MimeUtils;
+import org.jboss.xb.binding.sunday.marshalling.MarshallingContext;
+import org.jboss.xb.binding.sunday.marshalling.TermBeforeMarshallingCallback;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TermBeforeSetParentCallback;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.UnmarshallingContext;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.xml.namespace.QName;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Adopts raw binary contents to java types.
+ * This class works in conjunction with the <code>XOPUnmarshallerImpl</code>
+ * and <code>XOPMarshallerImpl</code>.
+ *
+ * @see XOPUnmarshallerImpl
+ * @see XOPMarshallerImpl
+ *
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @version $Id: JBossXBContentAdapter.java 1322 2006-10-27 13:27:04Z
heiko.braun(a)jboss.com $
+ * @since Oct 19, 2006
+ */
+public class JBossXBContentAdapter implements TermBeforeMarshallingCallback,
TermBeforeSetParentCallback {
+
+ private static final Logger log = Logger.getLogger(JBossXBContentAdapter.class);
+ private static final QName XMIME_BASE_64 = new QName(Constants.NS_XML_MIME,
"base64Binary");
+ private static final QName XOP_INCLUDE = new QName(Constants.NS_XOP,
"Include");
+
+ static
+ {
+ // Load JAF content handlers
+ ContentHandlerRegistry.register();
+ }
+
+ /**
+ * When XOP is disabled we need to convert java types to byte[]
+ * before handing off to XB.
+ */
+ public Object beforeMarshalling(Object object, MarshallingContext marshallingContext)
{
+
+ boolean mtomDisabled = !XOPContext.isMTOMEnabled();
+ boolean convertableType = object!=null && !(object instanceof byte[]);
+
+ if( mtomDisabled && convertableType )
+ {
+ String contentType = MimeUtils.resolveMimeType(object);
+ log.debug("Adopt " + object.getClass() + " to byte[], contentType
" + contentType);
+
+ DataHandler dh = new DataHandler(object, contentType);
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ try
+ {
+ IOUtils.copyStream(bout, dh.getInputStream());
+ object = bout.toByteArray();
+ }
+ catch (IOException e)
+ {
+ throw new WSException("Failed to adopt XOP content type", e);
+ }
+ }
+
+ return object;
+ }
+
+ /**
+ * When XOP is disabled (inlined request) we receive a byte[] from XB
+ * that needs to be converted in to java type
+ */
+ public Object beforeSetParent(Object object, UnmarshallingContext ctx) {
+
+ if(null==object)
+ return object;
+
+ // may be null when it's actually an encoded request ?!
+ Class targetClass = ctx.resolvePropertyType();
+
+ if(null==targetClass) {
+ throw new WSException("Failed to resolve target property type on "+
ctx.getParticle());
+ }
+
+ boolean isRegularMessage = !XOPContext.isXOPMessage();
+ boolean isSimpleType = (object instanceof byte[]);
+ boolean doTypesMatch = ( targetClass.equals(object.getClass()) );
+
+ // Handle inlined requests.
+ // In this case XB treats binaries as simple types that are unmarshalled to byte[]
+ // Still type conversion will be necessary.
+ if( isRegularMessage && isSimpleType && !doTypesMatch)
+ {
+ String contentType = MimeUtils.resolveMimeType(targetClass);
+ log.debug("Adopt byte[] to " + targetClass +", contentType
"+ contentType);
+
+ try
+ {
+ DataHandler dh = new DataHandler(
+ wrapAsDataSource(object, contentType)
+ );
+
+ if(targetClass.equals(DataHandler.class))
+ object = dh;
+ else
+ object = dh.getContent();
+ }
+ catch (IOException e)
+ {
+ throw new WSException("Failed to adopt XOP content type", e);
+ }
+ }
+
+ // Handle XOP encoded requests.
+ // XB will use the XOPUnmarshaller callback and receive a DataHandler instance.
+ // In this case we are be able to instantiate the correct content object
+ // from the data handler, with the exception of content-type
'application/octet-stream'.
+ // These attachments will be returned as DataHandler instances.
+ else if(XOPContext.isXOPMessage() && (object instanceof DataHandler)
&& !doTypesMatch)
+ {
+ try
+ {
+ String contentType = MimeUtils.resolveMimeType(targetClass);
+ log.debug("Adopt DataHandler to " + targetClass +",
contentType "+ contentType);
+
+ DataHandler dh = new DataHandler(
+ wrapAsDataSource(object, contentType)
+ );
+ object = dh.getContent();
+
+ // 'application/octet-stream' will return a byte[] instead fo the
stream
+ if(object instanceof InputStream)
+ {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ dh.writeTo(bout);
+ object = bout.toByteArray();
+ }
+ }
+ catch (IOException e)
+ {
+ throw new WSException("Failed to adopt XOP content type", e);
+ }
+ }
+
+ return object;
+ }
+
+ private DataSource wrapAsDataSource(Object object, String contentType) throws
IOException {
+
+ DataSource ds;
+
+ if(object instanceof byte[])
+ {
+ ds = new SwapableMemoryDataSource(new ByteArrayInputStream((byte[])object),
contentType);
+ }
+ else if(object instanceof DataHandler)
+ {
+ ds = new SwapableMemoryDataSource(((DataHandler)object).getInputStream(),
contentType);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Failed to wrap as data source:
"+object.getClass());
+ }
+
+ return ds;
+ }
+
+ /**
+ * A factory method that registers the XB (un)marshalling adapters with schema
binding.
+ * These adapters convert java types into byte[] and reverse,
+ * in order to match the jaxrpc-mapping declaration in case we receive or send an
inlined request.
+ */
+ public static void register(SchemaBinding schemaBinding)
+ {
+ JBossXBContentAdapter contentAdapter = new JBossXBContentAdapter();
+
+ // base64 simple types
+ TypeBinding base64Type =
schemaBinding.getType(org.jboss.xb.binding.Constants.QNAME_BASE64BINARY);
+ base64Type.setBeforeMarshallingCallback( contentAdapter );
+ base64Type.setBeforeSetParentCallback( contentAdapter );
+
+ // xmime complex types
+ TypeBinding xmimeBase64Type = schemaBinding.getType(XMIME_BASE_64);
+ if(xmimeBase64Type!=null)
+ {
+ xmimeBase64Type.setBeforeMarshallingCallback( contentAdapter );
+ xmimeBase64Type.setBeforeSetParentCallback( contentAdapter );
+
+ // xop:Include
+ /*ModelGroupBinding modelGroup =
(ModelGroupBinding)xmimeBase64Type.getParticle().getTerm();
+ ParticleBinding particle =
(ParticleBinding)modelGroup.getParticles().iterator().next();
+ ElementBinding xopInclude = (ElementBinding)particle.getTerm();
+
+ if(! xopInclude.getQName().equals(XOP_INCLUDE))
+ throw new WSException("Looks like the JBossXB XOP implementation has
changed, please open a JIRA issue");
+
+ xopInclude.setBeforeMarshallingCallback(contentAdapter);
+ xopInclude.setBeforeSetParentCallback(contentAdapter);
+ */
+ }
+ }
+
+}
Copied: trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPMarshallerImpl.java (from rev 1545,
trunk/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/XOPMarshallerImpl.java 2006-12-04 13:30:29 UTC
(rev 1545)
+++ trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPMarshallerImpl.java 2006-12-04 17:35:57
UTC (rev 1549)
@@ -0,0 +1,106 @@
+/*
+ * 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.xop.jaxrpc;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.NotImplementedException;
+import org.jboss.ws.common.CommonMessageContext;
+import org.jboss.ws.soap.MessageContextAssociation;
+import org.jboss.ws.soap.SOAPMessageImpl;
+import org.jboss.ws.soap.attachment.ContentHandlerRegistry;
+import org.jboss.ws.soap.attachment.MimeConstants;
+import org.jboss.ws.xop.XOPContext;
+import org.jboss.xb.binding.sunday.xop.XOPMarshaller;
+import org.jboss.xb.binding.sunday.xop.XOPObject;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+
+/**
+ * The XOPUnmarshallerImpl allows callbacks from the binding layer towards the
+ * soap processing components in order to optimize binary processing.
+ *
+ * @see XOPUnmarshallerImpl
+ *
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @since May 9, 2006
+ * @version $Id$
+ */
+public class XOPMarshallerImpl implements XOPMarshaller {
+
+ private static final Logger log = Logger.getLogger(XOPMarshallerImpl.class);
+
+ static
+ {
+ // Load JAF content handlers
+ ContentHandlerRegistry.register();
+ }
+
+ public boolean isXOPPackage()
+ {
+ return XOPContext.isXOPMessage();
+ }
+
+ public String addMtomAttachment(XOPObject obj, String elementNamespace, String
elementName)
+ {
+
+ CommonMessageContext msgContext =
(CommonMessageContext)MessageContextAssociation.peekMessageContext();
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
+
+ QName xmlName = new QName(elementNamespace, elementName);
+ log.debug("serialize: [xmlName=" + xmlName + "]");
+
+ String cid =
soapMessage.getCidGenerator().generateFromName(xmlName.getLocalPart());
+
+ DataHandler dataHandler = XOPContext.createDataHandler(obj);
+ AttachmentPart xopPart = soapMessage.createAttachmentPart(dataHandler);
+ xopPart.addMimeHeader(MimeConstants.CONTENT_ID, '<'+cid+'>');
// RFC2392 requirement
+ soapMessage.addAttachmentPart(xopPart);
+
+ log.debug("Created attachment part " +cid+", with content-type
" +xopPart.getContentType());
+
+ return "cid:" + cid;
+
+ }
+
+ public String addMtomAttachment(byte[] data, String elementNamespace, String
elementName)
+ {
+ /*
+ TODO: this requires a java mail upgrade
+ ByteArrayDataSource ds = new ByteArrayDataSource(data,
MimeConstants.TYPE_APPLICATION_OCTET_STREAM);
+ return addMtomAttachment(
+ new DataHandler(
+ ds, MimeConstants.TYPE_APPLICATION_OCTET_STREAM),
+ elementNamespace, elementName
+ );*/
+
+ throw new NotImplementedException("Not implemented yet");
+ }
+
+ public String addSwaRefAttachment(Object obj)
+ {
+ throw new NotImplementedException();
+ }
+
+
+}
Property changes on: trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPMarshallerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPScanner.java (from rev 1545,
trunk/src/main/java/org/jboss/ws/xop/XOPScanner.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/XOPScanner.java 2006-12-04 13:30:29 UTC (rev
1545)
+++ trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPScanner.java 2006-12-04 17:35:57 UTC
(rev 1549)
@@ -0,0 +1,146 @@
+/*
+* 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.xop.jaxrpc;
+
+import org.apache.xerces.xs.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Scans complex type definitions for nested XOP type declarations.
+ * A XOP type declaration is identified as a complex type
+ * that derives from xsd:base64Binary, i.e:
+ *
+ * <code> <pre>
+ * <xs:complexType name="MyXOPElement" >
+ * <xs:simpleContent>
+ * <xs:extension base="xs:base64Binary" >
+ * <xs:attribute ref="xmime:contentType" />
+ * </xs:extension>
+ * </xs:simpleContent>
+ * </xs:complexType>
+ * </pre></code>
+ *
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @since Jun 9, 2006
+ * @version $Id$
+ */
+public class XOPScanner {
+
+ // avoid circular scans
+ private List<String> scannedItems = new ArrayList<String>();
+ private static final String BASE64_BINARY = "base64Binary";
+
+ /**
+ * Query a complex type for nested XOP type definitions.
+ */
+ public XSTypeDefinition findXOPTypeDef(XSTypeDefinition typeDef)
+ {
+ if(typeDef==null)
+ return typeDef;
+ XSTypeDefinition result = null;
+ String name = typeDef.getName();
+ String namespace = typeDef.getNamespace()!=null ?
typeDef.getNamespace():"";
+
+ if(typeDef instanceof XSSimpleTypeDefinition &&
BASE64_BINARY.equals(name))
+ {
+ return typeDef;
+ }
+ else if(typeDef instanceof XSComplexTypeDefinition)
+ {
+ XSComplexTypeDefinition complexTypeDef = (XSComplexTypeDefinition)typeDef;
+ if(name!=null)
+ {
+ String typeKey = namespace+":"+name;
+
+ if(scannedItems.contains(typeKey))
+ {
+ return null;
+ }
+ else
+ {
+ scannedItems.add(typeKey);
+ }
+ }
+
+ // An XOP parameter is detected if it is a complex type
+ // that derives from xsd:base64Binary
+ if (complexTypeDef.getSimpleType() != null)
+ {
+ String typeName = complexTypeDef.getSimpleType().getName();
+ if (BASE64_BINARY.equals(typeName))
+ return complexTypeDef;
+ }
+ else
+ {
+
+ XSModelGroup xm = null;
+ if(complexTypeDef.getContentType() !=
XSComplexTypeDefinition.CONTENTTYPE_EMPTY)
+ {
+ XSParticle xp = complexTypeDef.getParticle();
+ if (xp != null)
+ {
+ XSTerm xterm = xp.getTerm();
+ if(xterm instanceof XSModelGroup)
+ {
+ xm = (XSModelGroup)xterm;
+ //System.out.println("xm -> " + xm);
+
+ XSObjectList xo = xm.getParticles();
+
+ // interate over nested particles
+ for(int i=0; i<xm.getParticles().getLength(); i++ )
+ {
+ XSTerm xsterm = ((XSParticle)xo.item(i)).getTerm();
+
+ // Can be either XSModelGroup, XSWildcard, XSElementDeclaration
+ // We only proceed with XSElementDeclaration
+ if(xsterm instanceof XSElementDeclaration)
+ {
+ XSElementDeclaration xe = (XSElementDeclaration)xsterm;
+ XSTypeDefinition nestedTypeDef = xe.getTypeDefinition();
+
+ //System.out.println("Query nested -> " +
xe.getName());
+ result = findXOPTypeDef(nestedTypeDef);
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ //System.out.println("result -> " + result);
+
+ }
+
+ return result;
+
+ }
+
+ public void reset()
+ {
+ scannedItems.clear();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPScanner.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPUnmarshallerImpl.java (from rev
1545, trunk/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/XOPUnmarshallerImpl.java 2006-12-04 13:30:29 UTC
(rev 1545)
+++ trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPUnmarshallerImpl.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -0,0 +1,106 @@
+/*
+ * 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.xop.jaxrpc;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+import org.jboss.ws.xop.XOPContext;
+import org.jboss.ws.soap.attachment.ContentHandlerRegistry;
+import org.jboss.xb.binding.sunday.xop.XOPObject;
+import org.jboss.xb.binding.sunday.xop.XOPUnmarshaller;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.SOAPException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * The XOPUnmarshallerImpl allows callbacks from the binding layer towards the
+ * soap processing components in order to optimize binary processing.
+ *
+ * @see XOPMarshallerImpl
+ *
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @since May 9, 2006
+ * @version $Id$
+ */
+public class XOPUnmarshallerImpl implements XOPUnmarshaller {
+
+ private static final Logger log = Logger.getLogger(XOPUnmarshallerImpl.class);
+ private static final QName XOP_INCLUDE = new QName(Constants.NS_XOP,
"Include");
+
+ static
+ {
+ // Load JAF content handlers
+ ContentHandlerRegistry.register();
+ }
+
+ public boolean isXOPPackage()
+ {
+ return XOPContext.isXOPMessage();
+ }
+
+ public XOPObject getAttachmentAsDataHandler(String cid)
+ {
+ try
+ {
+ AttachmentPart part = XOPContext.getAttachmentByCID(cid);
+ DataHandler dataHandler = part.getDataHandler();
+ String contentType = dataHandler.getContentType();
+
+ // Wrapping the DataHandler shields XB from the JAF dependency
+ XOPObject xopObject = new XOPObject(dataHandler);
+ xopObject.setContentType(contentType);
+
+ return xopObject;
+ }
+ catch(SOAPException e)
+ {
+ throw new WSException("Failed to access attachment part", e);
+ }
+ }
+
+ public byte[] getAttachmentAsByteArray(String cid)
+ {
+ try
+ {
+ AttachmentPart part = XOPContext.getAttachmentByCID(cid);
+ DataHandler dh = part.getDataHandler();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ dh.writeTo(bout);
+
+ return bout.toByteArray();
+ }
+ catch (SOAPException ex)
+ {
+ throw new WSException(ex);
+ }
+ catch(IOException e)
+ {
+ throw new WSException(e);
+ }
+
+ }
+}
Property changes on: trunk/src/main/java/org/jboss/ws/xop/jaxrpc/XOPUnmarshallerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentMarshallerImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentMarshallerImpl.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentMarshallerImpl.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -0,0 +1,46 @@
+package org.jboss.ws.xop.jaxws;
+
+import org.jboss.ws.xop.jaxrpc.XOPMarshallerImpl;
+import org.jboss.ws.xop.XOPContext;
+import org.jboss.ws.WSException;
+import org.jboss.xb.binding.sunday.xop.XOPObject;
+import org.jboss.xb.binding.sunday.xop.XOPMarshaller;
+
+import javax.xml.bind.attachment.AttachmentMarshaller;
+import javax.activation.DataHandler;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hbraun
+ * Date: 01.12.2006
+ * Time: 17:20:41
+ * To change this template use File | Settings | File Templates.
+ */
+public class AttachmentMarshallerImpl extends AttachmentMarshaller {
+
+ private XOPMarshaller delegate;
+
+ public AttachmentMarshallerImpl() {
+ super();
+ delegate = new XOPMarshallerImpl();
+ }
+
+ public String addMtomAttachment(DataHandler dataHandler, String string, String
string1) {
+ XOPObject xopObject = new XOPObject(dataHandler);
+ xopObject.setContentType(dataHandler.getContentType());
+ return delegate.addMtomAttachment(xopObject, string, string1);
+ }
+
+ public String addMtomAttachment(byte[] bytes, int i, int i1, String string, String
string1, String string2) {
+ throw new WSException("Not yet implemented");
+ }
+
+ public String addSwaRefAttachment(DataHandler dataHandler) {
+ throw new WSException("Not yet implemented");
+ }
+
+
+ public boolean isXOPPackage() {
+ return XOPContext.isXOPMessage();
+ }
+}
Added: trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentUnmarshallerImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentUnmarshallerImpl.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/xop/jaxws/AttachmentUnmarshallerImpl.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -0,0 +1,42 @@
+package org.jboss.ws.xop.jaxws;
+
+import org.jboss.ws.xop.XOPContext;
+import org.jboss.ws.xop.jaxrpc.XOPUnmarshallerImpl;
+import org.jboss.xb.binding.sunday.xop.XOPUnmarshaller;
+import org.jboss.xb.binding.sunday.xop.XOPObject;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.attachment.AttachmentUnmarshaller;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hbraun
+ * Date: 01.12.2006
+ * Time: 17:25:56
+ * To change this template use File | Settings | File Templates.
+ */
+public class AttachmentUnmarshallerImpl extends AttachmentUnmarshaller {
+
+
+ private XOPUnmarshaller delegate;
+
+
+ public AttachmentUnmarshallerImpl() {
+ super();
+ delegate = new XOPUnmarshallerImpl();
+ }
+
+ public boolean isXOPPackage() {
+ return XOPContext.isXOPMessage();
+ }
+
+ public DataHandler getAttachmentAsDataHandler(String string) {
+ XOPObject xopObject = delegate.getAttachmentAsDataHandler(string);
+ DataHandler dh = new DataHandler(xopObject.getContent(),
xopObject.getContentType());
+ return dh;
+ }
+
+ public byte[] getAttachmentAsByteArray(String string) {
+ return delegate.getAttachmentAsByteArray(string);
+ }
+}
Added: trunk/src/main/java/org/jboss/ws/xop/jaxws/ReflectiveXOPScanner.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/xop/jaxws/ReflectiveXOPScanner.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/main/java/org/jboss/ws/xop/jaxws/ReflectiveXOPScanner.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -0,0 +1,92 @@
+/*
+* 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.xop.jaxws;
+
+import javax.xml.bind.annotation.XmlMimeType;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @version $Id$
+ * @since 04.12.2006
+ */
+public class ReflectiveXOPScanner {
+
+ /**
+ * Scan java types for MTOM declarations
+ *
+ * @param xmlRoot
+ * @return the first matching XmlMimeType#value()
+ */
+ public String scan(Class xmlRoot)
+ {
+
+ System.out.println("root match: " +
xmlRoot.getAnnotation(XmlMimeType.class));
+
+ for(Field field : xmlRoot.getDeclaredFields())
+ {
+ Class<?> type = field.getType();
+ String mimeType = null;
+
+ if(field.isAnnotationPresent(XmlMimeType.class))
+ {
+ XmlMimeType mimeTypeDecl = field.getAnnotation(XmlMimeType.class);
+ mimeType = mimeTypeDecl.value();
+ }
+
+ if(null == mimeType) // try getter methods
+ {
+ mimeType = scanGetterAnnotation(xmlRoot, field);
+ }
+
+ if(null == mimeType) // recursive search
+ {
+ boolean isJDKClass = type.getPackage()!= null ?
type.getPackage().getName().startsWith("java") : true;
+ if(!isJDKClass) scan(type);
+ }
+ else
+ {
+ return mimeType;
+ }
+
+ }
+
+ return null;
+ }
+
+ 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;
+ }
+}
Added: trunk/src/test/java/org/jboss/test/ws/Runner.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/Runner.java 2006-12-04 17:05:16 UTC (rev 1548)
+++ trunk/src/test/java/org/jboss/test/ws/Runner.java 2006-12-04 17:35:57 UTC (rev 1549)
@@ -0,0 +1,41 @@
+package org.jboss.test.ws;
+
+import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBIntrospector;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlMimeType;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: hbraun
+ * Date: 04.12.2006
+ * Time: 12:20:42
+ * To change this template use File | Settings | File Templates.
+ */
+public class Runner {
+
+ public static void main(String[] args) throws Exception
+ {
+
+ JAXBContext jaxb = JAXBContext.newInstance(TestBinary.class);
+ JAXBIntrospector ins = jaxb.createJAXBIntrospector();
+
+ TestBinary testBinary = new TestBinary();
+
+ //System.out.println( "name: "+ins.getElementName(testBinary) );
+ //System.out.println( "isElement:" + ins.isElement(testBinary) );
+ JAXBContextImpl impl = (JAXBContextImpl)jaxb;
+ System.out.println("xmimeContentType: "+
impl.getXMIMEContentType(testBinary) );
+ System.out.println("beanInfo: "+ impl.getBeanInfo(testBinary));
+
+ }
+
+ @XmlRootElement(name="TestBinary", namespace =
"org.jboss.test.ws")
+ static class TestBinary {
+
+ @XmlMimeType("image/jpeg")
+ public byte[] data;
+ }
+}
Modified: trunk/src/test/java/org/jboss/test/ws/jaxrpc/xop/XOPTypeDefTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxrpc/xop/XOPTypeDefTestCase.java 2006-12-04
17:05:16 UTC (rev 1548)
+++ trunk/src/test/java/org/jboss/test/ws/jaxrpc/xop/XOPTypeDefTestCase.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -10,7 +10,7 @@
import org.jboss.ws.metadata.wsdl.xmlschema.JBossXSModel;
import org.jboss.ws.metadata.wsdl.xmlschema.WSSchemaUtils;
import org.jboss.ws.metadata.wsdl.xsd.SchemaUtils;
-import org.jboss.ws.xop.XOPScanner;
+import org.jboss.ws.xop.jaxrpc.XOPScanner;
import org.jboss.xb.binding.NamespaceRegistry;
/**
Added: trunk/src/test/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java 2006-12-04
17:05:16 UTC (rev 1548)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/xop/MimeDeclarationTestCase.java 2006-12-04
17:35:57 UTC (rev 1549)
@@ -0,0 +1,105 @@
+/*
+* 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.test.ws.jaxws.xop;
+
+import junit.framework.TestCase;
+
+import javax.xml.bind.annotation.XmlMimeType;
+import java.awt.*;
+import java.lang.reflect.Method;
+
+import org.jboss.ws.xop.jaxws.ReflectiveXOPScanner;
+
+/**
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @version $Id$
+ * @since 04.12.2006
+ */
+public class MimeDeclarationTestCase extends TestCase {
+
+ static ReflectiveXOPScanner SCANNER = new ReflectiveXOPScanner();
+
+ public void testFieldAnnotation() throws Exception
+ {
+ String mimeType = SCANNER.scan(FieldAnnotation.class);
+ assertNotNull("Unable to find xop declaration", mimeType);
+ }
+
+ public void testMethodAnnotation() throws Exception
+ {
+ String mimeType = SCANNER.scan(MethodAnnotation.class);
+ assertNotNull("Unable to find xop declaration", mimeType);
+ }
+
+ public void testAnnotationMissing() throws Exception
+ {
+ String mimeType = SCANNER.scan(NoAnnotation.class);
+ assertNull("There should be no mimeType available", mimeType);
+ }
+
+ public void testAnnotatedParameter() throws Exception
+ {
+
+ if(true)
+ {
+ System.out.println("FIXME: XmlMimeType on SEI parameter
declarations");
+ return;
+ }
+
+ Method m = AnnotatedSEI.class.getMethod("foo", new Class[]
{byte[].class});
+ assertNotNull(m);
+
+ System.out.println(m.getParameterAnnotations().length);
+
+ String mimeType = SCANNER.scan( m.getParameterTypes()[0]);
+ assertNotNull("Unable to find xop declaration", mimeType);
+ }
+
+ class FieldAnnotation
+ {
+ @XmlMimeType("text/xml")
+ public byte[] data;
+ }
+
+ class MethodAnnotation
+ {
+ private Image data;
+
+ @XmlMimeType("image/jpeg")
+ public Image getData() {
+ return data;
+ }
+ }
+
+ class NoAnnotation
+ {
+ private Image data;
+
+ public Image getData() {
+ return data;
+ }
+ }
+
+ interface AnnotatedSEI {
+ void foo(@XmlMimeType("text/xml")byte[] bar);
+ }
+}