summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt')
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/DefaultImportExportXYZFactory.java28
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZ.java60
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZImpl.java64
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZModelResolver.java54
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZProcessor.java171
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactory.java27
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactoryImpl.java32
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZ.java59
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZImpl.java79
-rw-r--r--tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZProcessor.java171
10 files changed, 745 insertions, 0 deletions
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/DefaultImportExportXYZFactory.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/DefaultImportExportXYZFactory.java
new file mode 100644
index 0000000000..b9a7bf6c0c
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/DefaultImportExportXYZFactory.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+/**
+ * Default Import/Export model factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultImportExportXYZFactory extends ImportExportXYZFactoryImpl implements ImportExportXYZFactory {
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZ.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZ.java
new file mode 100644
index 0000000000..b099cfee11
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZ.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+import org.apache.tuscany.sca.contribution.Export;
+
+
+/**
+ * The model of an export.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ExportXYZ extends Export {
+
+ /**
+ * Get the uri of the contributions
+ *
+ * @return The URI
+ */
+ String getURI();
+
+ /**
+ * Set the uri of the contributions
+ *
+ * @param URI
+ */
+ void setURI(String URI);
+
+ /**
+ * Get anAttribute
+ *
+ * @return anAttribute
+ */
+ String getAnAttribute();
+
+ /**
+ * Set anAttribute
+ *
+ * @param anAttribute
+ */
+ void setAnAttribute(String anAttribute);
+
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZImpl.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZImpl.java
new file mode 100644
index 0000000000..6e98979b5d
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+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 model of an export
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExportXYZImpl extends ExtensibleImpl implements ExportXYZ {
+ private String URI;
+ private String anAttribute;
+ private ModelResolver modelResolver;
+
+ protected ExportXYZImpl() {
+ super();
+ }
+
+ public String getURI() {
+ return URI;
+ }
+
+ public void setURI(String URI) {
+ this.URI = URI;
+ }
+
+ public String getAnAttribute() {
+ return anAttribute;
+ }
+
+ public void setAnAttribute(String anAttribute) {
+ this.anAttribute = anAttribute;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZModelResolver.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZModelResolver.java
new file mode 100644
index 0000000000..c3d2663d62
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZModelResolver.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A model resolver for exports.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExportXYZModelResolver implements ModelResolver {
+
+ private ModelResolver resolver;
+
+ public ExportXYZModelResolver(ModelResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ public void addModel(Object resolved) {
+ throw new IllegalStateException();
+ }
+
+ public Object removeModel(Object resolved) {
+ throw new IllegalStateException();
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+
+ // Just delegate to the contribution's model resolver, namespace
+ // based filtering is implemented in the model specific model
+ // resolver, which know how to get the namespace of the particular
+ // type of model that they handle
+ return resolver.resolveModel(modelClass, unresolved);
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZProcessor.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZProcessor.java
new file mode 100644
index 0000000000..7d4aafa31f
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ExportXYZProcessor.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.ExtensionFactory;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+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.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
+
+
+public class ExportXYZProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<ExportXYZ> {
+
+ private static final String NS = "http://someuri";
+ private static final QName EXPORT = new QName(NS, "export.xyz");
+ private static final String URI = "uri";
+ private static final String AN_ATTRIBUTE = "anAttribute";
+
+ private final ImportExportXYZFactory factory;
+ private final Monitor monitor;
+ private final ExtensionFactory extensionFactory;
+
+
+ public ExportXYZProcessor(ModelFactoryExtensionPoint modelFactories,
+ Monitor monitor) {
+ this.factory = modelFactories.getFactory(ImportExportXYZFactory.class);
+ this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class);
+ this.monitor = monitor;
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(this.getClass().getName(), "export-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 = new ProblemImpl(this.getClass().getName(), "export-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return EXPORT;
+ }
+
+ public Class<ExportXYZ> getModelType() {
+ return ExportXYZ.class;
+ }
+
+
+ public ExportXYZ read(XMLStreamReader reader) throws ContributionReadException {
+ ExportXYZ export = this.factory.createExport();
+ 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, URI);
+ if (ns == null) {
+ error("AttributeNameSpaceMissing", reader);
+ } else {
+ export.setURI(ns);
+ }
+
+ String anAttribute = reader.getAttributeValue(null, AN_ATTRIBUTE);
+ export.setAnAttribute(anAttribute);
+ }
+
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (EXPORT.equals(reader.getName())) {
+ return export;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error("XMLStreamException", reader, ex);
+ }
+
+ return export;
+ }
+
+ public void write(ExportXYZ export, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <export>
+ writer.writeStartElement(EXPORT.getNamespaceURI(), EXPORT.getLocalPart());
+
+ if (export.getURI() != null) {
+ writer.writeAttribute(URI, export.getURI());
+ }
+
+ if (export.getAnAttribute() != null) {
+ writer.writeAttribute(AN_ATTRIBUTE, export.getAnAttribute());
+ }
+
+ writer.writeEndElement();
+ }
+
+ public void resolve(ExportXYZ export, ModelResolver resolver) throws ContributionResolveException {
+
+ if (export.getURI() != null)
+ // Initialize the export's resolver
+ export.setModelResolver(new ExportXYZModelResolver(resolver));
+ }
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactory.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactory.java
new file mode 100644
index 0000000000..db2bab7f99
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactory.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+public interface ImportExportXYZFactory {
+
+ ImportXYZ createImport();
+
+ ExportXYZ createExport();
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactoryImpl.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactoryImpl.java
new file mode 100644
index 0000000000..b0a9c80d88
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportExportXYZFactoryImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+public class ImportExportXYZFactoryImpl implements ImportExportXYZFactory {
+
+ public ImportXYZ createImport() {
+ return new ImportXYZImpl();
+ }
+
+ public ExportXYZ createExport() {
+ return new ExportXYZImpl();
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZ.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZ.java
new file mode 100644
index 0000000000..3e883e84a2
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZ.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+import org.apache.tuscany.sca.contribution.Import;
+
+/**
+ * The representation of an XML namespace import.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ImportXYZ extends Import {
+
+ /**
+ * Get the uri of the contributions
+ *
+ * @return The URI
+ */
+ String getURI();
+
+ /**
+ * Set the uri of the contributions
+ *
+ * @param URI
+ */
+ void setURI(String URI);
+
+ /**
+ * Get anAttribute
+ *
+ * @return anAttribute
+ */
+ String getAnAttribute();
+
+ /**
+ * Set anAttribute
+ *
+ * @param anAttribute
+ */
+ void setAnAttribute(String anAttribute);
+
+} \ No newline at end of file
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZImpl.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZImpl.java
new file mode 100644
index 0000000000..ef3f0653f3
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZImpl.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+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;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of an import for the contribution
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImportXYZImpl extends ExtensibleImpl implements ImportXYZ {
+ private ModelResolver modelResolver;
+
+ private String URI;
+ private String anAttribute;
+
+
+ protected ImportXYZImpl() {
+ super();
+ }
+
+ public String getURI() {
+ return URI;
+ }
+
+ public void setURI(String URI) {
+ this.URI = URI;
+ }
+
+ public String getAnAttribute() {
+ return anAttribute;
+ }
+
+ public void setAnAttribute(String anAttribute) {
+ this.anAttribute = anAttribute;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+ public boolean match(Export export) {
+ if (export instanceof ExportXYZ){
+ return anAttribute.equals(((ExportXYZ)export).getAnAttribute());
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(URI);
+ }
+}
diff --git a/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZProcessor.java b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZProcessor.java
new file mode 100644
index 0000000000..763fa30002
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/workspace-manager/src/main/java/org/apache/tuscany/sca/imprt/xyz/ImportXYZProcessor.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ */
+
+package org.apache.tuscany.sca.imprt.xyz;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.ExtensionFactory;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+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.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
+
+/**
+ * Artifact processor for Namespace import
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImportXYZProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<ImportXYZ> {
+ private static final String NS = "http://someuri";
+
+ private static final QName IMPORT = new QName(NS, "import.xyz");
+
+ private static final String URI = "uri";
+ private static final String AN_ATTRIBUTE = "anAttribute";
+
+ private final ImportExportXYZFactory factory;
+ private final ExtensionFactory extensionFactory;
+ private final Monitor monitor;
+
+ public ImportXYZProcessor(ModelFactoryExtensionPoint modelFactories,
+ Monitor monitor) {
+ this.factory = modelFactories.getFactory(ImportExportXYZFactory.class);
+ this.monitor = monitor;
+ this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class);
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-namespace-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 = new ProblemImpl(this.getClass().getName(), "contribution-namespace-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return IMPORT;
+ }
+
+ public Class<ImportXYZ> getModelType() {
+ return ImportXYZ.class;
+ }
+
+ public ImportXYZ read(XMLStreamReader reader) throws ContributionReadException {
+ ImportXYZ importXYZ= this.factory.createImport();
+ 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, URI);
+ if (ns == null) {
+ error("AttributeNameSpaceMissing", reader);
+ } else {
+ importXYZ.setURI(ns);
+ }
+
+ String anAttribute = reader.getAttributeValue(null, AN_ATTRIBUTE);
+ if (anAttribute != null) {
+ importXYZ.setAnAttribute(anAttribute);
+ }
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (IMPORT.equals(reader.getName())) {
+ return importXYZ;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error("XMLStreamException", reader, ex);
+ }
+
+ return importXYZ;
+ }
+
+ public void write(ImportXYZ importXYZ, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <import>
+ writer.writeStartElement(IMPORT.getNamespaceURI(), IMPORT.getLocalPart());
+
+ if (importXYZ.getURI() != null) {
+ writer.writeAttribute(URI, importXYZ.getURI());
+ }
+ if (importXYZ.getAnAttribute() != null) {
+ writer.writeAttribute(AN_ATTRIBUTE, importXYZ.getAnAttribute());
+ }
+
+ writer.writeEndElement();
+ }
+
+
+ public void resolve(ImportXYZ model, ModelResolver resolver) throws ContributionResolveException {
+ }
+}