summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java42
-rw-r--r--java/sca/modules/contribution-java/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java11
-rw-r--r--java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java17
-rw-r--r--java/sca/modules/contribution-namespace/META-INF/MANIFEST.MF2
-rw-r--r--java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java23
-rw-r--r--java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java68
-rw-r--r--java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java25
-rw-r--r--java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java62
-rw-r--r--java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java15
-rw-r--r--java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java20
-rw-r--r--java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java149
-rw-r--r--java/sca/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java14
-rw-r--r--java/sca/modules/contribution/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java12
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java49
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java19
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java19
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java21
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java9
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java3
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java15
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java19
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java19
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java154
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java25
-rw-r--r--java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java42
-rw-r--r--java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java48
-rw-r--r--java/sca/modules/workspace/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java3
30 files changed, 509 insertions, 399 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
index 03a087a5ec..5701ae9593 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -70,7 +70,6 @@ import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Extensible;
-import org.apache.tuscany.sca.assembly.Extension;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Multiplicity;
import org.apache.tuscany.sca.assembly.Reference;
@@ -78,7 +77,6 @@ import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
@@ -833,48 +831,12 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
*/
protected void readExtendedAttributes(XMLStreamReader reader,
QName elementName,
- Extensible estensibleElement,
+ Extensible extensible,
StAXAttributeProcessor extensionAttributeProcessor)
throws ContributionReadException, XMLStreamException {
- for (int a = 0; a < reader.getAttributeCount(); a++) {
- QName attributeName = reader.getAttributeName(a);
- if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
- if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) {
- Object attributeValue = extensionAttributeProcessor.read(attributeName, reader);
- Extension attributeExtension;
- if (attributeValue instanceof Extension) {
- attributeExtension = (Extension)attributeValue;
- } else {
- attributeExtension = assemblyFactory.createExtension();
- attributeExtension.setQName(attributeName);
- attributeExtension.setAttribute(true);
- attributeExtension.setValue(attributeValue);
- }
- estensibleElement.getAttributeExtensions().add(attributeExtension);
- }
- }
- }
+ super.readExtendedAttributes(reader, extensible, extensionAttributeProcessor, assemblyFactory);
}
- /**
- *
- * @param attributeModel
- * @param writer
- * @param extensibleElement
- * @param extensionAttributeProcessor
- * @throws ContributionWriteException
- * @throws XMLStreamException
- */
- protected void writeExtendedAttributes(XMLStreamWriter writer,
- Extensible extensibleElement,
- StAXAttributeProcessor extensionAttributeProcessor)
- throws ContributionWriteException, XMLStreamException {
- for (Extension extension : extensibleElement.getAttributeExtensions()) {
- if (extension.isAttribute()) {
- extensionAttributeProcessor.write(extension, writer);
- }
- }
- }
/*protected void validatePolicySets(PolicySubject policySetAttachPoint)
throws ContributionResolveException {
diff --git a/java/sca/modules/contribution-java/META-INF/MANIFEST.MF b/java/sca/modules/contribution-java/META-INF/MANIFEST.MF
index 537fc124ba..5782ae1b0a 100644
--- a/java/sca/modules/contribution-java/META-INF/MANIFEST.MF
+++ b/java/sca/modules/contribution-java/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Bundle-Description: Apache Tuscany SCA Java Import/Export Model
Import-Package: javax.xml.namespace,
javax.xml.stream,
org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0",
org.apache.tuscany.sca.contribution.java;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
diff --git a/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java b/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java
index f35f35ac4c..c0bd9465e4 100644
--- a/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java
+++ b/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java
@@ -6,28 +6,29 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.java.impl;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.java.JavaExport;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* Implementation of a Java Import model
- *
+ *
* @version $Rev$ $Date$
*/
-public class JavaExportImpl implements JavaExport {
+public class JavaExportImpl extends ExtensibleImpl implements JavaExport {
private ModelResolver modelResolver;
/**
diff --git a/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java b/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java
index cc18d5f798..f2fdb3278e 100644
--- a/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java
+++ b/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java
@@ -6,21 +6,22 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.java.impl;
import java.util.List;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.Export;
import org.apache.tuscany.sca.contribution.java.JavaExport;
@@ -29,10 +30,10 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* Implementation of a Java Import model
- *
+ *
* @version $Rev$ $Date$
*/
-public class JavaImportImpl implements JavaImport {
+public class JavaImportImpl extends ExtensibleImpl implements JavaImport {
private ModelResolver modelResolver;
private List<Contribution> contributions;
/**
@@ -43,7 +44,7 @@ public class JavaImportImpl implements JavaImport {
* Contribution URI where the artifact is imported from
*/
private String location;
-
+
public JavaImportImpl() {
super();
}
@@ -99,10 +100,10 @@ public class JavaImportImpl implements JavaImport {
}
}
}
-
+
return false;
}
-
+
@Override
public String toString() {
return String.valueOf(packageName);
diff --git a/java/sca/modules/contribution-namespace/META-INF/MANIFEST.MF b/java/sca/modules/contribution-namespace/META-INF/MANIFEST.MF
index e5cda2aa33..dff2787b09 100644
--- a/java/sca/modules/contribution-namespace/META-INF/MANIFEST.MF
+++ b/java/sca/modules/contribution-namespace/META-INF/MANIFEST.MF
@@ -14,6 +14,8 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Namespace Import/Export Model
Import-Package: javax.xml.namespace,
javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0",
org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
diff --git a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
index 8991585d32..99af328964 100644
--- a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
+++ b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
@@ -6,35 +6,36 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.namespace.impl;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an export for the contribution
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceExportImpl implements NamespaceExport {
- private String namespace;
+public class NamespaceExportImpl extends ExtensibleImpl implements NamespaceExport {
+ private String namespace;
private ModelResolver modelResolver;
-
+
protected NamespaceExportImpl() {
super();
}
-
+
public String getNamespace() {
return namespace;
}
@@ -42,13 +43,13 @@ public class NamespaceExportImpl implements NamespaceExport {
public void setNamespace(String namespace) {
this.namespace = namespace;
}
-
+
public ModelResolver getModelResolver() {
return modelResolver;
}
-
+
public void setModelResolver(ModelResolver modelResolver) {
this.modelResolver = modelResolver;
}
-
+
}
diff --git a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
index 55f58b8328..030fc1754b 100644
--- a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
+++ b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.namespace.impl;
@@ -27,12 +27,15 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -41,26 +44,35 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* Artifact processor for Namespace export
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceExportProcessor implements StAXArtifactProcessor<NamespaceExport> {
+public class NamespaceExportProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<NamespaceExport> {
private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
private static final QName EXPORT = new QName(SCA11_NS, "export");
private static final String NAMESPACE = "namespace";
-
+
private final NamespaceImportExportFactory factory;
+ private final AssemblyFactory extensionFactory;
+ private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
private final Monitor monitor;
- public NamespaceExportProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+ public NamespaceExportProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor,
+ Monitor monitor) {
this.factory = modelFactories.getFactory(NamespaceImportExportFactory.class);
+ this.extensionFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
this.monitor = monitor;
}
-
+
/**
* Report a warning.
- *
+ *
* @param problems
* @param message
* @param model
@@ -71,47 +83,51 @@ public class NamespaceExportProcessor implements StAXArtifactProcessor<Namespace
monitor.problem(problem);
}
}
-
+
public QName getArtifactType() {
return EXPORT;
}
-
+
public Class<NamespaceExport> getModelType() {
return NamespaceExport.class;
}
-
+
/**
* Process <export namespace=""/>
*/
public NamespaceExport read(XMLStreamReader reader) throws ContributionReadException {
NamespaceExport namespaceExport = this.factory.createNamespaceExport();
QName element = null;
-
+
try {
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
element = reader.getName();
-
+
// Read <export>
if (EXPORT.equals(element)) {
String ns = reader.getAttributeValue(null, NAMESPACE);
if (ns == null) {
error("AttributeNameSpaceMissing", reader);
//throw new ContributionReadException("Attribute 'namespace' is missing");
- } else
+ } else {
namespaceExport.setNamespace(ns);
- }
-
+ }
+ readExtendedAttributes(reader, namespaceExport, attributeProcessor, extensionFactory);
+ } else {
+ readExtendedElement(reader, namespaceExport, extensionProcessor);
+ }
+
break;
case XMLStreamConstants.END_ELEMENT:
if (EXPORT.equals(reader.getName())) {
return namespaceExport;
}
- break;
+ break;
}
-
+
// Read the next element
if (reader.hasNext()) {
reader.next();
@@ -122,24 +138,28 @@ public class NamespaceExportProcessor implements StAXArtifactProcessor<Namespace
ContributionReadException ex = new ContributionReadException(e);
error("XMLStreamException", reader, ex);
}
-
+
return namespaceExport;
}
public void write(NamespaceExport namespaceExport, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
-
+
// Write <export>
writer.writeStartElement(EXPORT.getNamespaceURI(), EXPORT.getLocalPart());
-
+
if (namespaceExport.getNamespace() != null) {
writer.writeAttribute(NAMESPACE, namespaceExport.getNamespace());
}
-
+
+ writeExtendedAttributes(writer, namespaceExport, attributeProcessor);
+
+ writeExtendedElements(writer, namespaceExport, extensionProcessor);
+
writer.writeEndElement();
}
public void resolve(NamespaceExport namespaceExport, ModelResolver resolver) throws ContributionResolveException {
-
+
if (namespaceExport.getNamespace() != null)
// Initialize the export's resolver
namespaceExport.setModelResolver(new NamespaceExportModelResolver(resolver));
diff --git a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
index 6d2a31f702..35e2d539d4 100644
--- a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
+++ b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
@@ -6,19 +6,20 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.namespace.impl;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.Export;
import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
@@ -26,26 +27,26 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an import for the contribution
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceImportImpl implements NamespaceImport {
+public class NamespaceImportImpl extends ExtensibleImpl implements NamespaceImport {
private ModelResolver modelResolver;
/**
* The namespace to be imported
*/
- private String namespace;
+ private String namespace;
/**
* Optional location URI pointing to a Contribution that exports the namespace
*/
private String location;
-
+
protected NamespaceImportImpl() {
super();
}
-
+
public String getLocation() {
return location;
}
@@ -61,16 +62,16 @@ public class NamespaceImportImpl implements NamespaceImport {
public void setNamespace(String namespace) {
this.namespace = namespace;
}
-
+
public ModelResolver getModelResolver() {
return modelResolver;
}
-
+
public void setModelResolver(ModelResolver modelResolver) {
this.modelResolver = modelResolver;
}
-
+
/**
* Match a NamespaceImport to a given NamespaceExport based on :
* location is not provided
@@ -84,7 +85,7 @@ public class NamespaceImportImpl implements NamespaceImport {
}
return false;
}
-
+
@Override
public String toString() {
return String.valueOf(namespace);
diff --git a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
index 4c9129a0e4..b213d5e899 100644
--- a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
+++ b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.namespace.impl;
@@ -27,12 +27,15 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -41,28 +44,37 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* Artifact processor for Namespace import
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceImportProcessor implements StAXArtifactProcessor<NamespaceImport> {
+public class NamespaceImportProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<NamespaceImport> {
private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
-
+
private static final QName IMPORT = new QName(SCA11_NS, "import");
private static final String NAMESPACE = "namespace";
private static final String LOCATION = "location";
-
+
private final NamespaceImportExportFactory factory;
+ private final AssemblyFactory extensionFactory;
+ private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
private final Monitor monitor;
- public NamespaceImportProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+ public NamespaceImportProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor,
+ Monitor monitor) {
this.factory = modelFactories.getFactory(NamespaceImportExportFactory.class);
this.monitor = monitor;
+ this.extensionFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
}
-
+
/**
* Report a warning.
- *
+ *
* @param problems
* @param message
* @param model
@@ -73,11 +85,11 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac
monitor.problem(problem);
}
}
-
+
public QName getArtifactType() {
return IMPORT;
}
-
+
public Class<NamespaceImport> getModelType() {
return NamespaceImport.class;
}
@@ -88,36 +100,40 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac
public NamespaceImport read(XMLStreamReader reader) throws ContributionReadException {
NamespaceImport namespaceImport = this.factory.createNamespaceImport();
QName element;
-
+
try {
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
element = reader.getName();
-
+
// Read <import>
if (IMPORT.equals(element)) {
String ns = reader.getAttributeValue(null, NAMESPACE);
if (ns == null) {
error("AttributeNameSpaceMissing", reader);
//throw new ContributionReadException("Attribute 'namespace' is missing");
- } else
+ } else {
namespaceImport.setNamespace(ns);
-
+ }
+
String location = reader.getAttributeValue(null, LOCATION);
if (location != null) {
namespaceImport.setLocation(location);
}
+ readExtendedAttributes(reader, namespaceImport, attributeProcessor, extensionFactory);
+ } else {
+ readExtendedElement(reader, namespaceImport, extensionProcessor);
}
break;
case XMLStreamConstants.END_ELEMENT:
if (IMPORT.equals(reader.getName())) {
return namespaceImport;
}
- break;
+ break;
}
-
+
// Read the next element
if (reader.hasNext()) {
reader.next();
@@ -128,22 +144,24 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac
ContributionReadException ex = new ContributionReadException(e);
error("XMLStreamException", reader, ex);
}
-
+
return namespaceImport;
}
public void write(NamespaceImport namespaceImport, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
-
+
// Write <import>
writer.writeStartElement(IMPORT.getNamespaceURI(), IMPORT.getLocalPart());
-
+
if (namespaceImport.getNamespace() != null) {
writer.writeAttribute(NAMESPACE, namespaceImport.getNamespace());
}
if (namespaceImport.getLocation() != null) {
writer.writeAttribute(LOCATION, namespaceImport.getLocation());
}
-
+
+ writeExtendedAttributes(writer, namespaceImport, attributeProcessor);
+ writeExtendedElements(writer, namespaceImport, extensionProcessor);
writer.writeEndElement();
}
diff --git a/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java b/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java
index 109fa59855..a1c5189767 100644
--- a/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java
+++ b/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.namespace.impl;
@@ -43,13 +43,16 @@ import org.junit.Test;
/**
* Test NamespaceExportProcessorTestCase
- *
+ *
* @version $Rev$ $Date$
*/
public class NamespaceExportProcessorTestCase {
private static final String VALID_XML =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<export xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns=\"http://ns\" namespace=\"http://foo\"/>";
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<export xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns=\"http://ns\""
+ + " ns:ext=\"extended\" namespace=\"http://foo\">"
+ + "<ns:foo/></export>";
private static final String INVALID_XML =
"<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<export xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns=\"http://ns\"/>";
@@ -83,6 +86,8 @@ public class NamespaceExportProcessorTestCase {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
NamespaceExport namespaceExport = (NamespaceExport)staxProcessor.read(reader);
assertEquals("http://foo", namespaceExport.getNamespace());
+ assertEquals(1, namespaceExport.getAttributeExtensions().size());
+ assertEquals(1, namespaceExport.getExtensions().size());
}
/**
diff --git a/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java b/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java
index 3ac25d4016..676437042d 100644
--- a/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java
+++ b/java/sca/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.namespace.impl;
@@ -45,17 +45,19 @@ import org.junit.Test;
/**
* Test NamespaceImportProcessorTestCase
- *
+ *
* @version $Rev$ $Date$
*/
public class NamespaceImportProcessorTestCase {
private static final String VALID_XML =
"<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<import xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns=\"http://ns\" namespace=\"http://foo\" location=\"sca://contributions/001\"/>";
+ + "<import xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns=\"http://ns\""
+ + " namespace=\"http://foo\" location=\"sca://contributions/001\" ns:ext=\"extended\">"
+ + "<ns:foo/></import>";
private static final String INVALID_XML =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ "<import xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns=\"http://ns\" location=\"sca://contributions/001\"/>";
private static XMLInputFactory inputFactory;
@@ -85,9 +87,11 @@ public class NamespaceImportProcessorTestCase {
public void testLoad() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
NamespaceImport namespaceImport = (NamespaceImport)staxProcessor.read(reader);
-
+
assertEquals("http://foo", namespaceImport.getNamespace());
assertEquals("sca://contributions/001", namespaceImport.getLocation());
+ assertEquals(1, namespaceImport.getAttributeExtensions().size());
+ assertEquals(1, namespaceImport.getExtensions().size());
}
/**
@@ -107,5 +111,5 @@ public class NamespaceImportProcessorTestCase {
Problem problem = monitor.getLastProblem();
assertNotNull(problem);
assertEquals("AttributeNameSpaceMissing", problem.getMessageId());
- }
+ }
}
diff --git a/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java b/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
index 804af17719..7218a0fb73 100644
--- a/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
+++ b/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.xml;
@@ -39,6 +39,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -47,55 +48,69 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* Processor for contribution metadata
- *
+ *
* @version $Rev$ $Date$
*/
-public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<ContributionMetadata> {
+public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<ContributionMetadata> {
private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
-
+
private static final QName CONTRIBUTION_QNAME = new QName(SCA11_NS, "contribution");
private static final QName DEPLOYABLE_QNAME = new QName(SCA11_NS, "deployable");
-
+
private final AssemblyFactory assemblyFactory;
private final ContributionFactory contributionFactory;
-
private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
private Monitor monitor;
- public ContributionMetadataProcessor(AssemblyFactory assemblyFactory,
- ContributionFactory contributionFactory,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
- this.assemblyFactory = assemblyFactory;
- this.contributionFactory = contributionFactory;
+ public ContributionMetadataProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor,
+ Monitor monitor) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
this.monitor = monitor;
}
-
+
/**
* Report a error.
- *
+ *
* @param problems
* @param message
* @param model
*/
- private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-xml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
-
- public ContributionMetadataProcessor(FactoryExtensionPoint modelFactories,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
- this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
- this.extensionProcessor = extensionProcessor;
- this.monitor = monitor;
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
-
-
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(), "contribution-xml-validation-messages", Severity.ERROR,
+ model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
public QName getArtifactType() {
return CONTRIBUTION_QNAME;
}
@@ -107,37 +122,38 @@ public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor imp
public ContributionMetadata read(XMLStreamReader reader) throws ContributionReadException {
ContributionMetadata contribution = null;
QName name = null;
-
+
try {
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
name = reader.getName();
-
+
if (CONTRIBUTION_QNAME.equals(name)) {
-
+
// Read <contribution>
contribution = this.contributionFactory.createContributionMetadata();
contribution.setUnresolved(true);
-
- } else if (DEPLOYABLE_QNAME.equals(name)) {
-
+ readExtendedAttributes(reader, contribution, attributeProcessor, assemblyFactory);
+
+ } else if (DEPLOYABLE_QNAME.equals(name)) {
+
// Read <deployable>
QName compositeName = getQName(reader, "composite");
if (compositeName == null) {
- error("AttributeCompositeMissing", reader);
+ error("AttributeCompositeMissing", reader);
//throw new ContributionReadException("Attribute 'composite' is missing");
} else {
if (contribution != null) {
Composite composite = assemblyFactory.createComposite();
composite.setName(compositeName);
composite.setUnresolved(true);
- contribution.getDeployables().add(composite);
+ contribution.getDeployables().add(composite);
}
}
} else {
-
+
// Read an extension element
Object extension = extensionProcessor.read(reader);
if (extension != null && contribution != null) {
@@ -145,69 +161,74 @@ public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor imp
contribution.getImports().add((Import)extension);
} else if (extension instanceof Export) {
contribution.getExports().add((Export)extension);
+ } else {
+ contribution.getExtensions().add(extension);
}
}
}
break;
-
+
case XMLStreamConstants.END_ELEMENT:
if (CONTRIBUTION_QNAME.equals(reader.getName())) {
return contribution;
}
- break;
+ break;
}
-
+
//Read the next element
if (reader.hasNext()) {
reader.next();
}
}
- }
- catch (XMLStreamException e) {
+ } catch (XMLStreamException e) {
ContributionReadException ex = new ContributionReadException(e);
error("XMLStreamException", reader, ex);
}
-
+
return contribution;
}
- public void write(ContributionMetadata contribution, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
-
+ public void write(ContributionMetadata contribution, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
+
// Write <contribution>
writeStartDocument(writer, CONTRIBUTION_QNAME.getNamespaceURI(), CONTRIBUTION_QNAME.getLocalPart());
+ writeExtendedAttributes(writer, contribution, attributeProcessor);
// Write <import>
- for (Import imp: contribution.getImports()) {
+ for (Import imp : contribution.getImports()) {
extensionProcessor.write(imp, writer);
}
-
+
// Write <export>
- for (Export export: contribution.getExports()) {
+ for (Export export : contribution.getExports()) {
extensionProcessor.write(export, writer);
}
-
+
// Write <deployable>
- for (Composite deployable: contribution.getDeployables()) {
- writeStart(writer, DEPLOYABLE_QNAME.getNamespaceURI(), DEPLOYABLE_QNAME.getLocalPart(),
+ for (Composite deployable : contribution.getDeployables()) {
+ writeStart(writer,
+ DEPLOYABLE_QNAME.getNamespaceURI(),
+ DEPLOYABLE_QNAME.getLocalPart(),
new XAttr("composite", deployable.getName()));
writeEnd(writer);
}
-
+
writeEndDocument(writer);
}
public void resolve(ContributionMetadata contribution, ModelResolver resolver) throws ContributionResolveException {
-
+
// Resolve imports and exports
- for (Export export: contribution.getExports()) {
+ for (Export export : contribution.getExports()) {
extensionProcessor.resolve(export, resolver);
}
- for (Import import_: contribution.getImports()) {
+ for (Import import_ : contribution.getImports()) {
extensionProcessor.resolve(import_, resolver);
}
-
+
// Resolve deployable composites
- List<Composite> deployables = contribution.getDeployables();
+ List<Composite> deployables = contribution.getDeployables();
for (int i = 0, n = deployables.size(); i < n; i++) {
Composite deployable = deployables.get(i);
Composite resolved = (Composite)resolver.resolveModel(Composite.class, deployable);
@@ -215,7 +236,11 @@ public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor imp
deployables.set(i, resolved);
}
}
-
+
+ for (Object ext : contribution.getExtensions()) {
+ extensionProcessor.resolve(ext, resolver);
+ }
+
contribution.setUnresolved(false);
}
}
diff --git a/java/sca/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java b/java/sca/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
index 35e8b57136..d1c18beee5 100644
--- a/java/sca/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
+++ b/java/sca/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.xml;
@@ -47,16 +47,18 @@ import org.junit.Test;
/**
* Test the contribution metadata processor.
- *
+ *
* @version $Rev$ $Date$
*/
public class ContributionMetadataProcessorTestCase {
private static final String VALID_XML =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" xmlns:ns=\"http://ns\">"
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\""
+ + " xmlns:ns=\"http://ns\" ns:foo=\"extended\">"
+ "<deployable composite=\"ns:Composite1\"/>"
+ "<deployable composite=\"ns:Composite2\"/>"
+ + "<ns:bar x=\"1\"/>"
+ "</contribution>";
private static final String INVALID_XML =
@@ -95,6 +97,8 @@ public class ContributionMetadataProcessorTestCase {
ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader);
assertNotNull(contribution);
assertEquals(2, contribution.getDeployables().size());
+ assertEquals(1, contribution.getAttributeExtensions().size());
+ assertEquals(1, contribution.getExtensions().size());
}
@Test
diff --git a/java/sca/modules/contribution/META-INF/MANIFEST.MF b/java/sca/modules/contribution/META-INF/MANIFEST.MF
index 5614ccceb2..260fd1d3ed 100644
--- a/java/sca/modules/contribution/META-INF/MANIFEST.MF
+++ b/java/sca/modules/contribution/META-INF/MANIFEST.MF
@@ -31,6 +31,7 @@ Import-Package: javax.xml.namespace,
javax.xml.transform.stream,
javax.xml.validation,
org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java
index 6b44dc40c6..e3e1bd8fac 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java
@@ -71,16 +71,4 @@ public interface Artifact extends Base {
* @param model The model object
*/
void setModel(Object model);
-
- /**
- * Returns the contents of the artifact cached here.
- * @return the contents of the artifact
- */
- byte[] getContents();
-
- /**
- * Sets the contents of the artifact.
- * @param contents the contents of the artifact
- */
- void setContents(byte[] contents);
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java
index cdf397a500..de09725cdb 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution;
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.contribution;
import java.util.List;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
@@ -29,42 +30,42 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
*
* @version $Rev$ $Date$
*/
-public interface Contribution extends Artifact {
-
+public interface Contribution extends Artifact, Extensible {
+
/**
* Default location of contribution metadata in an SCA contribution.
*/
String SCA_CONTRIBUTION_META = "META-INF/sca-contribution.xml";
-
+
/**
* Default location of a generated contribution metadata in an SCA contribution.
*/
String SCA_CONTRIBUTION_GENERATED_META = "META-INF/sca-contribution-generated.xml";
-
+
/**
* Returns a list of exports based on the contribution metadata.
- *
+ *
* @return The list of exports in this contribution
*/
List<Export> getExports();
/**
* Returns a list of imports based on the contribution metadata.
- *
+ *
* @return The list of imports in this contribution
*/
List<Import> getImports();
-
+
/**
* Returns the list of deployable composites in the contribution.
- *
+ *
* @return The list of deployable composites
*/
List<Composite> getDeployables();
/**
* Returns the list of artifacts in the contribution.
- *
+ *
* @return The list of artifacts in the contribution
*/
List<Artifact> getArtifacts();
@@ -72,19 +73,19 @@ public interface Contribution extends Artifact {
/**
* Returns the model resolver for the models representing the artifacts
* visible in the scope of this contribution.
- *
+ *
* @return The model resolver
*/
ModelResolver getModelResolver();
-
+
/**
* Sets the model resolver for the models representing the artifacts
* visible in the scope of this contribution.
- *
+ *
* @param modelResolver The model resolver
*/
void setModelResolver(ModelResolver modelResolver);
-
+
/**
* Returns the list of contributions that this contribution depends on.
*
@@ -95,23 +96,23 @@ public interface Contribution extends Artifact {
/**
* Returns the ClassLoader used to load classes and resources from
* this contribution
- *
+ *
* FIXME Remove this, the base contribution model should not depend
- * on Java ClassLoaders.
- *
+ * on Java ClassLoaders.
+ *
* @return The contribution ClassLoader
*/
ClassLoader getClassLoader();
-
+
/**
* Sets the ClassLoader used to load classes and resources from
* this contribution
- *
+ *
* FIXME Remove this, the base contribution model should not depend
- * on Java ClassLoaders.
- *
+ * on Java ClassLoaders.
+ *
* @param classLoader the contribution class loader
*/
void setClassLoader(ClassLoader classLoader);
-
+
} \ No newline at end of file
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java
index 4043fb9eda..5f26c3d907 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution;
@@ -23,31 +23,32 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Base;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Extensible;
/**
* The representation of SCA contribution metadata.
*
* @version $Rev$ $Date$
*/
-public interface ContributionMetadata extends Base {
-
+public interface ContributionMetadata extends Base, Extensible {
+
/**
* Returns a list of exports based on the contribution metadata.
- *
+ *
* @return The list of exports
*/
List<Export> getExports();
/**
* Returns a list of imports based on the contribution metadata.
- *
+ *
* @return The list of imports
*/
List<Import> getImports();
-
+
/**
* Returns the list of deployable based on the contribution metadata.
- *
+ *
* @return The list of deployable composites
*/
List<Composite> getDeployables();
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java
index bfa16b1ce3..a6e5afe7b8 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java
@@ -6,42 +6,43 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution;
+import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an export.
- *
+ *
* @version $Rev$ $Date$
*/
-public interface Export {
+public interface Export extends Extensible {
/**
* Returns the model resolver for the models representing artifacts
* made available by this export.
- *
+ *
* @return The model resolver
*/
ModelResolver getModelResolver();
-
+
/**
* Sets the model resolver for the models representing artifacts
* made available by this export.
- *
+ *
* @param modelResolver
*/
void setModelResolver(ModelResolver modelResolver);
-
+
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java
index 35076f55a7..256a2387f1 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java
@@ -6,33 +6,34 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution;
+import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an import.
- *
+ *
* @version $Rev$ $Date$
*/
-public interface Import {
+public interface Import extends Extensible {
/**
* Returns the model resolver for the models representing artifacts
* made available by this import.
- *
+ *
* @return The model resolver
*/
ModelResolver getModelResolver();
@@ -40,17 +41,17 @@ public interface Import {
/**
* Sets the model resolver for the models representing artifacts
* made available by this import.
- *
+ *
* @param modelResolver The model resolver
*/
void setModelResolver(ModelResolver modelResolver);
-
+
/**
* Verify that a specific export actually exports what is being imported.
- *
+ *
* @param export The Exported being verified
* @return true/false
*/
boolean match(Export export);
-
+
} \ No newline at end of file
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java
index cb7d34593f..a362e97fc6 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java
@@ -32,7 +32,6 @@ class ArtifactImpl implements Artifact {
private String location;
private Object model;
private boolean unresolved;
- private byte[] contents;
ArtifactImpl() {
}
@@ -61,14 +60,6 @@ class ArtifactImpl implements Artifact {
this.model = model;
}
- public byte[] getContents() {
- return contents;
- }
-
- public void setContents(byte[] contents) {
- this.contents = contents;
- }
-
public boolean isUnresolved() {
return unresolved;
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java
index 3a5d20d5e7..04a39b061d 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.Export;
@@ -34,7 +35,7 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
*
* @version $Rev$ $Date$
*/
-class ContributionImpl implements Contribution {
+class ContributionImpl extends ExtensibleImpl implements Contribution {
private String uri;
private String location;
private Object model;
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java
index 75b12b1260..da8c879a93 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.impl;
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.ContributionMetadata;
import org.apache.tuscany.sca.contribution.Export;
import org.apache.tuscany.sca.contribution.Import;
@@ -32,7 +33,7 @@ import org.apache.tuscany.sca.contribution.Import;
*
* @version $Rev$ $Date$
*/
-class ContributionMetadataImpl implements ContributionMetadata {
+class ContributionMetadataImpl extends ExtensibleImpl implements ContributionMetadata {
private boolean unresolved;
private List<Export> exports = new ArrayList<Export>();
private List<Import> imports = new ArrayList<Import>();
@@ -40,15 +41,15 @@ class ContributionMetadataImpl implements ContributionMetadata {
ContributionMetadataImpl() {
}
-
+
public boolean isUnresolved() {
return unresolved;
}
-
+
public void setUnresolved(boolean unresolved) {
this.unresolved = unresolved;
}
-
+
public List<Export> getExports() {
return exports;
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java
index e67395337a..d4614e5427 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java
@@ -6,40 +6,41 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.impl;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.DefaultExport;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an export for the contribution
- *
+ *
* @version $Rev$ $Date$
*/
-public class DefaultExportImpl implements DefaultExport {
+public class DefaultExportImpl extends ExtensibleImpl implements DefaultExport {
private ModelResolver modelResolver;
-
+
protected DefaultExportImpl() {
super();
}
-
+
public ModelResolver getModelResolver() {
return modelResolver;
}
-
+
public void setModelResolver(ModelResolver modelResolver) {
this.modelResolver = modelResolver;
}
-
+
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java
index 17c09f2cbc..7ab535f916 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java
@@ -6,19 +6,20 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.impl;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.DefaultExport;
import org.apache.tuscany.sca.contribution.DefaultImport;
import org.apache.tuscany.sca.contribution.Export;
@@ -26,30 +27,30 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an import for the contribution
- *
+ *
* @version $Rev$ $Date$
*/
-public class DefaultImportImpl implements DefaultImport {
+public class DefaultImportImpl extends ExtensibleImpl implements DefaultImport {
private ModelResolver modelResolver;
protected DefaultImportImpl() {
super();
}
-
+
public ModelResolver getModelResolver() {
return modelResolver;
}
-
+
public void setModelResolver(ModelResolver modelResolver) {
this.modelResolver = modelResolver;
}
-
+
public boolean match(Export export) {
if (export instanceof DefaultExport) {
return true;
}
return false;
}
-
+
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java
index 158b3d7e64..e9da0b5780 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.contribution.processor;
@@ -35,16 +35,20 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+
/**
- * A base class with utility methods for the other artifact processors in this module.
- *
+ * A base class with utility methods for the other artifact processors in this module.
+ *
* @version $Rev$ $Date$
*/
public abstract class BaseStAXArtifactProcessor {
/**
- * Returns a QName from a string.
+ * Returns a QName from a string.
* @param reader
* @param value
* @return
@@ -178,9 +182,9 @@ public abstract class BaseStAXArtifactProcessor {
}
}
}
-
+
/**
- *
+ *
* @param writer
* @param uri
* @throws XMLStreamException
@@ -193,8 +197,8 @@ public abstract class BaseStAXArtifactProcessor {
if (prefix != null) {
return null;
} else {
-
- // Find an available prefix and bind it to the given URI
+
+ // Find an available prefix and bind it to the given URI
NamespaceContext nsc = writer.getNamespaceContext();
for (int i=1; ; i++) {
prefix = "ns" + i;
@@ -205,7 +209,7 @@ public abstract class BaseStAXArtifactProcessor {
writer.setPrefix(prefix, uri);
return prefix;
}
-
+
}
/**
@@ -219,12 +223,12 @@ public abstract class BaseStAXArtifactProcessor {
String prefix = writeElementPrefix(writer, uri);
writer.writeStartElement(uri, name);
if (prefix != null){
- writer.writeNamespace(prefix,uri);
+ writer.writeNamespace(prefix,uri);
}
writeAttributePrefixes(writer, attrs);
writeAttributes(writer, attrs);
}
-
+
/**
* Start an element.
* @param qname
@@ -234,9 +238,9 @@ public abstract class BaseStAXArtifactProcessor {
protected void writeStart(XMLStreamWriter writer, QName qname, XAttr... attrs) throws XMLStreamException {
writeStart(writer, qname.getNamespaceURI(), qname.getLocalPart(), attrs);
}
-
+
/**
- * End an element.
+ * End an element.
* @param writer
* @throws XMLStreamException
*/
@@ -303,10 +307,86 @@ public abstract class BaseStAXArtifactProcessor {
}
/**
+ *
+ * @param reader
+ * @param elementName
+ * @param extensible
+ * @param extensionAttributeProcessor
+ * @param extensionAttributeProcessor
+ * @param extensionFactory
+ * @throws ContributionReadException
+ * @throws XMLStreamException
+ */
+ protected void readExtendedAttributes(XMLStreamReader reader,
+ Extensible extensible,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ AssemblyFactory extensionFactory) throws ContributionReadException,
+ XMLStreamException {
+ QName elementName = reader.getName();
+ for (int a = 0; a < reader.getAttributeCount(); a++) {
+ QName attributeName = reader.getAttributeName(a);
+ if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
+ if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) {
+ Object attributeValue = extensionAttributeProcessor.read(attributeName, reader);
+ Extension attributeExtension;
+ if (attributeValue instanceof Extension) {
+ attributeExtension = (Extension)attributeValue;
+ } else {
+ attributeExtension = extensionFactory.createExtension();
+ attributeExtension.setQName(attributeName);
+ attributeExtension.setValue(attributeValue);
+ attributeExtension.setAttribute(true);
+ }
+ extensible.getAttributeExtensions().add(attributeExtension);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param attributeModel
+ * @param writer
+ * @param extensibleElement
+ * @param extensionAttributeProcessor
+ * @throws ContributionWriteException
+ * @throws XMLStreamException
+ */
+ protected void writeExtendedAttributes(XMLStreamWriter writer,
+ Extensible extensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor)
+ throws ContributionWriteException, XMLStreamException {
+ for (Extension extension : extensibleElement.getAttributeExtensions()) {
+ if (extension.isAttribute()) {
+ extensionAttributeProcessor.write(extension, writer);
+ }
+ }
+ }
+
+ protected void readExtendedElement(XMLStreamReader reader,
+ Extensible extensible,
+ StAXArtifactProcessor extensionProcessor) throws ContributionReadException,
+ XMLStreamException {
+ Object ext = extensionProcessor.read(reader);
+ if (extensible != null) {
+ extensible.getExtensions().add(ext);
+ }
+ }
+
+ protected void writeExtendedElements(XMLStreamWriter writer,
+ Extensible extensible,
+ StAXArtifactProcessor extensionProcessor) throws ContributionWriteException,
+ XMLStreamException {
+ for (Object ext : extensible.getExtensions()) {
+ extensionProcessor.write(ext, writer);
+ }
+ }
+
+ /**
* Represents an XML attribute that needs to be written to a document.
*/
public static class XAttr {
-
+
private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
private String uri = SCA11_NS;
@@ -374,7 +454,7 @@ public abstract class BaseStAXArtifactProcessor {
}
/**
- * Writes a string from a QName and registers a prefix for its namespace.
+ * Writes a string from a QName and registers a prefix for its namespace.
* @param reader
* @param value
* @return
@@ -390,14 +470,14 @@ public abstract class BaseStAXArtifactProcessor {
if (prefix.length() > 0) {
return prefix + ":" + qname.getLocalPart();
} else {
-
+
// Empty prefix, just return the local part of the given qname
return qname.getLocalPart();
}
-
+
} else {
-
- // Find an available prefix and bind it to the given URI
+
+ // Find an available prefix and bind it to the given URI
NamespaceContext nsc = writer.getNamespaceContext();
for (int i=1; ; i++) {
prefix = "ns" + i;
@@ -415,7 +495,7 @@ public abstract class BaseStAXArtifactProcessor {
}
/**
- * Registers a prefix for the namespace of a QName.
+ * Registers a prefix for the namespace of a QName.
* @param reader
* @param value
* @return
@@ -428,8 +508,8 @@ public abstract class BaseStAXArtifactProcessor {
if (prefix != null) {
return;
} else {
-
- // Find an available prefix and bind it to the given URI
+
+ // Find an available prefix and bind it to the given URI
NamespaceContext nsc = writer.getNamespaceContext();
for (int i=1; ; i++) {
prefix = "ns" + i;
@@ -451,12 +531,12 @@ public abstract class BaseStAXArtifactProcessor {
public void write(XMLStreamWriter writer) throws XMLStreamException {
String str;
if (value instanceof QName) {
-
+
// Write a QName
str = writeQNameValue(writer, (QName)value);
-
+
} else if (value instanceof List) {
-
+
// Write a list of values
List<?> values = (List<?>)value;
if (values.isEmpty()) {
@@ -468,7 +548,7 @@ public abstract class BaseStAXArtifactProcessor {
// Skip null values
continue;
}
-
+
if (v instanceof XAttr) {
// Write an XAttr value
((XAttr)v).write(writer);
@@ -482,14 +562,14 @@ public abstract class BaseStAXArtifactProcessor {
// Write a QName value
buffer.append(writeQNameValue(writer, (QName)v));
} else {
- // Write value as a string
+ // Write value as a string
buffer.append(String.valueOf(v));
}
}
str = buffer.toString();
-
+
} else {
-
+
// Write a string
if (value == null) {
return;
@@ -509,24 +589,24 @@ public abstract class BaseStAXArtifactProcessor {
}
/**
- * Registers a prefix for the namespace of a QName or list of QNames
+ * Registers a prefix for the namespace of a QName or list of QNames
* @param writer
* @throws XMLStreamException
*/
public void writePrefix(XMLStreamWriter writer) throws XMLStreamException {
if (value instanceof QName) {
-
+
// Write prefix for a single QName value
writeQNamePrefix(writer, (QName)value);
-
+
} else if (value instanceof List) {
-
+
// Write prefixes for a list of values
for (Object v: (List<?>)value) {
if (v instanceof QName) {
// Write prefix for a QName value
writeQNamePrefix(writer, (QName)v);
-
+
} else if (v instanceof XAttr) {
// Write prefix for an XAttr value
((XAttr)v).writePrefix(writer);
@@ -535,5 +615,5 @@ public abstract class BaseStAXArtifactProcessor {
}
}
}
-
+
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
index 618a97602f..ac1141128c 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
@@ -177,29 +177,22 @@ public class NodeFactoryImpl {
ConfiguredNodeImplementation configuration = getNodeConfiguration(bundle);
if (compositeContent != null) {
- Contribution deploymentContrib = createDeploymentContribution(compositeContent);
+ Composite deploymentComposite =
+ addDeploymentComposite(configuration.getContributions().get(0), compositeContent);
- configuration.setComposite(deploymentContrib.getDeployables().get(0));
- configuration.getContributions().add(deploymentContrib);
+ configuration.setComposite(deploymentComposite);
}
return configuration;
}
/**
- * Create an SCA contribution to hold the deployment composite
+ * Add the deployment composite to an installed SCA contribution
* @param compositeContent The XML string for the deployment composite
- * @return An SCA contribution with the deployment composite
+ * @return The deployment composite
* @throws Exception
*/
- private Contribution createDeploymentContribution(String compositeContent) throws Exception {
- // Create the deployment contribution
- Contribution contrib = contributionFactory.createContribution();
- contrib.setURI(SCA11_TUSCANY_NS + "/contributions/_deployment_");
- contrib.setLocation(SCA11_TUSCANY_NS + "/contributions/_deployment_");
- ModelResolver modelResolver = new ExtensibleModelResolver(contrib, modelResolvers, modelFactories);
- contrib.setModelResolver(modelResolver);
- contrib.setUnresolved(false);
+ private Composite addDeploymentComposite(Contribution contrib, String compositeContent) throws Exception {
// Load the deployment composite
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(compositeContent));
@@ -210,16 +203,14 @@ public class NodeFactoryImpl {
Artifact compositeArtifact = contributionFactory.createArtifact();
compositeArtifact.setModel(deploymentComposite);
- compositeArtifact.setURI("META-INF/_deployment_.composite");
- compositeArtifact.setContents(compositeContent.getBytes("UTF-8"));
- compositeArtifact.setLocation(SCA11_TUSCANY_NS + "/contributions/_deployment_/META-INF/_deployment_.composite");
+ compositeArtifact.setURI(deploymentComposite.getName()+".composite");
compositeArtifact.setUnresolved(false);
contrib.getArtifacts().add(compositeArtifact);
contrib.getDeployables().add(deploymentComposite);
analyzeProblems();
- return contrib;
+ return deploymentComposite;
}
private synchronized void init() {
diff --git a/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java b/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java
index 9a16553460..da8f957d9e 100644
--- a/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java
+++ b/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.workspace.processor.impl;
@@ -53,7 +53,7 @@ import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner;
/**
* URLArtifactProcessor that handles contribution files and the artifacts they contain
* and returns a contribution model.
- *
+ *
* @version $Rev$ $Date$
*/
public class ContributionContentProcessor implements URLArtifactProcessor<Contribution>{
@@ -76,7 +76,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
this.scanners = extensionPoints.getExtensionPoint(ContributionScannerExtensionPoint.class);
}
-
+
/*
public ContributionContentProcessor(FactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers,
URLArtifactProcessor<Object> artifactProcessor, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) {
@@ -89,17 +89,17 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
this.monitor = monitor;
}
*/
-
+
public String getArtifactType() {
return ".contribution/content";
}
-
+
public Class<Contribution> getModelType() {
return Contribution.class;
}
-
+
public Contribution read(URL parentURL, URI contributionURI, URL contributionURL) throws ContributionReadException {
-
+
// Create contribution model
Contribution contribution = contributionFactory.createContribution();
contribution.setURI(contributionURI.toString());
@@ -117,7 +117,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
scanner = new JarContributionScanner();
}
}
-
+
// Scan the contribution and list the artifacts contained in it
List<Artifact> artifacts = contribution.getArtifacts();
boolean contributionMetadata = false;
@@ -131,7 +131,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
artifact.setLocation(artifactURL.toString());
artifacts.add(artifact);
modelResolver.addModel(artifact);
-
+
// Read each artifact
Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
if (model != null) {
@@ -147,10 +147,12 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
contribution.getImports().addAll(c.getImports());
contribution.getExports().addAll(c.getExports());
contribution.getDeployables().addAll(c.getDeployables());
+ contribution.getExtensions().addAll(c.getExtensions());
+ contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
}
}
}
-
+
// If no sca-contribution.xml file was provided then just consider
// all composites in the contribution as deployables
if (!contributionMetadata) {
@@ -167,24 +169,24 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
DefaultExport defaultExport = contributionFactory.createDefaultExport();
contribution.getExports().add(defaultExport);
}
-
+
return contribution;
}
-
+
public void resolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException {
-
+
// Resolve the contribution model itself
ModelResolver contributionResolver = contribution.getModelResolver();
contribution.setUnresolved(false);
contributionResolver.addModel(contribution);
-
+
// Resolve imports and exports
for (Export export: contribution.getExports()) {
if (export instanceof DefaultExport) {
-
+
// Initialize the default export's resolver
export.setModelResolver(contributionResolver);
-
+
} else {
extensionProcessor.resolve(export, contributionResolver);
}
@@ -192,7 +194,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
for (Import import_: contribution.getImports()) {
extensionProcessor.resolve(import_, contributionResolver);
}
-
+
// Resolve all artifact models
for (Artifact artifact : contribution.getArtifacts()) {
Object model = artifact.getModel();
@@ -204,7 +206,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri
}
}
}
-
+
// Resolve deployable composites
List<Composite> deployables = contribution.getDeployables();
for (int i = 0, n = deployables.size(); i < n; i++) {
diff --git a/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java b/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java
index 6b7fc2f259..3af692c52c 100644
--- a/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java
+++ b/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java
@@ -6,15 +6,15 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.tuscany.sca.workspace.processor.impl;
@@ -55,7 +55,7 @@ import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner;
/**
* URLArtifactProcessor that handles contribution files and returns a contribution
* info model.
- *
+ *
* @version $Rev$ $Date$
*/
public class ContributionInfoProcessor implements URLArtifactProcessor<Contribution>{
@@ -76,7 +76,7 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
this.extensionProcessor = extensionProcessor;
this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
}
-
+
public ContributionInfoProcessor(FactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor) {
this.modelFactories = modelFactories;
this.modelResolvers = modelResolvers;
@@ -84,17 +84,17 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
this.artifactProcessor = artifactProcessor;
this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
}
-
+
public String getArtifactType() {
return ".contribution/info";
}
-
+
public Class<Contribution> getModelType() {
return null;
}
-
+
public Contribution read(URL parentURL, URI contributionURI, URL contributionURL) throws ContributionReadException {
-
+
// Create contribution model
Contribution contribution = contributionFactory.createContribution();
contribution.setURI(contributionURI.toString());
@@ -110,7 +110,7 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
} else {
scanner = new JarContributionScanner();
}
-
+
// Read generated and user sca-contribution.xml files
boolean contributionMetadata = false;
for (String path: new String[]{
@@ -127,14 +127,16 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
continue;
}
contributionMetadata = true;
-
+
// Read the sca-contribution.xml file
ContributionMetadata c = (ContributionMetadata)artifactProcessor.read(contributionURL, URI.create(path), url);
contribution.getImports().addAll(c.getImports());
contribution.getExports().addAll(c.getExports());
contribution.getDeployables().addAll(c.getDeployables());
+ contribution.getExtensions().addAll(c.getExtensions());
+ contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
}
-
+
// If no sca-contribution.xml file was provided then consider
// all composites in the contribution as deployables, and also
// read any files that are explicitly asssigned artifact processors
@@ -160,10 +162,10 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
}
if (read) {
URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
-
+
// Read each artifact
Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
-
+
// In the absence of more info, consider all composites as deployable
if (model instanceof Composite) {
contribution.getDeployables().add((Composite)model);
@@ -171,7 +173,7 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
}
}
}
-
+
// Add default contribution import and export
DefaultImport defaultImport = contributionFactory.createDefaultImport();
defaultImport.setModelResolver(new DefaultModelResolver());
@@ -179,24 +181,24 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
DefaultExport defaultExport = contributionFactory.createDefaultExport();
contribution.getExports().add(defaultExport);
}
-
+
return contribution;
}
-
+
public void resolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException {
-
+
// Mark the contribution model resolved
ModelResolver contributionResolver = contribution.getModelResolver();
contribution.setUnresolved(false);
contributionResolver.addModel(contribution);
-
+
// Resolve imports and exports
for (Export export: contribution.getExports()) {
if (export instanceof DefaultExport) {
-
+
// Initialize the default export's resolver
export.setModelResolver(contributionResolver);
-
+
} else {
extensionProcessor.resolve(export, contributionResolver);
}
@@ -204,12 +206,12 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut
for (Import import_: contribution.getImports()) {
extensionProcessor.resolve(import_, contributionResolver);
}
-
+
}
/**
* FIXME Temporary hack for testing the ClassLoaderModelResolver.
- *
+ *
* @param modelResolvers
*/
private static void hackResolvers(ModelResolverExtensionPoint modelResolvers) {
diff --git a/java/sca/modules/workspace/META-INF/MANIFEST.MF b/java/sca/modules/workspace/META-INF/MANIFEST.MF
index be3410ad88..21a127e24f 100644
--- a/java/sca/modules/workspace/META-INF/MANIFEST.MF
+++ b/java/sca/modules/workspace/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Domain Workspace Model
Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
diff --git a/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java b/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java
index 1ae3b6b664..0e2b673063 100644
--- a/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java
+++ b/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.Export;
@@ -35,7 +36,7 @@ import org.apache.tuscany.sca.workspace.Workspace;
*
* @version $Rev$ $Date$
*/
-class WorkspaceImpl implements Workspace {
+class WorkspaceImpl extends ExtensibleImpl implements Workspace {
private List<Contribution> contributions = new ArrayList<Contribution>();
private String location;