From cde3d2629677a07aa09e3c7fbe117b680c0f5df7 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:09:08 +0000 Subject: Moving 2.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835133 13f79535-47bb-0310-9956-ffa450edef68 --- .../namespace/impl/NamespaceExportImpl.java | 54 -------- .../impl/NamespaceExportModelResolver.java | 54 -------- .../namespace/impl/NamespaceExportProcessor.java | 141 -------------------- .../impl/NamespaceImportExportFactoryImpl.java | 41 ------ .../namespace/impl/NamespaceImportImpl.java | 92 ------------- .../namespace/impl/NamespaceImportProcessor.java | 147 --------------------- 6 files changed, 529 deletions(-) delete mode 100644 branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java delete mode 100644 branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java delete mode 100644 branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java delete mode 100644 branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java delete mode 100644 branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java delete mode 100644 branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java (limited to 'branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl') diff --git a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java b/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java deleted file mode 100644 index 8991585d32..0000000000 --- a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.contribution.namespace.impl; - -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; - private ModelResolver modelResolver; - - protected NamespaceExportImpl() { - super(); - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public ModelResolver getModelResolver() { - return modelResolver; - } - - public void setModelResolver(ModelResolver modelResolver) { - this.modelResolver = modelResolver; - } - -} diff --git a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java b/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java deleted file mode 100644 index 5c5ae22f77..0000000000 --- a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.contribution.namespace.impl; - -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - -/** - * A model resolver for namespace exports. - * - * @version $Rev$ $Date$ - */ -public class NamespaceExportModelResolver implements ModelResolver { - - private ModelResolver resolver; - - public NamespaceExportModelResolver(ModelResolver resolver) { - this.resolver = resolver; - } - - public void addModel(Object resolved) { - throw new IllegalStateException(); - } - - public Object removeModel(Object resolved) { - throw new IllegalStateException(); - } - - public T resolveModel(Class 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/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java b/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java deleted file mode 100644 index 6bf7c8f1d7..0000000000 --- a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.contribution.namespace.impl; - -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.contribution.namespace.NamespaceExport; -import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory; -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.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; - -/** - * Artifact processor for Namespace export - * - * @version $Rev$ $Date$ - */ -public class NamespaceExportProcessor implements StAXArtifactProcessor { - - private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0"; - private static final QName EXPORT = new QName(SCA10_NS, "export"); - private static final String NAMESPACE = "namespace"; - - private final NamespaceImportExportFactory factory; - private final Monitor monitor; - - public NamespaceExportProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.factory = modelFactories.getFactory(NamespaceImportExportFactory.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 = monitor.createProblem(this.getClass().getName(), "contribution-namespace-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - public QName getArtifactType() { - return EXPORT; - } - - public Class getModelType() { - return NamespaceExport.class; - } - - /** - * Process - */ - public NamespaceExport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - NamespaceExport namespaceExport = this.factory.createNamespaceExport(); - QName element = null; - - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - element = reader.getName(); - - // Read - if (EXPORT.equals(element)) { - String ns = reader.getAttributeValue(null, NAMESPACE); - if (ns == null) { - error("AttributeNameSpaceMissing", reader); - //throw new ContributionReadException("Attribute 'namespace' is missing"); - } else - namespaceExport.setNamespace(ns); - } - - break; - case XMLStreamConstants.END_ELEMENT: - if (EXPORT.equals(reader.getName())) { - return namespaceExport; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return namespaceExport; - } - - public void write(NamespaceExport namespaceExport, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write - writer.writeStartElement(EXPORT.getNamespaceURI(), EXPORT.getLocalPart()); - - if (namespaceExport.getNamespace() != null) { - writer.writeAttribute(NAMESPACE, namespaceExport.getNamespace()); - } - - 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/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java b/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java deleted file mode 100644 index 1146e593a9..0000000000 --- a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.contribution.namespace.impl; - -import org.apache.tuscany.sca.contribution.namespace.NamespaceExport; -import org.apache.tuscany.sca.contribution.namespace.NamespaceImport; -import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory; - -/** - * Namespace Import/Export model factory implementation - * - * @version $Rev$ $Date$ - */ -public class NamespaceImportExportFactoryImpl implements NamespaceImportExportFactory { - - public NamespaceImport createNamespaceImport() { - return new NamespaceImportImpl(); - } - - public NamespaceExport createNamespaceExport() { - return new NamespaceExportImpl(); - } - -} diff --git a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java b/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java deleted file mode 100644 index 6d2a31f702..0000000000 --- a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.contribution.namespace.impl; - -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 NamespaceImportImpl implements NamespaceImport { - private ModelResolver modelResolver; - - /** - * The namespace to be imported - */ - 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; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getNamespace() { - return namespace; - } - - 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 - * import and export namespaces match - */ - public boolean match(Export export) { - if (export instanceof NamespaceExport) { - if (this.getNamespace().equals(((NamespaceExport)export).getNamespace())) { - return true; - } - } - return false; - } - - @Override - public String toString() { - return String.valueOf(namespace); - } -} diff --git a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java b/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java deleted file mode 100644 index e258dcf874..0000000000 --- a/branches/sca-equinox/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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.contribution.namespace.impl; - -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.contribution.namespace.NamespaceImport; -import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory; -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.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; - -/** - * Artifact processor for Namespace import - * - * @version $Rev$ $Date$ - */ -public class NamespaceImportProcessor implements StAXArtifactProcessor { - private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0"; - - private static final QName IMPORT = new QName(SCA10_NS, "import"); - - private static final String NAMESPACE = "namespace"; - private static final String LOCATION = "location"; - - private final NamespaceImportExportFactory factory; - private final Monitor monitor; - - public NamespaceImportProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.factory = modelFactories.getFactory(NamespaceImportExportFactory.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 = monitor.createProblem(this.getClass().getName(), "contribution-namespace-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - - public QName getArtifactType() { - return IMPORT; - } - - public Class getModelType() { - return NamespaceImport.class; - } - - /** - * Process - */ - public NamespaceImport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - NamespaceImport namespaceImport = this.factory.createNamespaceImport(); - QName element; - - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - element = reader.getName(); - - // Read - if (IMPORT.equals(element)) { - String ns = reader.getAttributeValue(null, NAMESPACE); - if (ns == null) { - error("AttributeNameSpaceMissing", reader); - //throw new ContributionReadException("Attribute 'namespace' is missing"); - } else - namespaceImport.setNamespace(ns); - - String location = reader.getAttributeValue(null, LOCATION); - if (location != null) { - namespaceImport.setLocation(location); - } - } - break; - case XMLStreamConstants.END_ELEMENT: - if (IMPORT.equals(reader.getName())) { - return namespaceImport; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return namespaceImport; - } - - public void write(NamespaceImport namespaceImport, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - // Write - writer.writeStartElement(IMPORT.getNamespaceURI(), IMPORT.getLocalPart()); - - if (namespaceImport.getNamespace() != null) { - writer.writeAttribute(NAMESPACE, namespaceImport.getNamespace()); - } - if (namespaceImport.getLocation() != null) { - writer.writeAttribute(LOCATION, namespaceImport.getLocation()); - } - - writer.writeEndElement(); - } - - - public void resolve(NamespaceImport model, ModelResolver resolver) throws ContributionResolveException { - } -} -- cgit v1.2.3