Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java Sun Dec 17 22:34:08 2017 @@ -77,22 +77,21 @@ public class JAXWSDeployer extends Abstr ClassLoader threadClassLoader = null; try { threadClassLoader = Thread.currentThread().getContextClassLoader(); - ArrayList<URL> urls = new ArrayList<URL>(); - urls.add(repository); + List<URL> extraUrls = new ArrayList<>(); String webLocation = DeploymentEngine.getWebLocationString(); if (webLocation != null) { - urls.add(new File(webLocation).toURL()); + extraUrls.add(new File(webLocation).toURI().toURL()); } ClassLoader classLoader = Utils.createClassLoader( - urls, + repository, + extraUrls.toArray(new URL[extraUrls.size()]), axisConfig.getSystemClassLoader(), - true, (File) axisConfig. getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR), axisConfig.isChildFirstClassLoading()); Thread.currentThread().setContextClassLoader(classLoader); JAXWSDeployerSupport deployerSupport = new JAXWSDeployerSupport(configCtx, directory); - deployerSupport.deployClasses("JAXWS-Builtin", file.toURL(), Thread.currentThread().getContextClassLoader(), classList); + deployerSupport.deployClasses("JAXWS-Builtin", file.toURI().toURL(), Thread.currentThread().getContextClassLoader(), classList); } catch (NoClassDefFoundError e) { if (log.isDebugEnabled()) { log.debug(Messages.getMessage("deployingexception", e.getMessage()), e); @@ -128,24 +127,23 @@ public class JAXWSDeployer extends Abstr try { threadClassLoader = Thread.currentThread().getContextClassLoader(); String groupName = deploymentFileData.getName(); - URL location = deploymentFileData.getFile().toURL(); + URL location = deploymentFileData.getFile().toURI().toURL(); if (isJar(deploymentFileData.getFile())) { log.info("Deploying artifact : " + deploymentFileData.getAbsolutePath()); - ArrayList<URL> urls = new ArrayList<URL>(); - urls.add(deploymentFileData.getFile().toURL()); - urls.add(axisConfig.getRepository()); + List<URL> extraUrls = new ArrayList<>(); + extraUrls.add(axisConfig.getRepository()); // adding libs under jaxws deployment dir - addJaxwsLibs(urls, axisConfig.getRepository().getPath() + directory); + addJaxwsLibs(extraUrls, axisConfig.getRepository().getPath() + directory); String webLocation = DeploymentEngine.getWebLocationString(); if (webLocation != null) { - urls.add(new File(webLocation).toURL()); + extraUrls.add(new File(webLocation).toURI().toURL()); } ClassLoader classLoader = Utils.createClassLoader( - urls, + deploymentFileData.getFile().toURI().toURL(), + extraUrls.toArray(new URL[extraUrls.size()]), axisConfig.getSystemClassLoader(), - true, (File) axisConfig. getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR), axisConfig.isChildFirstClassLoading()); @@ -237,7 +235,7 @@ public class JAXWSDeployer extends Abstr * @param jaxwsDepDirPath - jaxws deployment folder path * @throws Exception - on error while geting URLs of libs */ - private void addJaxwsLibs(ArrayList<URL> urls, String jaxwsDepDirPath) + private void addJaxwsLibs(List<URL> urls, String jaxwsDepDirPath) throws Exception { File jaxwsDepDirLib = new File(jaxwsDepDirPath + File.separator + "lib"); if (jaxwsDepDirLib.exists() && jaxwsDepDirLib.isDirectory()) {
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSServiceBuilderExtension.java Sun Dec 17 22:34:08 2017 @@ -106,7 +106,7 @@ public class JAXWSServiceBuilderExtensio .getServiceClassNameFromMetaData(serviceMetaData); } - return deployerSupport.deployClasses(deploymentFileData.getFile().toURL(), + return deployerSupport.deployClasses(deploymentFileData.getFile().toURI().toURL(), deploymentFileData.getClassLoader(), listOfClasses); } catch (AxisFault e) { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/UnmarshalMessageContextListener.java Sun Dec 17 22:34:08 2017 @@ -19,7 +19,7 @@ package org.apache.axis2.jaxws.marshaller.impl.alt; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axis2.context.MessageContext; import org.apache.axis2.context.ServiceContext; @@ -89,7 +89,7 @@ public class UnmarshalMessageContextList if (envelope == null) { return; } - if (!(envelope.getBuilder() instanceof StAXOMBuilder)) { + if (!(envelope.getBuilder() instanceof CustomBuilderSupport)) { return; } @@ -114,7 +114,7 @@ public class UnmarshalMessageContextList JAXBDSContext jaxbDSC = new JAXBDSContext(info.getPackages(), info.getPackagesKey()); jaxbDSC.setMessageContext(mc); JAXBCustomBuilder jcb = new JAXBCustomBuilder(jaxbDSC); - ((StAXOMBuilder) envelope.getBuilder()).registerCustomBuilderForPayload(jcb); + ((CustomBuilderSupport) envelope.getBuilder()).registerCustomBuilder(jcb, jcb); if (log.isDebugEnabled()) { log.debug("Registering JAXBCustomBuilder: " + jcb + " for AxisOperation: " + axisOp.getName()); } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java Sun Dec 17 22:34:08 2017 @@ -44,7 +44,7 @@ import javax.xml.ws.WebServiceException; * longer valid after the message is called. (i.e. the implementation does not need to cache the * information) */ -public interface Block extends OMDataSourceExt { +public interface Block<T,C> extends OMDataSourceExt { /** * Get a reference to the Business Object represented by this Block Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/DataSourceBlock.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/DataSourceBlock.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/DataSourceBlock.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/DataSourceBlock.java Sun Dec 17 22:34:08 2017 @@ -19,9 +19,11 @@ package org.apache.axis2.jaxws.message.databinding; +import javax.activation.DataSource; + import org.apache.axis2.jaxws.message.Block; /** DataSourceBlock Block with a business object that is a javax.activation.DataSource */ -public interface DataSourceBlock extends Block { +public interface DataSourceBlock extends Block<DataSource,Void> { } \ No newline at end of file Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlock.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlock.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlock.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlock.java Sun Dec 17 22:34:08 2017 @@ -22,6 +22,6 @@ package org.apache.axis2.jaxws.message.d import org.apache.axis2.jaxws.message.Block; /** JAXBBlock Block represented by a JAXB object */ -public interface JAXBBlock extends Block { +public interface JAXBBlock extends Block<Object,JAXBBlockContext> { } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java Sun Dec 17 22:34:08 2017 @@ -19,18 +19,14 @@ package org.apache.axis2.jaxws.message.databinding; -import org.apache.axiom.util.stax.xop.MimePartProvider; import org.apache.axis2.context.MessageContext; +import org.apache.axis2.datasource.jaxb.AttachmentContext; import org.apache.axis2.datasource.jaxb.JAXBDSContext; import org.apache.axis2.jaxws.message.Message; -import org.apache.axis2.jaxws.message.attachments.JAXBAttachmentMarshaller; -import org.apache.axis2.jaxws.message.attachments.JAXBAttachmentUnmarshaller; +import org.apache.axis2.jaxws.message.attachments.MessageAttachmentContext; import org.apache.axis2.jaxws.spi.Constants; import javax.xml.bind.JAXBContext; -import javax.xml.bind.attachment.AttachmentMarshaller; -import javax.xml.bind.attachment.AttachmentUnmarshaller; -import javax.xml.stream.XMLStreamWriter; import java.util.TreeSet; /* @@ -89,13 +85,8 @@ public class JAXBBlockContext extends JA } @Override - protected AttachmentMarshaller createAttachmentMarshaller(XMLStreamWriter writer) { - return new JAXBAttachmentMarshaller(getMessage(), writer); - } - - @Override - protected AttachmentUnmarshaller createAttachmentUnmarshaller(MimePartProvider mimePartProvider) { - return new JAXBAttachmentUnmarshaller(mimePartProvider, getMessage()); + protected AttachmentContext createAttachmentContext() { + return new MessageAttachmentContext(getMessage()); } public ClassLoader getClassLoader() { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/OMBlock.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/OMBlock.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/OMBlock.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/OMBlock.java Sun Dec 17 22:34:08 2017 @@ -19,9 +19,10 @@ package org.apache.axis2.jaxws.message.databinding; +import org.apache.axiom.om.OMElement; import org.apache.axis2.jaxws.message.Block; /** OMBlock Block represented by an OMElement object */ -public interface OMBlock extends Block { +public interface OMBlock extends Block<OMElement,Void> { } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SOAPEnvelopeBlock.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SOAPEnvelopeBlock.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SOAPEnvelopeBlock.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SOAPEnvelopeBlock.java Sun Dec 17 22:34:08 2017 @@ -19,12 +19,14 @@ package org.apache.axis2.jaxws.message.databinding; +import javax.xml.soap.SOAPEnvelope; + import org.apache.axis2.jaxws.message.Block; /** * SOAPEnvelopeBlock Block represented by an SAAJ SOAPEnvelope. This kind of block is useful for * building the initial Message */ -public interface SOAPEnvelopeBlock extends Block { +public interface SOAPEnvelopeBlock extends Block<SOAPEnvelope,Void> { } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SourceBlock.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SourceBlock.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SourceBlock.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/SourceBlock.java Sun Dec 17 22:34:08 2017 @@ -19,9 +19,11 @@ package org.apache.axis2.jaxws.message.databinding; +import javax.xml.transform.Source; + import org.apache.axis2.jaxws.message.Block; /** SourceBlock Block with a business object that is a javax.xml.transform.Source */ -public interface SourceBlock extends Block { +public interface SourceBlock extends Block<Source,Void> { } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XMLStringBlock.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XMLStringBlock.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XMLStringBlock.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XMLStringBlock.java Sun Dec 17 22:34:08 2017 @@ -22,6 +22,6 @@ package org.apache.axis2.jaxws.message.d import org.apache.axis2.jaxws.message.Block; /** XMLStringBlock Block with a business object that is a String containing xml text */ -public interface XMLStringBlock extends Block { +public interface XMLStringBlock extends Block<String,Void> { } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/DataSourceBlockImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/DataSourceBlockImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/DataSourceBlockImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/DataSourceBlockImpl.java Sun Dec 17 22:34:08 2017 @@ -19,44 +19,30 @@ package org.apache.axis2.jaxws.message.databinding.impl; -import org.apache.axiom.attachments.impl.BufferUtils; import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.om.OMOutputFormat; import org.apache.axiom.om.OMSourcedElement; import org.apache.axiom.om.util.StAXUtils; import org.apache.axiom.soap.SOAP11Constants; -import org.apache.axis2.datasource.SourceDataSource; -import org.apache.axis2.java.security.AccessController; +import org.apache.axis2.builder.DataSourceBuilder; import org.apache.axis2.jaxws.ExceptionFactory; import org.apache.axis2.jaxws.i18n.Messages; import org.apache.axis2.jaxws.message.databinding.DataSourceBlock; import org.apache.axis2.jaxws.message.factory.BlockFactory; import org.apache.axis2.jaxws.message.impl.BlockImpl; -import org.apache.axis2.jaxws.message.util.Reader2Writer; -import org.apache.axis2.jaxws.utility.ConvertUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.activation.DataSource; import javax.mail.util.ByteArrayDataSource; import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import javax.xml.ws.WebServiceException; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; /** * SourceBlock @@ -64,7 +50,7 @@ import java.security.PrivilegedException * Block containing a business object that is a javax.activation.DataSource * <p/> */ -public class DataSourceBlockImpl extends BlockImpl implements DataSourceBlock { +public class DataSourceBlockImpl extends BlockImpl<DataSource,Void> implements DataSourceBlock { private static final Log log = LogFactory.getLog(DataSourceBlockImpl.class); @@ -78,11 +64,6 @@ public class DataSourceBlockImpl extends DataSourceBlockImpl(DataSource busObject, QName qName, BlockFactory factory) throws WebServiceException { super(busObject, null, qName, factory); - // Check validity of DataSource - if (!(busObject instanceof DataSource)) { - throw ExceptionFactory.makeWebServiceException( - Messages.getMessage("SourceNotSupported", busObject.getClass().getName())); - } } @@ -97,16 +78,7 @@ public class DataSourceBlockImpl extends super(omElement, null, qName, factory); } - protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) throws XMLStreamException, WebServiceException { - Reader2Writer r2w = new Reader2Writer(reader); - try { - return new ByteArrayDataSource(r2w.getAsString(), "application/octet-stream"); - } catch (IOException e) { - throw new XMLStreamException(e); - } - - } - + @Override public OMElement getOMElement() throws XMLStreamException, WebServiceException { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("", ""); @@ -114,17 +86,18 @@ public class DataSourceBlockImpl extends } @Override - protected Object _getBOFromOM(OMElement omElement, Object busContext) + protected DataSource _getBOFromOM(OMElement omElement, Void busContext) throws XMLStreamException, WebServiceException { - Object busObject; + DataSource busObject; // Shortcut to get business object from existing data source - if (omElement instanceof OMSourcedElement) { - OMDataSource ds = ((OMSourcedElement) omElement).getDataSource(); - if (ds instanceof SourceDataSource) { - return ((SourceDataSource) ds).getObject(); - } - } + // TODO: incorrect (wrong type) +// if (omElement instanceof OMSourcedElement) { +// OMDataSource ds = ((OMSourcedElement) omElement).getDataSource(); +// if (ds instanceof SourceDataSource) { +// return ((SourceDataSource) ds).getObject(); +// } +// } // If the message is a fault, there are some special gymnastics that we have to do // to get this working for all of the handler scenarios. @@ -136,7 +109,7 @@ public class DataSourceBlockImpl extends // Transform reader into business object if (!hasFault) { - busObject = ((OMSourcedElement)omElement).getDataSource(); + busObject = (DataSourceBuilder.ByteArrayDataSourceEx)((OMSourcedElement)omElement).getDataSource(); } else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -147,18 +120,10 @@ public class DataSourceBlockImpl extends } @Override - protected XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) + protected XMLStreamReader _getReaderFromBO(DataSource busObj, Void busContext) throws XMLStreamException, WebServiceException { try { - if (busObj instanceof DataSource) { - XMLInputFactory f = StAXUtils.getXMLInputFactory(); - - XMLStreamReader reader = f.createXMLStreamReader(((DataSource)busObj).getInputStream()); - StAXUtils.releaseXMLInputFactory(f); - return reader; - } - throw ExceptionFactory.makeWebServiceException( - Messages.getMessage("SourceNotSupported", busObject.getClass().getName())); + return StAXUtils.createXMLStreamReader(busObj.getInputStream()); } catch (Exception e) { String className = (busObj == null) ? "none" : busObj.getClass().getName(); throw ExceptionFactory @@ -166,16 +131,8 @@ public class DataSourceBlockImpl extends } } - public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException { - try { - BufferUtils.inputStream2OutputStream(((DataSource)busObject).getInputStream(), output); - } catch (IOException e) { - throw new XMLStreamException(e); - } - } - @Override - protected void _outputFromBO(Object busObject, Object busContext, XMLStreamWriter writer) + protected void _outputFromBO(DataSource busObject, Void busContext, XMLStreamWriter writer) throws XMLStreamException, WebServiceException { // There is no fast way to output the Source to a writer, so get the reader // and pass use the default reader->writer. @@ -195,7 +152,7 @@ public class DataSourceBlockImpl extends @Override - protected Object _getBOFromBO(Object busObject, Object busContext, boolean consume) { + protected DataSource _getBOFromBO(DataSource busObject, Void busContext, boolean consume) { if (consume) { return busObject; } else { @@ -205,50 +162,17 @@ public class DataSourceBlockImpl extends } } + @Override public boolean isElementData() { return false; // The source could be a text or element etc. } - /** - * Return the class for this name - * @return Class - */ - private static Class forName(final String className) throws ClassNotFoundException { - // NOTE: This method must remain private because it uses AccessController - Class cl = null; - try { - cl = (Class)AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws ClassNotFoundException { - return Class.forName(className); - } - } - ); - } catch (PrivilegedActionException e) { - if (log.isDebugEnabled()) { - log.debug("Exception thrown from AccessController: " + e); - } - throw (ClassNotFoundException)e.getException(); - } - - return cl; - } - - + @Override public void close() { return; // Nothing to close } - public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException { - try { - byte[] bytes = (byte[]) - ConvertUtils.convert(getBusinessObject(false), byte[].class); - return new ByteArrayInputStream(bytes); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - } - + @Override public Object getObject() { try { return getBusinessObject(false); @@ -257,29 +181,13 @@ public class DataSourceBlockImpl extends } } + @Override public boolean isDestructiveRead() { return true; } + @Override public boolean isDestructiveWrite() { return true; } - - - public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { - if (log.isDebugEnabled()) { - log.debug("Start getXMLBytes"); - } - byte[] bytes = null; - try { - bytes = (byte[]) - ConvertUtils.convert(getBusinessObject(false), byte[].class); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - if (log.isDebugEnabled()) { - log.debug("End getXMLBytes"); - } - return bytes; - } } \ No newline at end of file Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java Sun Dec 17 22:34:08 2017 @@ -24,7 +24,6 @@ import org.apache.axiom.om.OMDataSourceE import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.om.OMSourcedElement; -import org.apache.axiom.om.OMXMLStreamReader; import org.apache.axiom.om.util.StAXUtils; import org.apache.axis2.datasource.jaxb.JAXBDSContext; import org.apache.axis2.datasource.jaxb.JAXBDataSource; @@ -46,14 +45,12 @@ import javax.xml.stream.XMLStreamWriter; import javax.xml.ws.WebServiceException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; /** * JAXBBlockImpl <p/> A Block containing a JAXB business object (either a JAXBElement or an object * with @XmlRootElement). */ -public class JAXBBlockImpl extends BlockImpl implements JAXBBlock { +public class JAXBBlockImpl extends BlockImpl<Object,JAXBBlockContext> implements JAXBBlock { private static final Log log = LogFactory.getLog(JAXBBlockImpl.class); @@ -87,28 +84,8 @@ public class JAXBBlockImpl extends Block super(omElement, busContext, qName, factory); } - protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) - throws XMLStreamException, WebServiceException { - // Get the JAXBBlockContext. All of the necessry information is recorded on it - JAXBBlockContext ctx = (JAXBBlockContext) busContext; - - try { - busObject = ctx.unmarshal(reader); - } catch (JAXBException je) { - if (DEBUG_ENABLED) { - try { - log.debug("JAXBContext for unmarshal failure:" + - ctx.getJAXBContext(ctx.getClassLoader())); - } catch (Exception e) { - } - } - throw ExceptionFactory.makeWebServiceException(je); - } - return busObject; - } - @Override - protected Object _getBOFromOM(OMElement omElement, Object busContext) + protected Object _getBOFromOM(OMElement omElement, JAXBBlockContext busContext) throws XMLStreamException, WebServiceException { // Shortcut to get business object from existing data source @@ -133,7 +110,19 @@ public class JAXBBlockImpl extends Block return ((JAXBBlockImpl) ds).getObject(); } } - return super._getBOFromOM(omElement, busContext); + + try { + return busContext.unmarshal(omElement); + } catch (JAXBException je) { + if (DEBUG_ENABLED) { + try { + log.debug("JAXBContext for unmarshal failure:" + + busContext.getJAXBContext(busContext.getClassLoader())); + } catch (Exception e) { + } + } + throw ExceptionFactory.makeWebServiceException(je); + } } /** @@ -143,7 +132,7 @@ public class JAXBBlockImpl extends Block * @throws XMLStreamException * @throws WebServiceException */ - private byte[] _getBytesFromBO(Object busObj, Object busContext, String encoding) + private byte[] _getBytesFromBO(Object busObj, JAXBBlockContext busContext, String encoding) throws XMLStreamException, WebServiceException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -161,37 +150,23 @@ public class JAXBBlockImpl extends Block @Override - protected XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) + protected XMLStreamReader _getReaderFromBO(Object busObj, JAXBBlockContext busContext) throws XMLStreamException, WebServiceException { ByteArrayInputStream baos = new ByteArrayInputStream(_getBytesFromBO(busObj, busContext, "utf-8")); return StAXUtils.createXMLStreamReader(baos, "utf-8"); } - protected XMLStreamReader _getReaderFromOM(OMElement omElement) { - XMLStreamReader reader; - if (omElement.getBuilder() != null && !omElement.getBuilder().isCompleted()) { - reader = omElement.getXMLStreamReaderWithoutCaching(); - } else { - reader = omElement.getXMLStreamReader(); - } - if (reader instanceof OMXMLStreamReader) { - ((OMXMLStreamReader)reader).setInlineMTOM(false); // Optimize attachment usage - } - return reader; - } - - protected void _outputFromBO(Object busObject, Object busContext, XMLStreamWriter writer) + @Override + protected void _outputFromBO(Object busObject, JAXBBlockContext busContext, XMLStreamWriter writer) throws XMLStreamException, WebServiceException { - JAXBBlockContext ctx = (JAXBBlockContext) busContext; - try { - ctx.marshal(busObject, writer); + busContext.marshal(busObject, writer); } catch (JAXBException je) { if (DEBUG_ENABLED) { try { log.debug("JAXBContext for marshal failure:" + - ctx.getJAXBContext(ctx.getClassLoader())); + busContext.getJAXBContext(busContext.getClassLoader())); } catch (Exception e) { } } @@ -199,26 +174,17 @@ public class JAXBBlockImpl extends Block } } + @Override public boolean isElementData() { return true; } + @Override public void close() { return; // Nothing to close } - public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException { - try { - byte[] bytes= _getBytesFromBO( - getBusinessObject(false), - busContext, - encoding); - return new ByteArrayInputStream(bytes); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - } - + @Override public Object getObject() { try { return getBusinessObject(false); @@ -227,14 +193,17 @@ public class JAXBBlockImpl extends Block } } + @Override public boolean isDestructiveRead() { return false; } + @Override public boolean isDestructiveWrite() { return false; } + @Override public OMDataSourceExt copy() throws OMException { if (DEBUG_ENABLED) { @@ -244,19 +213,10 @@ public class JAXBBlockImpl extends Block (JAXBDSContext) this.getBusinessContext()); } - public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { - try { - return _getBytesFromBO(getBusinessObject(false), - busContext, - encoding); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - } - + @Override public void setParent(Message message) { if (busContext != null) { - ((JAXBBlockContext) busContext).setMessage(message); + busContext.setMessage(message); } super.setParent(message); } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/OMBlockImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/OMBlockImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/OMBlockImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/OMBlockImpl.java Sun Dec 17 22:34:08 2017 @@ -20,7 +20,6 @@ package org.apache.axis2.jaxws.message.databinding.impl; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMOutputFormat; import org.apache.axis2.jaxws.ExceptionFactory; import org.apache.axis2.jaxws.message.databinding.OMBlock; import org.apache.axis2.jaxws.message.factory.BlockFactory; @@ -30,14 +29,9 @@ import javax.xml.stream.XMLStreamExcepti import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import javax.xml.ws.WebServiceException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; /** OMBlockImpl Block with a business object that is an OMElement */ -public class OMBlockImpl extends BlockImpl implements OMBlock { +public class OMBlockImpl extends BlockImpl<OMElement,Void> implements OMBlock { /** @@ -47,57 +41,47 @@ public class OMBlockImpl extends BlockIm * @param factory */ OMBlockImpl(OMElement busObject, BlockFactory factory) { - super(busObject, - null, + super(null, + busObject, busObject.getQName(), factory); } @Override - protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) + protected XMLStreamReader _getReaderFromBO(OMElement busObj, Void busContext) throws XMLStreamException, WebServiceException { - // Take a shortcut and return the OMElement - return this.getOMElement(); - } - - @Override - protected XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) - throws XMLStreamException, WebServiceException { - OMElement om = (OMElement)busObj; - return om.getXMLStreamReader(); + return busObj.getXMLStreamReader(); } @Override - protected Object _getBOFromOM(OMElement om, Object busContext) + protected OMElement _getBOFromOM(OMElement om, Void busContext) throws XMLStreamException, WebServiceException { return om; } @Override - protected OMElement _getOMFromBO(Object busObject, Object busContext) + protected OMElement _getOMFromBO(OMElement busObject, Void busContext) throws XMLStreamException, WebServiceException { - return (OMElement) busObject; + return busObject; } @Override - protected void _outputFromBO(Object busObject, Object busContext, XMLStreamWriter writer) + protected void _outputFromBO(OMElement busObject, Void busContext, XMLStreamWriter writer) throws XMLStreamException, WebServiceException { - OMElement om = (OMElement)busObject; - om.serialize(writer); + busObject.serialize(writer); } + @Override public boolean isElementData() { return true; } + + @Override public void close() { return; // Nothing to close } - public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException { - byte[] bytes = getXMLBytes(encoding); - return new ByteArrayInputStream(bytes); - } - + @Override public Object getObject() { try { return getBusinessObject(false); @@ -106,26 +90,13 @@ public class OMBlockImpl extends BlockIm } } + @Override public boolean isDestructiveRead() { return false; } + @Override public boolean isDestructiveWrite() { return false; } - - public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - OMOutputFormat format = new OMOutputFormat(); - format.setCharSetEncoding(encoding); - try { - serialize(baos, format); - baos.flush(); - return baos.toByteArray(); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } catch (IOException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockFactoryImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockFactoryImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockFactoryImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockFactoryImpl.java Sun Dec 17 22:34:08 2017 @@ -46,7 +46,7 @@ public class SOAPEnvelopeBlockFactoryImp */ public Block createFrom(OMElement omElement, Object context, QName qName) throws XMLStreamException { - return new SOAPEnvelopeBlockImpl(omElement, null, qName, this); + return new SOAPEnvelopeBlockImpl(omElement, qName, this); } /* (non-Javadoc) @@ -54,7 +54,7 @@ public class SOAPEnvelopeBlockFactoryImp */ public Block createFrom(Object businessObject, Object context, QName qName) throws WebServiceException { - return new SOAPEnvelopeBlockImpl((SOAPEnvelope)businessObject, null, qName, this); + return new SOAPEnvelopeBlockImpl((SOAPEnvelope)businessObject, qName, this); } public boolean isElement() { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SOAPEnvelopeBlockImpl.java Sun Dec 17 22:34:08 2017 @@ -23,34 +23,28 @@ package org.apache.axis2.jaxws.message.databinding.impl; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMOutputFormat; +import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axis2.jaxws.ExceptionFactory; import org.apache.axis2.jaxws.message.Message; import org.apache.axis2.jaxws.message.databinding.SOAPEnvelopeBlock; import org.apache.axis2.jaxws.message.factory.BlockFactory; import org.apache.axis2.jaxws.message.factory.MessageFactory; import org.apache.axis2.jaxws.message.impl.BlockImpl; -import org.apache.axis2.jaxws.message.util.SOAPElementReader; import org.apache.axis2.jaxws.registry.FactoryRegistry; import javax.xml.namespace.QName; -import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.dom.DOMSource; import javax.xml.ws.WebServiceException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; /** * * */ -public class SOAPEnvelopeBlockImpl extends BlockImpl implements SOAPEnvelopeBlock { +public class SOAPEnvelopeBlockImpl extends BlockImpl<SOAPEnvelope,Void> implements SOAPEnvelopeBlock { /** * Called by SOAPEnvelopeBlockFactory @@ -60,11 +54,11 @@ public class SOAPEnvelopeBlockImpl exten * @param qName * @param factory */ - public SOAPEnvelopeBlockImpl(Object busObject, Object busContext, + public SOAPEnvelopeBlockImpl(SOAPEnvelope busObject, QName qName, BlockFactory factory) { super(busObject, - busContext, - (qName == null) ? getQName((SOAPEnvelope)busObject) : qName, + null, + (qName == null) ? getQName(busObject) : qName, factory); } @@ -76,19 +70,16 @@ public class SOAPEnvelopeBlockImpl exten * @param qName * @param factory */ - public SOAPEnvelopeBlockImpl(OMElement omElement, Object busContext, + public SOAPEnvelopeBlockImpl(OMElement omElement, QName qName, BlockFactory factory) { - super(omElement, busContext, qName, factory); + super(omElement, null, qName, factory); } - /* (non-Javadoc) - * @see org.apache.axis2.jaxws.message.impl.BlockImpl#_getBOFromReader(javax.xml.stream.XMLStreamReader, java.lang.Object) - */ @Override - protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) + protected SOAPEnvelope _getBOFromOM(OMElement omElement, Void busContext) throws XMLStreamException, WebServiceException { MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class); - Message message = mf.createFrom(reader, null); + Message message = mf.createFrom(omElement.getXMLStreamReader(false), null); SOAPEnvelope env = message.getAsSOAPEnvelope(); this.setQName(getQName(env)); return env; @@ -98,16 +89,16 @@ public class SOAPEnvelopeBlockImpl exten * @see org.apache.axis2.jaxws.message.impl.BlockImpl#_getReaderFromBO(java.lang.Object, java.lang.Object) */ @Override - protected XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) + protected XMLStreamReader _getReaderFromBO(SOAPEnvelope busObj, Void busContext) throws XMLStreamException, WebServiceException { - return new SOAPElementReader((SOAPElement)busObj); + return OMXMLBuilderFactory.createOMBuilder(new DOMSource(busObj)).getDocument().getXMLStreamReader(false); } /* (non-Javadoc) * @see org.apache.axis2.jaxws.message.impl.BlockImpl#_outputFromBO(java.lang.Object, java.lang.Object, javax.xml.stream.XMLStreamWriter) */ @Override - protected void _outputFromBO(Object busObject, Object busContext, + protected void _outputFromBO(SOAPEnvelope busObject, Void busContext, XMLStreamWriter writer) throws XMLStreamException, WebServiceException { XMLStreamReader reader = _getReaderFromBO(busObject, busContext); @@ -124,19 +115,17 @@ public class SOAPEnvelopeBlockImpl exten return new QName(env.getNamespaceURI(), env.getLocalName(), env.getPrefix()); } + @Override public boolean isElementData() { return true; } + @Override public void close() { return; // Nothing to close } - public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException { - byte[] bytes = getXMLBytes(encoding); - return new ByteArrayInputStream(bytes); - } - + @Override public Object getObject() { try { return getBusinessObject(false); @@ -145,26 +134,13 @@ public class SOAPEnvelopeBlockImpl exten } } + @Override public boolean isDestructiveRead() { return false; } + @Override public boolean isDestructiveWrite() { return false; } - - public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - OMOutputFormat format = new OMOutputFormat(); - format.setCharSetEncoding(encoding); - try { - serialize(baos, format); - baos.flush(); - return baos.toByteArray(); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } catch (IOException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java Sun Dec 17 22:34:08 2017 @@ -19,19 +19,19 @@ package org.apache.axis2.jaxws.message.databinding.impl; +import org.apache.axiom.blob.Blobs; +import org.apache.axiom.blob.MemoryBlob; import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMSourcedElement; import org.apache.axiom.om.util.StAXUtils; import org.apache.axiom.soap.SOAP11Constants; import org.apache.axis2.datasource.SourceDataSource; -import org.apache.axis2.java.security.AccessController; import org.apache.axis2.jaxws.ExceptionFactory; import org.apache.axis2.jaxws.i18n.Messages; import org.apache.axis2.jaxws.message.databinding.SourceBlock; import org.apache.axis2.jaxws.message.factory.BlockFactory; import org.apache.axis2.jaxws.message.impl.BlockImpl; -import org.apache.axis2.jaxws.message.util.Reader2Writer; import org.apache.axis2.jaxws.utility.ConvertUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -45,15 +45,12 @@ import javax.xml.stream.XMLStreamWriter; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; import javax.xml.ws.WebServiceException; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.StringReader; -import java.io.UnsupportedEncodingException; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; +import java.io.IOException; +import java.io.OutputStream; /** * SourceBlock @@ -70,29 +67,9 @@ import java.security.PrivilegedException * A Source is consumed when read. The block will make a copy of the source if a non-consumable * request is made. */ -public class SourceBlockImpl extends BlockImpl implements SourceBlock { +public class SourceBlockImpl extends BlockImpl<Source,Void> implements SourceBlock { private static final Log log = LogFactory.getLog(SourceBlockImpl.class); - private static Class staxSource = null; - - static { - try { - // Dynamically discover if StAXSource is available - staxSource = forName("javax.xml.transform.stax.StAXSource"); - } catch (Exception e) { - if (log.isDebugEnabled()) { - log.debug("StAXSource is not present in the JDK. " + - "This is acceptable. Processing continues"); - } - } - try { - // Woodstox does not work with StAXSource - if(XMLInputFactory.newInstance().getClass().getName().indexOf("wstx")!=-1){ - staxSource = null; - } - } catch (Exception e){ - } - } /** * Constructor called from factory @@ -109,7 +86,7 @@ public class SourceBlockImpl extends Blo if (busObject instanceof DOMSource || busObject instanceof SAXSource || busObject instanceof StreamSource || - (busObject.getClass().equals(staxSource)) || + busObject instanceof StAXSource || busObject instanceof JAXBSource) { // Okay, these are supported Source objects if (log.isDebugEnabled()) { @@ -134,36 +111,9 @@ public class SourceBlockImpl extends Blo } @Override - protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) - throws XMLStreamException { - - // Best solution is to use a StAXSource - // However StAXSource is not widely accepted. - // For now, a StreamSource is always returned - /* - if (staxSource != null) { - try { - // TODO Constructor should be statically cached for performance - Constructor c = - staxSource.getDeclaredConstructor(new Class[] { XMLStreamReader.class }); - return c.newInstance(new Object[] { reader }); - } catch (Exception e) { - } - } - */ - - // TODO StreamSource is not performant...work is needed here to make this faster - Reader2Writer r2w = new Reader2Writer(reader); - String text = r2w.getAsString(); - StringReader sr = new StringReader(text); - return new StreamSource(sr); - - } - - @Override - protected Object _getBOFromOM(OMElement omElement, Object busContext) + protected Source _getBOFromOM(OMElement omElement, Void busContext) throws XMLStreamException, WebServiceException { - Object busObject; + Source busObject; // Shortcut to get business object from existing data source if (omElement instanceof OMSourcedElement) { @@ -182,21 +132,24 @@ public class SourceBlockImpl extends Blo } // Transform reader into business object - if (!hasFault) { - busObject = super._getBOFromOM(omElement, busContext); - } - else { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - omElement.serialize(baos); - - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - busObject = new StreamSource(bais); + MemoryBlob blob = Blobs.createMemoryBlob(); + OutputStream out = blob.getOutputStream(); + try { + if (!hasFault) { + omElement.serializeAndConsume(out); + } else { + omElement.serialize(out); + } + out.close(); + } catch (IOException ex) { + throw new XMLStreamException(ex); } + busObject = new StreamSource(blob.getInputStream()); return busObject; } @Override - protected XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) + protected XMLStreamReader _getReaderFromBO(Source busObj, Void busContext) throws XMLStreamException, WebServiceException { try { // TODO not sure if this is always the most performant way to do this. @@ -227,9 +180,7 @@ public class SourceBlockImpl extends Blo if (busObj instanceof StreamSource) { XMLInputFactory f = StAXUtils.getXMLInputFactory(); - XMLStreamReader reader = f.createXMLStreamReader((Source)busObj); - StAXUtils.releaseXMLInputFactory(f); - return reader; + return f.createXMLStreamReader(busObj); } //TODO: For GM we need to only use this approach when absolutely necessary. // For example, we don't want to do this if this is a (1.6) StaxSource or if the @@ -237,7 +188,7 @@ public class SourceBlockImpl extends Blo //TODO: Uncomment this code if woodstock parser handles // JAXBSource and SAXSource correctly. //return inputFactory.createXMLStreamReader((Source) busObj); - return _slow_getReaderFromSource((Source)busObj); + return _slow_getReaderFromSource(busObj); } catch (Exception e) { String className = (busObj == null) ? "none" : busObj.getClass().getName(); throw ExceptionFactory @@ -263,7 +214,7 @@ public class SourceBlockImpl extends Blo } @Override - protected void _outputFromBO(Object busObject, Object busContext, XMLStreamWriter writer) + protected void _outputFromBO(Source busObject, Void busContext, XMLStreamWriter writer) throws XMLStreamException, WebServiceException { // There is no fast way to output the Source to a writer, so get the reader // and pass use the default reader->writer. @@ -283,7 +234,7 @@ public class SourceBlockImpl extends Blo @Override - protected Object _getBOFromBO(Object busObject, Object busContext, boolean consume) { + protected Source _getBOFromBO(Source busObject, Void busContext, boolean consume) { if (consume) { return busObject; } else { @@ -294,50 +245,17 @@ public class SourceBlockImpl extends Blo } + @Override public boolean isElementData() { return false; // The source could be a text or element etc. } - /** - * Return the class for this name - * @return Class - */ - private static Class forName(final String className) throws ClassNotFoundException { - // NOTE: This method must remain private because it uses AccessController - Class cl = null; - try { - cl = (Class)AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws ClassNotFoundException { - return Class.forName(className); - } - } - ); - } catch (PrivilegedActionException e) { - if (log.isDebugEnabled()) { - log.debug("Exception thrown from AccessController: " + e); - } - throw (ClassNotFoundException)e.getException(); - } - - return cl; - } - - + @Override public void close() { return; // Nothing to close } - public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException { - try { - byte[] bytes = (byte[]) - ConvertUtils.convert(getBusinessObject(false), byte[].class); - return new ByteArrayInputStream(bytes); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - } - + @Override public Object getObject() { try { return getBusinessObject(false); @@ -346,29 +264,13 @@ public class SourceBlockImpl extends Blo } } + @Override public boolean isDestructiveRead() { return true; } + @Override public boolean isDestructiveWrite() { return true; } - - - public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { - if (log.isDebugEnabled()) { - log.debug("Start getXMLBytes"); - } - byte[] bytes = null; - try { - bytes = (byte[]) - ConvertUtils.convert(getBusinessObject(false), byte[].class); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - if (log.isDebugEnabled()) { - log.debug("End getXMLBytes"); - } - return bytes; - } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/XMLStringBlockImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/XMLStringBlockImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/XMLStringBlockImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/XMLStringBlockImpl.java Sun Dec 17 22:34:08 2017 @@ -24,30 +24,26 @@ import org.apache.axiom.om.OMDataSourceE import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.om.OMSourcedElement; +import org.apache.axiom.om.ds.StringOMDataSource; import org.apache.axiom.om.util.StAXUtils; -import org.apache.axis2.datasource.XMLStringDataSource; import org.apache.axis2.jaxws.ExceptionFactory; import org.apache.axis2.jaxws.message.databinding.XMLStringBlock; import org.apache.axis2.jaxws.message.factory.BlockFactory; import org.apache.axis2.jaxws.message.impl.BlockImpl; -import org.apache.axis2.jaxws.message.util.Reader2Writer; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import javax.xml.ws.WebServiceException; -import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.io.StringReader; -import java.io.UnsupportedEncodingException; /** * XMLStringBlock * <p/> * Block containing a business object that is a String of xml text */ -public class XMLStringBlockImpl extends BlockImpl implements XMLStringBlock { +public class XMLStringBlockImpl extends BlockImpl<String,Void> implements XMLStringBlock { /** * Constructor called from factory @@ -72,41 +68,29 @@ public class XMLStringBlockImpl extends super(omElement, null, qName, factory); } - protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) - throws XMLStreamException { - // Create a Reader2Writer converter and get the output as a String - Reader2Writer r2w; - if ((busContext == null) && (omElement != null) && (omElement.isComplete())) { - r2w = new Reader2Writer(reader, false); - } else { - r2w = new Reader2Writer(reader); - } - return r2w.getAsString(); - } - @Override - protected Object _getBOFromOM(OMElement omElement, Object busContext) + protected String _getBOFromOM(OMElement omElement, Void busContext) throws XMLStreamException, WebServiceException { // Shortcut to get business object from existing data source if (omElement instanceof OMSourcedElement) { OMDataSource ds = ((OMSourcedElement) omElement).getDataSource(); - if (ds instanceof XMLStringDataSource) { - return ((XMLStringDataSource) ds).getObject(); + if (ds instanceof StringOMDataSource) { + return ((StringOMDataSource) ds).getObject(); } } - return super._getBOFromOM(omElement, busContext); + return omElement.toStringWithConsume(); } - protected XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) + @Override + protected XMLStreamReader _getReaderFromBO(String busObj, Void busContext) throws XMLStreamException { // Create an XMLStreamReader from the inputFactory using the String as the sources - String str = (String)busObj; - StringReader sr = new StringReader(str); - return StAXUtils.createXMLStreamReader(sr); + return StAXUtils.createXMLStreamReader(new StringReader(busObj)); } - protected void _outputFromBO(Object busObject, Object busContext, XMLStreamWriter writer) + @Override + protected void _outputFromBO(String busObject, Void busContext, XMLStreamWriter writer) throws XMLStreamException { // There is no fast way to output the String to a writer, so get the reader // and pass use the default reader->writer. @@ -114,24 +98,17 @@ public class XMLStringBlockImpl extends _outputFromReader(reader, writer); } - + @Override public boolean isElementData() { return false; // The text could be element or text or something else } + @Override public void close() { return; // Nothing to close } - public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException { - try { - byte[] bytes = ((String) getBusinessObject(false)).getBytes(encoding); - return new ByteArrayInputStream(bytes); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } - } - + @Override public Object getObject() { try { return getBusinessObject(false); @@ -140,26 +117,20 @@ public class XMLStringBlockImpl extends } } + @Override public boolean isDestructiveRead() { // return false; // TODO: XMLStringBlock should actually be non destructive, but getReader() throws an exception when it is invoked the second time return true; } + @Override public boolean isDestructiveWrite() { return false; } + @Override public OMDataSourceExt copy() throws OMException { - return new XMLStringDataSource((String) getObject()); - } - - - public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { - try { - return ((String) getBusinessObject(false)).getBytes(encoding); - } catch (XMLStreamException e) { - throw ExceptionFactory.makeWebServiceException(e); - } + return new StringOMDataSource((String) getObject()); } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockFactoryImpl.java Sun Dec 17 22:34:08 2017 @@ -20,7 +20,8 @@ package org.apache.axis2.jaxws.message.impl; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.om.OMXMLParserWrapper; import org.apache.axis2.jaxws.message.Block; import org.apache.axis2.jaxws.message.factory.BlockFactory; @@ -62,7 +63,7 @@ public abstract class BlockFactoryImpl i public Block createFrom(XMLStreamReader reader, Object context, QName qName) throws XMLStreamException, WebServiceException { - StAXOMBuilder builder = new StAXOMBuilder(reader); + OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(reader); OMElement omElement = builder.getDocumentElement(); return createFrom(omElement, context, omElement.getQName()); } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java Sun Dec 17 22:34:08 2017 @@ -19,13 +19,14 @@ package org.apache.axis2.jaxws.message.impl; +import org.apache.axiom.blob.Blobs; import org.apache.axiom.om.OMDataSourceExt; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; -import org.apache.axiom.om.OMOutputFormat; -import org.apache.axiom.om.ds.ByteArrayDataSource; -import org.apache.axiom.om.impl.MTOMXMLStreamWriter; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.om.OMXMLParserWrapper; +import org.apache.axiom.om.ds.AbstractOMDataSource; +import org.apache.axiom.om.ds.BlobOMDataSource; import org.apache.axiom.om.util.StAXUtils; import org.apache.axis2.jaxws.ExceptionFactory; import org.apache.axis2.jaxws.i18n.Messages; @@ -43,11 +44,8 @@ import javax.xml.stream.XMLStreamExcepti import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import javax.xml.ws.WebServiceException; -import java.io.OutputStream; import java.io.StringReader; import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.util.HashMap; /** * BlockImpl Abstract Base class for various Block Implementations. @@ -62,12 +60,12 @@ import java.util.HashMap; * The derived classes don't have direct access to the instance data. This ensures that BlockImpl * controls the transformations. */ -public abstract class BlockImpl implements Block { +public abstract class BlockImpl<T,C> extends AbstractOMDataSource implements Block<T,C> { private static Log log = LogFactory.getLog(BlockImpl.class); - protected Object busObject; - protected Object busContext; + protected T busObject; + protected C busContext; protected OMElement omElement = null; @@ -78,8 +76,6 @@ public abstract class BlockImpl implemen protected boolean consumed = false; protected Message parent; - private HashMap map = null; // OMDataSourceExt properties - /** * A Block has the following components * @@ -88,7 +84,7 @@ public abstract class BlockImpl implemen * @param qName or null if unknown * @param factory that creates the Block */ - protected BlockImpl(Object busObject, Object busContext, QName qName, BlockFactory factory) { + protected BlockImpl(T busObject, C busContext, QName qName, BlockFactory factory) { this.busObject = busObject; this.busContext = busContext; this.qName = qName; @@ -103,31 +99,40 @@ public abstract class BlockImpl implemen * @param qName or null if unknown * @param factory that creates the Block */ - protected BlockImpl(OMElement omElement, Object busContext, QName qName, BlockFactory factory) { + protected BlockImpl(OMElement omElement, C busContext, QName qName, BlockFactory factory) { this.omElement = omElement; this.busContext = busContext; this.qName = qName; this.factory = factory; } + + // Hack to disambiguate the constructors is T = OMElement + protected BlockImpl(C busContext, OMElement omElement, QName qName, BlockFactory factory) { + this(omElement, busContext, qName, factory); + } /* (non-Javadoc) * @see org.apache.axis2.jaxws.message.Block#getBlockFactory() */ - public BlockFactory getBlockFactory() { + @Override + public final BlockFactory getBlockFactory() { return factory; } /* (non-Javadoc) * @see org.apache.axis2.jaxws.message.Block#getBusinessContext() */ - public Object getBusinessContext() { + @Override + public final Object getBusinessContext() { return busContext; } - public Message getParent() { + @Override + public final Message getParent() { return parent; } + @Override public void setParent(Message p) { parent = p; } @@ -135,7 +140,8 @@ public abstract class BlockImpl implemen /* (non-Javadoc) * @see org.apache.axis2.jaxws.message.Block#getBusinessObject(boolean) */ - public Object getBusinessObject(boolean consume) + @Override + public final T getBusinessObject(boolean consume) throws XMLStreamException, WebServiceException { if (consumed) { throw ExceptionFactory.makeWebServiceException( @@ -151,7 +157,7 @@ public abstract class BlockImpl implemen // Save the businessObject in a local variable // so that we can reset the Block if consume was indicated - Object newBusObject = busObject; + T newBusObject = busObject; setConsumed(consume); return newBusObject; } @@ -160,7 +166,8 @@ public abstract class BlockImpl implemen /* (non-Javadoc) * @see org.apache.axis2.jaxws.message.Block#getQName() */ - public QName getQName() throws WebServiceException { + @Override + public final QName getQName() throws WebServiceException { // If the QName is not known, find it try { if (qName == null) { @@ -172,7 +179,7 @@ public abstract class BlockImpl implemen try { XMLStreamReader newReader = _getReaderFromBO(busObject, busContext); busObject = null; - StAXOMBuilder builder = new StAXOMBuilder(newReader); + OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(newReader); omElement = builder.getDocumentElement(); omElement.close(true); } catch (Exception e) { @@ -211,14 +218,15 @@ public abstract class BlockImpl implemen * * @param qName */ - protected void setQName(QName qName) { + protected final void setQName(QName qName) { this.qName = qName; } /* (non-Javadoc) * @see org.apache.axis2.jaxws.message.Block#getXMLStreamReader(boolean) */ - public XMLStreamReader getXMLStreamReader(boolean consume) + @Override + public final XMLStreamReader getXMLStreamReader(boolean consume) throws XMLStreamException, WebServiceException { XMLStreamReader newReader = null; if (consumed) { @@ -231,15 +239,9 @@ public abstract class BlockImpl implemen Messages.getMessage("BlockImplErr1", this.getClass().getName())); } if (omElement != null) { + newReader = omElement.getXMLStreamReader(!consume); if (consume) { - if (omElement.getBuilder() != null && !omElement.getBuilder().isCompleted()) { - newReader = omElement.getXMLStreamReaderWithoutCaching(); - } else { - newReader = omElement.getXMLStreamReader(); - } omElement = null; - } else { - newReader = omElement.getXMLStreamReader(); } } else if (busObject != null) { // Getting the reader does not destroy the BusinessObject @@ -253,48 +255,20 @@ public abstract class BlockImpl implemen /* (non-Javadoc) * @see org.apache.axiom.om.OMDataSource#getReader() */ - public XMLStreamReader getReader() throws XMLStreamException { + @Override + public final XMLStreamReader getReader() throws XMLStreamException { return getXMLStreamReader(true); } /* (non-Javadoc) - * @see org.apache.axiom.om.OMDataSource#serialize(java.io.OutputStream, org.apache.axiom.om.OMOutputFormat) - */ - public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException { - MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format); - serialize(writer); - writer.flush(); - try { - writer.close(); - } catch (XMLStreamException e) { - // An exception can occur if nothing is written to the - // writer. This is possible if the underlying data source - // writers to the output stream directly. - if (log.isDebugEnabled()) { - log.debug("Catching and swallowing exception " + e); - } - } - } - - /* (non-Javadoc) - * @see org.apache.axiom.om.OMDataSource#serialize(java.io.Writer, org.apache.axiom.om.OMOutputFormat) - */ - public void serialize(Writer writerTarget, OMOutputFormat format) throws XMLStreamException { - MTOMXMLStreamWriter writer = - new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writerTarget)); - writer.setOutputFormat(format); - serialize(writer); - writer.flush(); - writer.close(); - } - - /* (non-Javadoc) * @see org.apache.axiom.om.OMDataSource#serialize(javax.xml.stream.XMLStreamWriter) */ - public void serialize(XMLStreamWriter writer) throws XMLStreamException { + @Override + public final void serialize(XMLStreamWriter writer) throws XMLStreamException { outputTo(writer, isDestructiveWrite()); } + @Override public OMElement getOMElement() throws XMLStreamException, WebServiceException { OMElement newOMElement = null; boolean consume = true; // get the OM consumes the message @@ -317,7 +291,8 @@ public abstract class BlockImpl implemen /* (non-Javadoc) * @see org.apache.axis2.jaxws.message.Block#isConsumed() */ - public boolean isConsumed() { + @Override + public final boolean isConsumed() { return consumed; } @@ -327,7 +302,7 @@ public abstract class BlockImpl implemen * @param consume * @return */ - public void setConsumed(boolean consume) { + public final void setConsumed(boolean consume) { if (consume) { this.consumed = true; busObject = null; @@ -343,11 +318,13 @@ public abstract class BlockImpl implemen } } - public boolean isQNameAvailable() { + @Override + public final boolean isQNameAvailable() { return (qName != null); } - public void outputTo(XMLStreamWriter writer, boolean consume) + @Override + public final void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, WebServiceException { if (log.isDebugEnabled()) { log.debug("Start outputTo"); @@ -381,7 +358,7 @@ public abstract class BlockImpl implemen * Called if we have passed the pivot point but someone wants to output the block. The actual * block implementation may choose to override this setting */ - protected void _postPivot_outputTo(XMLStreamWriter writer) + protected final void _postPivot_outputTo(XMLStreamWriter writer) throws XMLStreamException, WebServiceException { if (log.isDebugEnabled()) { QName theQName = isQNameAvailable() ? getQName() : new QName("unknown"); @@ -397,7 +374,7 @@ public abstract class BlockImpl implemen * Called if we have passed the pivot point but someone wants to output the block. The actual * block implementation may choose to override this setting. */ - protected XMLStreamReader _postPivot_getXMLStreamReader() + protected final XMLStreamReader _postPivot_getXMLStreamReader() throws XMLStreamException, WebServiceException { if (log.isDebugEnabled()) { QName theQName = isQNameAvailable() ? getQName() : new QName("unknown"); @@ -422,11 +399,12 @@ public abstract class BlockImpl implemen * @return true if the representation of the block is currently a business object. Derived classes * may use this information to get information in a performant way. */ - protected boolean isBusinessObject() { + protected final boolean isBusinessObject() { return busObject != null; } - public String traceString(String indent) { + @Override + public final String traceString(String indent) { // TODO add trace string return null; } @@ -442,23 +420,10 @@ public abstract class BlockImpl implemen * @param consume * @return */ - protected Object _getBOFromBO(Object busObject, Object busContext, boolean consume) { + protected T _getBOFromBO(T busObject, C busContext, boolean consume) { return busObject; } - - /** - * The derived class must provide an implementation that builds the business object from the - * reader - * - * @param reader XMLStreamReader, which is consumed - * @param busContext - * @return - */ - protected abstract Object _getBOFromReader(XMLStreamReader reader, Object busContext) - throws XMLStreamException, WebServiceException; - - /** * Default method for getting business object from OM. * Derived classes may override this method to get the business object from a @@ -470,11 +435,8 @@ public abstract class BlockImpl implemen * @throws XMLStreamException * @throws WebServiceException */ - protected Object _getBOFromOM(OMElement omElement, Object busContext) - throws XMLStreamException, WebServiceException { - XMLStreamReader reader = _getReaderFromOM(omElement); - return _getBOFromReader(reader, busContext); - } + protected abstract T _getBOFromOM(OMElement omElement, C busContext) + throws XMLStreamException, WebServiceException; /** * Get an XMLStreamReader for the BusinessObject The derived Block must implement this method @@ -483,35 +445,21 @@ public abstract class BlockImpl implemen * @param busContext * @return */ - protected abstract XMLStreamReader _getReaderFromBO(Object busObj, Object busContext) + protected abstract XMLStreamReader _getReaderFromBO(T busObj, C busContext) throws XMLStreamException, WebServiceException; /** - * @param omElement - * @return XMLStreamReader - */ - protected XMLStreamReader _getReaderFromOM(OMElement omElement) { - XMLStreamReader reader; - if (omElement.getBuilder() != null && !omElement.getBuilder().isCompleted()) { - reader = omElement.getXMLStreamReaderWithoutCaching(); - } else { - reader = omElement.getXMLStreamReader(); - } - return reader; - } - - /** * @param busObject * @param busContext * @return OMElement * @throws XMLStreamException * @throws WebServiceException */ - protected OMElement _getOMFromBO(Object busObject, Object busContext) + protected OMElement _getOMFromBO(T busObject, C busContext) throws XMLStreamException, WebServiceException { // Getting the reader does not destroy the BusinessObject XMLStreamReader newReader = _getReaderFromBO(busObject, busContext); - StAXOMBuilder builder = new StAXOMBuilder(newReader); + OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(newReader); return builder.getDocumentElement(); } @@ -523,7 +471,7 @@ public abstract class BlockImpl implemen * @param writer * @throws XMLStreamException */ - protected void _outputFromReader(XMLStreamReader reader, XMLStreamWriter writer) + protected final void _outputFromReader(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { Reader2Writer r2w = new Reader2Writer(reader); r2w.outputTo(writer); @@ -537,7 +485,7 @@ public abstract class BlockImpl implemen * @param writer * @throws XMLStreamException */ - protected void _outputFromOM(OMElement omElement, XMLStreamWriter writer, boolean consume) + protected final void _outputFromOM(OMElement omElement, XMLStreamWriter writer, boolean consume) throws XMLStreamException { if (consume) { if (log.isDebugEnabled()) { @@ -555,13 +503,14 @@ public abstract class BlockImpl implemen /* (non-Javadoc) * @see org.apache.axiom.om.OMDataSourceExt#copy() */ + @Override public OMDataSourceExt copy() throws OMException { // TODO: This is a default implementation. Much // more refactoring needs to occur to account for attachments. try { String encoding = "utf-8"; // Choose a common encoding byte[] bytes = this.getXMLBytes(encoding); - return new ByteArrayDataSource(bytes, encoding); + return new BlobOMDataSource(Blobs.createBlob(bytes), encoding); } catch (UnsupportedEncodingException e) { throw new OMException(e); } @@ -576,28 +525,7 @@ public abstract class BlockImpl implemen * @throws XMLStreamException * @throws WebServiceException */ - protected abstract void _outputFromBO(Object busObject, Object busContext, + protected abstract void _outputFromBO(T busObject, C busContext, XMLStreamWriter writer) throws XMLStreamException, WebServiceException; - - public Object getProperty(String key) { - if (map == null) { - return null; - } - return map.get(key); - } - - public Object setProperty(String key, Object value) { - if (map == null) { - map = new HashMap(); - } - return map.put(key, value); - } - - public boolean hasProperty(String key) { - if (map == null) { - return false; - } - return map.containsKey(key); - } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageFactoryImpl.java Sun Dec 17 22:34:08 2017 @@ -20,9 +20,9 @@ package org.apache.axis2.jaxws.message.impl; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.om.OMXMLParserWrapper; import org.apache.axiom.soap.SOAPEnvelope; -import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; import org.apache.axis2.jaxws.ExceptionFactory; import org.apache.axis2.jaxws.message.Block; import org.apache.axis2.jaxws.message.Message; @@ -57,14 +57,13 @@ public class MessageFactoryImpl implemen */ public Message createFrom(XMLStreamReader reader, Protocol protocol) throws XMLStreamException, WebServiceException { - StAXOMBuilder builder; + OMXMLParserWrapper builder; if (protocol == Protocol.rest) { // Build a normal OM tree - builder = new StAXOMBuilder(reader); + builder = OMXMLBuilderFactory.createStAXOMBuilder(reader); } else { // Build a SOAP OM tree - builder = new StAXSOAPModelBuilder(reader, - null); // Pass null as the version to trigger autodetection + builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(reader); } OMElement omElement = builder.getDocumentElement(); return createFrom(omElement, protocol);
