summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/assembly-xml/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-08-12 23:43:27 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-08-12 23:43:27 +0000
commitc122a7379b57d45d2c994728171d20609842f7c5 (patch)
tree9ea10773724f65216b0ebe8d155db4dabaca08f9 /java/sca/modules/assembly-xml/src
parentaaa85d1773cf5740e22913a9b5027f0bfebbf1de (diff)
Fix issues around XMLStreamWriter based on the isRepairingNamespaces property of XMLOutputFactory
More refactoring to use common-xml and common-java git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@803742 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly-xml/src')
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java6
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java21
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java26
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java19
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java1
5 files changed, 9 insertions, 64 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
index 969115cf4c..672476a834 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
@@ -23,13 +23,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
-import java.net.URLConnection;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -64,9 +64,7 @@ public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implem
try {
// Create a stream reader
- URLConnection connection = url.openConnection();
- connection.setUseCaches(false);
- urlStream = connection.getInputStream();
+ urlStream = IOHelper.openStream(url);
XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
reader.nextTag();
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
index ec059ace81..bb3e88e8fb 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
@@ -20,13 +20,10 @@
package org.apache.tuscany.sca.assembly.xml;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLConnection;
import java.util.Collection;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -35,6 +32,7 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -84,25 +82,14 @@ public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements
throw new ContributionReadException("Request to read composite with uri or url NULL");
} // end if
InputStream scdlStream = null;
+
try {
- URLConnection connection;
- if (url.getProtocol().equals("file")) {
- File scdlFile = new File(url.toURI().getPath());
- connection = scdlFile.toURL().openConnection();
- } else {
- connection = url.openConnection();
- }
- connection.setUseCaches(false);
- scdlStream = connection.getInputStream();
+ scdlStream = IOHelper.openStream(url);;
} catch (IOException e) {
ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
error("ContributionReadException", url, ce);
throw ce;
- } catch (URISyntaxException e) {
- ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
- error("ContributionReadException", url, ce);
- throw ce;
- }
+ }
return read(uri, scdlStream);
}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java
index 401fa7123e..135fad43e7 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java
@@ -23,13 +23,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
-import java.net.URLConnection;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -64,33 +64,13 @@ public class ConstrainingTypeDocumentProcessor extends BaseAssemblyProcessor imp
try {
// Create a stream reader
- URLConnection connection = url.openConnection();
- connection.setUseCaches(false);
- urlStream = connection.getInputStream();
+ urlStream = IOHelper.openStream(url);
XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
reader.nextTag();
// Read the constrainingType model
ConstrainingType constrainingType = (ConstrainingType)extensionProcessor.read(reader);
-
- // For debugging purposes, write it back to XML
-// if (constrainingType != null) {
-// try {
-// ByteArrayOutputStream bos = new ByteArrayOutputStream();
-// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
-// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
-// extensionProcessor.write(constrainingType, outputFactory.createXMLStreamWriter(bos));
-// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
-// OutputFormat format = new OutputFormat();
-// format.setIndenting(true);
-// format.setIndent(2);
-// XMLSerializer serializer = new XMLSerializer(System.out, format);
-// serializer.serialize(document);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-
+
return constrainingType;
} catch (XMLStreamException e) {
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
index d69f30aceb..386fb24bf9 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
@@ -146,15 +146,6 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
}
/**
- * Write policies
- * @param attachPoint
- * @return
- */
- public void writePolicyPrefixes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
- writePolicyPrefixes(attachPoint, (Operation)null, writer);
- }
-
- /**
* Write policies associated with an operation
* @param attachPoint
* @param operation
@@ -178,16 +169,6 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
}
/**
- * Write policies
- * @param attachPoint
- * @return
- */
- public void writePolicyPrefixes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
- XAttr attr = writePolicies(attachPoint, operation);
- attr.writePrefix(writer);
- }
-
- /**
* Write policy intents associated with an operation.
* @param attachPoint
* @param operation
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java
index 88d8abdf2e..29608ac534 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java
@@ -111,7 +111,6 @@ public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding> {
public void write(SCABinding scaBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
// Write <binding.sca>
- policyProcessor.writePolicyPrefixes(scaBinding, writer);
writer.writeStartElement(SCA11_NS, BINDING_SCA);
policyProcessor.writePolicyAttributes(scaBinding, writer);