diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-12-18 17:55:54 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-12-18 17:55:54 +0000 |
commit | 1d9d90639d2b679dc82443dd1b2011effc34261b (patch) | |
tree | fb450853240b387a97adc63f461c836c01f1b430 /sca-java-2.x/trunk/modules/contribution/src | |
parent | c49527a54252db75c7498b786a736b86e56f8572 (diff) |
TUSCANY-3397 - Adding support for identifying the sca spec version used for contribution metadata being read
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@892324 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/contribution/src')
4 files changed, 40 insertions, 7 deletions
diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java index 5f26c3d907..a62d7155c9 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java @@ -31,6 +31,20 @@ import org.apache.tuscany.sca.assembly.Extensible; * @version $Rev$ $Date$ */ public interface ContributionMetadata extends Base, Extensible { + + /** + * Returns the spec version of the contribution metadata used to build this model + * + * @return the spec version used to build this model + */ + String getSpecVersion(); + + /** + * Sets the spec version of the contribution metadata used to build this model + * + * @param specVersion the spec version used to build this model + */ + void setSpecVersion(String specVersion); /** * Returns a list of exports based on the contribution metadata. diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java index da8c879a93..e2397c6f26 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java @@ -34,20 +34,22 @@ import org.apache.tuscany.sca.contribution.Import; * @version $Rev$ $Date$ */ class ContributionMetadataImpl extends ExtensibleImpl implements ContributionMetadata { - private boolean unresolved; + + private String specVersion = "undefined"; private List<Export> exports = new ArrayList<Export>(); private List<Import> imports = new ArrayList<Import>(); private List<Composite> deployables = new ArrayList<Composite>(); - + private boolean unresolved; + ContributionMetadataImpl() { } - public boolean isUnresolved() { - return unresolved; + public String getSpecVersion() { + return specVersion; } - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; + public void setSpecVersion(String specVersion) { + this.specVersion = specVersion; } public List<Export> getExports() { @@ -62,4 +64,11 @@ class ContributionMetadataImpl extends ExtensibleImpl implements ContributionMet return deployables; } + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } } diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java index 6feb0569c6..823684f422 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java @@ -135,6 +135,7 @@ public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor imp // Read <contribution> contribution = this.contributionFactory.createContributionMetadata(); + contribution.setSpecVersion(SCA11_NS); contribution.setUnresolved(true); readExtendedAttributes(reader, contribution, attributeProcessor, assemblyFactory, context); diff --git a/sca-java-2.x/trunk/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java b/sca-java-2.x/trunk/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java index a4aa564392..de6a8ac151 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java +++ b/sca-java-2.x/trunk/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java @@ -50,6 +50,7 @@ import org.junit.Test; */ public class ContributionMetadataProcessorTestCase { + private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912"; private static final String VALID_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\"" @@ -64,7 +65,7 @@ public class ContributionMetadataProcessorTestCase { + "<deployable composite=\"ns:Composite1\"/>" + "<deployable/>" + "</contribution>"; - + private static XMLInputFactory inputFactory; private static XMLOutputFactory outputFactory; private static StAXArtifactProcessor<Object> staxProcessor; @@ -110,6 +111,14 @@ public class ContributionMetadataProcessorTestCase { } @Test + public void testReadSpecVersion() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML)); + ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader, context); + assertNotNull(contribution); + assertEquals(SCA11_NS, contribution.getSpecVersion()); + } + + @Test public void testWrite() throws Exception { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML)); ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader, context); |