Repository: olingo-odata2 Updated Branches: refs/heads/OLINGO-231_PocForAndroid 543a98dfe -> 6ee4a3034
[OLINGO-231] Removed 'javax.xml' from AtomEntityProvider Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/6ee4a303 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/6ee4a303 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/6ee4a303 Branch: refs/heads/OLINGO-231_PocForAndroid Commit: 6ee4a3034bfa8aa5dfca374815d1ca4a020c8c0e Parents: 543a98d Author: Michael Bolz <[email protected]> Authored: Mon Apr 7 21:40:07 2014 +0200 Committer: Michael Bolz <[email protected]> Committed: Mon Apr 7 21:40:07 2014 +0200 ---------------------------------------------------------------------- .../olingo/odata2/api/xml/XMLStreamWriter.java | 4 +++ .../odata2/core/ep/AtomEntityProvider.java | 26 +++++++++++--------- .../ep/producer/AtomEntryEntityProducer.java | 7 +++--- .../core/ep/producer/AtomFeedProducer.java | 7 +++--- .../core/ep/producer/TombstoneProducer.java | 5 ++-- .../producer/XmlCollectionEntityProducer.java | 5 ++-- .../ep/producer/XmlErrorDocumentProducer.java | 5 ++-- .../core/ep/producer/XmlLinkEntityProducer.java | 5 ++-- .../ep/producer/XmlLinksEntityProducer.java | 5 ++-- .../ep/producer/XmlPropertyEntityProducer.java | 5 ++-- .../odata2/core/xml/JavaxStaxWriterWrapper.java | 19 ++++++++++++++ .../odata2/core/xml/XmlStreamFactory.java | 8 ++++++ .../olingo/odata2/core/ep/PerformanceTest.java | 14 +++++------ .../core/ep/producer/TombstoneProducerTest.java | 9 +++---- pom.xml | 1 + 15 files changed, 75 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/xml/XMLStreamWriter.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/xml/XMLStreamWriter.java b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/xml/XMLStreamWriter.java index 36b411d..c21c1fb 100644 --- a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/xml/XMLStreamWriter.java +++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/xml/XMLStreamWriter.java @@ -51,4 +51,8 @@ public interface XMLStreamWriter { public abstract void writeCharacters(String text) throws XMLStreamException; public abstract void writeStartElement(String prefix, String name, String namespace) throws XMLStreamException; + + void writeStartDocument(String defaultCharset, String xmlVersion) throws XMLStreamException; + + void writeAttribute(String namespaceM200708, String mEtag, String etag) throws XMLStreamException; } http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java index 441dace..b6b6bee 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java @@ -25,10 +25,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.ODataServiceVersion; import org.apache.olingo.odata2.api.commons.HttpStatusCodes; import org.apache.olingo.odata2.api.commons.ODataHttpHeaders; @@ -50,6 +46,8 @@ import org.apache.olingo.odata2.api.processor.ODataErrorContext; import org.apache.olingo.odata2.api.processor.ODataResponse; import org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder; import org.apache.olingo.odata2.api.servicedocument.ServiceDocument; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.commons.ContentType; import org.apache.olingo.odata2.core.commons.ContentType.ODataFormat; import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator; @@ -67,6 +65,7 @@ import org.apache.olingo.odata2.core.ep.producer.XmlLinksEntityProducer; import org.apache.olingo.odata2.core.ep.producer.XmlPropertyEntityProducer; import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer; import org.apache.olingo.odata2.core.exception.ODataRuntimeException; +import org.apache.olingo.odata2.core.xml.XmlStreamFactory; /** * @@ -111,7 +110,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { try { OutputStream outStream = csb.getOutputStream(); - XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + XMLStreamWriter writer = createXmlStreamWriter(outStream); XmlErrorDocumentProducer producer = new XmlErrorDocumentProducer(); producer.writeErrorDocument(writer, errorCode, message, locale, innerError); @@ -166,7 +165,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { try { OutputStream outStream = csb.getOutputStream(); - XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + XMLStreamWriter writer = createXmlStreamWriter(outStream); writer.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); AtomEntryEntityProducer as = new AtomEntryEntityProducer(properties); @@ -202,7 +201,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { try { OutputStream outStream = csb.getOutputStream(); - XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + XMLStreamWriter writer = createXmlStreamWriter(outStream); writer.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); XmlPropertyEntityProducer ps = new XmlPropertyEntityProducer(false); @@ -229,7 +228,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { try { OutputStream outStream = csb.getOutputStream(); - XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + XMLStreamWriter writer = createXmlStreamWriter(outStream); writer.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); AtomFeedProducer atomFeedProvider = new AtomFeedProducer(properties); @@ -258,7 +257,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { try { OutputStream outStream = csb.getOutputStream(); - XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + XMLStreamWriter writer = createXmlStreamWriter(outStream); writer.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); XmlLinkEntityProducer entity = new XmlLinkEntityProducer(properties); @@ -287,7 +286,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { try { OutputStream outStream = csb.getOutputStream(); - XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + XMLStreamWriter writer = createXmlStreamWriter(outStream); writer.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); XmlLinksEntityProducer entity = new XmlLinksEntityProducer(properties); @@ -314,7 +313,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { try { OutputStream outStream = csb.getOutputStream(); - XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + XMLStreamWriter writer = createXmlStreamWriter(outStream); writer.writeStartDocument(DEFAULT_CHARSET, XML_VERSION); XmlCollectionEntityProducer.append(writer, propertyInfo, data); @@ -333,6 +332,11 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider { } } + private XMLStreamWriter createXmlStreamWriter(OutputStream outStream) + throws EntityProviderException, XMLStreamException { + return XmlStreamFactory.createStreamWriter(outStream, DEFAULT_CHARSET); + } + @Override public ODataResponse writeFunctionImport(final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException { http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java index 307c828..89748c6 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomEntryEntityProducer.java @@ -26,9 +26,6 @@ import java.util.Date; import java.util.List; import java.util.Map; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.ODataCallback; import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.edm.EdmCustomizableFeedMappings; @@ -53,6 +50,8 @@ import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext; import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult; import org.apache.olingo.odata2.api.exception.ODataApplicationException; import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.commons.ContentType; import org.apache.olingo.odata2.core.commons.Encoder; import org.apache.olingo.odata2.core.edm.EdmDateTimeOffset; @@ -76,7 +75,7 @@ public class AtomEntryEntityProducer { } public void append(final XMLStreamWriter writer, final EntityInfoAggregator eia, final Map<String, Object> data, - final boolean isRootElement, final boolean isFeedPart) throws EntityProviderException { + final boolean isRootElement, final boolean isFeedPart) throws EntityProviderException, XMLStreamException { try { writer.writeStartElement(FormatXml.ATOM_ENTRY); http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java index 5684814..7e49e74 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/AtomFeedProducer.java @@ -23,9 +23,6 @@ import java.util.Date; import java.util.List; import java.util.Map; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.commons.InlineCount; import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.edm.EdmFacets; @@ -35,6 +32,8 @@ import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties; import org.apache.olingo.odata2.api.ep.callback.TombstoneCallback; import org.apache.olingo.odata2.api.ep.callback.TombstoneCallbackResult; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.commons.Encoder; import org.apache.olingo.odata2.core.edm.EdmDateTimeOffset; import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator; @@ -137,7 +136,7 @@ public class AtomFeedProducer { } private void appendEntries(final XMLStreamWriter writer, final EntityInfoAggregator eia, - final List<Map<String, Object>> data) throws EntityProviderException { + final List<Map<String, Object>> data) throws EntityProviderException, XMLStreamException { AtomEntryEntityProducer entryProvider = new AtomEntryEntityProducer(properties); for (Map<String, Object> singleEntryData : data) { entryProvider.append(writer, eia, singleEntryData, false, true); http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java index 7f1babb..2002444 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducer.java @@ -22,9 +22,6 @@ import java.util.Date; import java.util.List; import java.util.Map; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.EdmFacets; import org.apache.olingo.odata2.api.edm.EdmLiteralKind; import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException; @@ -32,6 +29,8 @@ import org.apache.olingo.odata2.api.edm.EdmTargetPath; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties; import org.apache.olingo.odata2.api.ep.callback.TombstoneCallback; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.edm.EdmDateTimeOffset; import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator; import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java index ef6fcb7..7e10134 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlCollectionEntityProducer.java @@ -20,11 +20,10 @@ package org.apache.olingo.odata2.core.ep.producer; import java.util.List; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.ep.EntityProviderException; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo; import org.apache.olingo.odata2.core.ep.util.FormatXml; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlErrorDocumentProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlErrorDocumentProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlErrorDocumentProducer.java index 05ee992..903b958 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlErrorDocumentProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlErrorDocumentProducer.java @@ -20,10 +20,9 @@ package org.apache.olingo.odata2.core.ep.producer; import java.util.Locale; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.Edm; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.util.FormatXml; public class XmlErrorDocumentProducer { http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java index fe59c4a..4fbc567 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinkEntityProducer.java @@ -20,12 +20,11 @@ package org.apache.olingo.odata2.core.ep.producer; import java.util.Map; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator; import org.apache.olingo.odata2.core.ep.util.FormatXml; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java index 84eff3b..31fbf8c 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlLinksEntityProducer.java @@ -21,12 +21,11 @@ package org.apache.olingo.odata2.core.ep.producer; import java.util.List; import java.util.Map; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator; import org.apache.olingo.odata2.core.ep.util.FormatXml; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java index b36205a..7f05942 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/XmlPropertyEntityProducer.java @@ -21,15 +21,14 @@ package org.apache.olingo.odata2.core.ep.producer; import java.util.List; import java.util.Map; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.edm.EdmCustomizableFeedMappings; import org.apache.olingo.odata2.api.edm.EdmException; import org.apache.olingo.odata2.api.edm.EdmLiteralKind; import org.apache.olingo.odata2.api.edm.EdmSimpleType; import org.apache.olingo.odata2.api.ep.EntityProviderException; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.aggregator.EntityComplexPropertyInfo; import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo; import org.apache.olingo.odata2.core.ep.util.FormatXml; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/JavaxStaxWriterWrapper.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/JavaxStaxWriterWrapper.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/JavaxStaxWriterWrapper.java index ba5bbe1..e76d367 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/JavaxStaxWriterWrapper.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/JavaxStaxWriterWrapper.java @@ -179,4 +179,23 @@ public class JavaxStaxWriterWrapper implements XMLStreamWriter, XMLStreamWriterF throw new XMLStreamException(e); } } + + @Override + public void writeStartDocument(String encoding, String xmlVersion) throws XMLStreamException { + try { + xmlStreamWriter.writeStartDocument(encoding, xmlVersion); + } catch (javax.xml.stream.XMLStreamException e) { + throw new XMLStreamException(e); + } + } + + @Override + public void writeAttribute(String namespaceUdi, String localName, String value) throws XMLStreamException { + try { + xmlStreamWriter.writeAttribute(namespaceUdi, localName, value); + } catch (javax.xml.stream.XMLStreamException e) { + throw new XMLStreamException(e); + } + + } } http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/XmlStreamFactory.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/XmlStreamFactory.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/XmlStreamFactory.java index dd1fe5d..92a6c91 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/XmlStreamFactory.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/xml/XmlStreamFactory.java @@ -21,6 +21,8 @@ package org.apache.olingo.odata2.core.xml; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.xml.*; +import java.io.OutputStream; + /** * */ @@ -38,6 +40,12 @@ public class XmlStreamFactory implements XMLStreamWriterFactory, XMLStreamReader return factory.createXMLStreamWriter(content); } + public static XMLStreamWriter createStreamWriter(OutputStream content, String charset) + throws EntityProviderException { + XmlStreamFactory factory = new XmlStreamFactory(); + return factory.createXMLStreamWriter(content); + } + public XMLStreamReaderFactory createReaderFactory() throws EntityProviderException { String factory = System.getProperty(XML_STREAM_READER_FACTORY_CLASS); if(factory != null) { http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java index e7ab5b9..e26911c 100644 --- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java +++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/PerformanceTest.java @@ -26,19 +26,17 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import javax.xml.stream.FactoryConfigurationError; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.edm.EdmEntitySet; import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties; import org.apache.olingo.odata2.api.exception.ODataException; import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator; import org.apache.olingo.odata2.core.ep.producer.AtomEntryEntityProducer; import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer; +import org.apache.olingo.odata2.core.xml.XmlStreamFactory; import org.apache.olingo.odata2.testutil.helper.StringHelper; import org.apache.olingo.odata2.testutil.mock.MockFacade; import org.custommonkey.xmlunit.exceptions.XpathException; @@ -79,7 +77,7 @@ public class PerformanceTest extends AbstractProviderTest { outStream = new ByteArrayOutputStream(); } - writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, "utf-8"); + writer = XmlStreamFactory.createStreamWriter(outStream); writer.writeStartElement("junit"); writer.writeDefaultNamespace(Edm.NAMESPACE_ATOM_2005); @@ -112,7 +110,7 @@ public class PerformanceTest extends AbstractProviderTest { @Test public void readAtomEntry() throws IOException, XpathException, SAXException, XMLStreamException, - FactoryConfigurationError, ODataException { + ODataException { long t = startTimer(); for (int i = 0; i < TIMES; i++) { @@ -141,7 +139,7 @@ public class PerformanceTest extends AbstractProviderTest { @Test public void readAtomEntryOptimized() throws IOException, XpathException, SAXException, XMLStreamException, - FactoryConfigurationError, ODataException { + ODataException { long t = startTimer(); ExpandSelectTreeNode epProperties = null; http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducerTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducerTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducerTest.java index 11fc21a..07fb145 100644 --- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducerTest.java +++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/TombstoneProducerTest.java @@ -31,18 +31,17 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - import org.apache.olingo.odata2.api.edm.Edm; import org.apache.olingo.odata2.api.ep.EntityProviderException; import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties; import org.apache.olingo.odata2.api.ep.callback.TombstoneCallback; +import org.apache.olingo.odata2.api.xml.XMLStreamException; +import org.apache.olingo.odata2.api.xml.XMLStreamWriter; import org.apache.olingo.odata2.core.commons.ContentType; import org.apache.olingo.odata2.core.ep.AbstractProviderTest; import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator; import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer; +import org.apache.olingo.odata2.core.xml.XmlStreamFactory; import org.apache.olingo.odata2.testutil.helper.StringHelper; import org.apache.olingo.odata2.testutil.mock.MockFacade; import org.junit.Before; @@ -65,7 +64,7 @@ public class TombstoneProducerTest extends AbstractProviderTest { public void initialize() throws Exception { csb = new CircleStreamBuffer(); OutputStream outStream = csb.getOutputStream(); - writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET); + writer = XmlStreamFactory.createStreamWriter(outStream, DEFAULT_CHARSET); defaultProperties = EntityProviderWriteProperties.serviceRoot(BASE_URI).build(); defaultEia = EntityInfoAggregator.create(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"), http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/6ee4a303/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 55700ca..cb26813 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,7 @@ <module>odata2-lib</module> <module>odata2-jpa-processor</module> <module>odata2-annotation-processor</module> + <module>odata2-android</module> <module>odata2-dist</module> <module>odata2-sample</module> </modules>
