Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java Wed Apr 22 21:51:38 2009 @@ -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 @@ 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,48 +30,48 @@ * * @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"; - + /** * Default location of deployable composites in an SCA contribution. */ String SCA_CONTRIBUTION_DEPLOYABLES = "META-INF/sca-deployables/"; - + /** * 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(); @@ -78,41 +79,41 @@ /** * 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 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); - + /** * Returns the type string based on the types that appear in * o.a.t.s.contribution.PackageType
Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java Wed Apr 22 21:51:38 2009 @@ -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 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(); Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java Wed Apr 22 21:51:38 2009 @@ -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); - + } Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java Wed Apr 22 21:51:38 2009 @@ -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 @@ /** * 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 Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java Wed Apr 22 21:51:38 2009 @@ -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; @@ -24,7 +24,7 @@ /** * The model representing an artifact in a contribution. - * + * * @version $Rev$ $Date$ */ class ArtifactImpl implements Artifact { @@ -32,11 +32,10 @@ private String location; private Object model; private boolean unresolved; - private byte[] contents; ArtifactImpl() { } - + public String getLocation() { return location; } @@ -44,35 +43,27 @@ public void setLocation(String location) { this.location = location; } - + public String getURI() { return uri; } - + public void setURI(String uri) { this.uri = uri; } - + public Object getModel() { return model; } - + public void setModel(Object model) { this.model = model; } - public byte[] getContents() { - return contents; - } - - public void setContents(byte[] contents) { - this.contents = contents; - } - public boolean isUnresolved() { return unresolved; } - + public void setUnresolved(boolean unresolved) { this.unresolved = unresolved; } @@ -81,7 +72,7 @@ public int hashCode() { return uri.hashCode(); } - + @Override public boolean equals(Object obj) { if (obj == this) { Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java Wed Apr 22 21:51:38 2009 @@ -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.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 @@ * * @version $Rev$ $Date$ */ -class ContributionImpl implements Contribution { +class ContributionImpl extends ExtensibleImpl implements Contribution { private String type; private String uri; private String location; @@ -46,13 +47,13 @@ private List<Composite> deployables = new ArrayList<Composite>(); private List<Artifact> artifacts = new ArrayList<Artifact>(); private ModelResolver modelResolver; - + // FIXME remove this dependency on Java ClassLoaders private ClassLoader classLoader; ContributionImpl() { } - + public String getLocation() { return this.location; } @@ -65,17 +66,17 @@ public ClassLoader getClassLoader() { return classLoader; } - + //FIXME Remove dependency on Java ClassLoaders public void setClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; } - - + + public String getURI() { return this.uri; } - + public void setURI(String uri) { this.uri = uri; } @@ -83,27 +84,27 @@ public Object getModel() { return model; } - + public void setModel(Object model) { this.model = model; } - + public byte[] getContents() { return contents; } - + public void setContents(byte[] contents) { this.contents = contents; } - + public boolean isUnresolved() { return unresolved; } - + public void setUnresolved(boolean unresolved) { this.unresolved = unresolved; } - + public ModelResolver getModelResolver() { return modelResolver; } @@ -111,7 +112,7 @@ public void setModelResolver(ModelResolver modelResolver) { this.modelResolver = modelResolver; } - + public List<Export> getExports() { return exports; } @@ -132,7 +133,7 @@ public int hashCode() { return uri.hashCode(); } - + @Override public boolean equals(Object obj) { if (obj == this) { Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java Wed Apr 22 21:51:38 2009 @@ -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.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 @@ * * @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 @@ ContributionMetadataImpl() { } - + public boolean isUnresolved() { return unresolved; } - + public void setUnresolved(boolean unresolved) { this.unresolved = unresolved; } - + public List<Export> getExports() { return exports; } Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java Wed Apr 22 21:51:38 2009 @@ -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; } - + } Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java Wed Apr 22 21:51:38 2009 @@ -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 @@ /** * 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; } - + } Modified: tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java (original) +++ tuscany/branches/sca-java-1.x/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java Wed Apr 22 21:51:38 2009 @@ -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,22 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; +import org.apache.tuscany.sca.assembly.Extensible; +import org.apache.tuscany.sca.assembly.Extension; +import org.apache.tuscany.sca.assembly.ExtensionFactory; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; + /** - * 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 +184,9 @@ } } } - + /** - * + * * @param writer * @param uri * @throws XMLStreamException @@ -193,8 +199,8 @@ 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 +211,7 @@ writer.setPrefix(prefix, uri); return prefix; } - + } /** @@ -219,12 +225,12 @@ 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 +240,9 @@ 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 +309,83 @@ } /** + * + * @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, + ExtensionFactory 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(attributeName, attributeValue, 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 SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0"; private String uri = SCA10_NS; @@ -374,7 +453,7 @@ } /** - * 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 +469,14 @@ 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 +494,7 @@ } /** - * 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 +507,8 @@ 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 +530,12 @@ 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 +547,7 @@ // Skip null values continue; } - + if (v instanceof XAttr) { // Write an XAttr value ((XAttr)v).write(writer); @@ -482,14 +561,14 @@ // 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 +588,24 @@ } /** - * 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 +614,5 @@ } } } - + } Modified: tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java (original) +++ tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java Wed Apr 22 21:51:38 2009 @@ -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; @@ -59,7 +59,7 @@ /** * URLArtifactProcessor that handles contribution files and the artifacts they contain * and returns a contribution model. - * + * * @version $Rev$ $Date$ */ public class ContributionContentProcessor implements URLArtifactProcessor<Contribution>{ @@ -80,7 +80,7 @@ this.monitor = monitor; URLArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); this.artifactProcessor = new ExtensibleURLArtifactProcessor(artifactProcessors, this.monitor); - + // Get and initialize artifact processors StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); @@ -88,7 +88,7 @@ this.extensionProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, monitor); this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } - + /* public ContributionContentProcessor(ModelFactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { @@ -101,17 +101,17 @@ 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()); @@ -127,7 +127,7 @@ } else { scanner = new JarContributionScanner(); } - + // Scan the contribution and list the artifacts contained in it List<Artifact> artifacts = contribution.getArtifacts(); boolean contributionMetadata = false; @@ -141,7 +141,7 @@ 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) { @@ -157,10 +157,12 @@ 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) { @@ -177,24 +179,24 @@ 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); } @@ -202,7 +204,7 @@ for (Import import_: contribution.getImports()) { extensionProcessor.resolve(import_, contributionResolver); } - + // Resolve all artifact models for (Artifact artifact : contribution.getArtifacts()) { Object model = artifact.getModel(); @@ -216,7 +218,7 @@ } } } - + // Resolve deployable composites List<Composite> deployables = contribution.getDeployables(); for (int i = 0, n = deployables.size(); i < n; i++) { @@ -230,7 +232,7 @@ /** * FIXME Temporary hack for testing the ClassLoaderModelResolver. - * + * * @param modelResolvers */ private static void hackResolvers(ModelResolverExtensionPoint modelResolvers) { Modified: tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java (original) +++ tuscany/branches/sca-java-1.x/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java Wed Apr 22 21:51:38 2009 @@ -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; @@ -60,7 +60,7 @@ /** * URLArtifactProcessor that handles contribution files and returns a contribution * info model. - * + * * @version $Rev$ $Date$ */ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribution>{ @@ -87,7 +87,7 @@ this.extensionProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, monitor); this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } - + /* public ContributionInfoProcessor(ModelFactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor) { this.modelFactories = modelFactories; @@ -97,17 +97,17 @@ 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()); @@ -123,7 +123,7 @@ } else { scanner = new JarContributionScanner(); } - + // Read generated and user sca-contribution.xml files boolean contributionMetadata = false; for (String path: new String[]{ @@ -140,14 +140,16 @@ 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 @@ -173,10 +175,10 @@ } 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); @@ -184,7 +186,7 @@ } } } - + // Add default contribution import and export DefaultImport defaultImport = contributionFactory.createDefaultImport(); defaultImport.setModelResolver(new DefaultModelResolver()); @@ -192,24 +194,24 @@ 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); } @@ -217,12 +219,12 @@ for (Import import_: contribution.getImports()) { extensionProcessor.resolve(import_, contributionResolver); } - + } /** * FIXME Temporary hack for testing the ClassLoaderModelResolver. - * + * * @param modelResolvers */ private static void hackResolvers(ModelResolverExtensionPoint modelResolvers) { Modified: tuscany/branches/sca-java-1.x/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java?rev=767683&r1=767682&r2=767683&view=diff ============================================================================== --- tuscany/branches/sca-java-1.x/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java (original) +++ tuscany/branches/sca-java-1.x/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/impl/WorkspaceImpl.java Wed Apr 22 21:51:38 2009 @@ -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.impl; @@ -23,6 +23,7 @@ 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 @@ * * @version $Rev$ $Date$ */ -class WorkspaceImpl implements Workspace { +class WorkspaceImpl extends ExtensibleImpl implements Workspace { private List<Contribution> contributions = new ArrayList<Contribution>(); private String location; @@ -43,14 +44,14 @@ private Object model; private byte[] contents; private boolean unresolved; - private ModelResolver modelResolver; - + private ModelResolver modelResolver; + /** - * Constructs a new workspace. + * Constructs a new workspace. */ WorkspaceImpl() { } - + public String getLocation() { return location; } @@ -74,11 +75,11 @@ public byte[] getContents() { return contents; } - + public void setContents(byte[] contents) { this.contents = contents; } - + public void setURI(String uri) { this.uri = uri; } @@ -94,7 +95,7 @@ public List<Contribution> getContributions() { return contributions; } - + public List<Artifact> getArtifacts() { return (List<Artifact>)(Object)contributions; } @@ -103,11 +104,11 @@ //FIXME Remove later return null; } - + public void setClassLoader(ClassLoader classLoader) { //FIXME Remove later } - + public List<Composite> getDeployables() { List<Composite> deployables = new ArrayList<Composite>(); for (Contribution contribution: contributions) { @@ -115,7 +116,7 @@ } return deployables; } - + public List<Export> getExports() { List<Export> exports = new ArrayList<Export>(); for (Contribution contribution: contributions) { @@ -123,7 +124,7 @@ } return exports; } - + public List<Import> getImports() { List<Import> imports = new ArrayList<Import>(); for (Contribution contribution: contributions) { @@ -131,11 +132,11 @@ } return imports; } - + public ModelResolver getModelResolver() { return modelResolver; } - + public void setModelResolver(ModelResolver modelResolver) { this.modelResolver = modelResolver; }
