diff options
author | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-08 12:01:56 +0000 |
---|---|---|
committer | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-08 12:01:56 +0000 |
commit | 35b26fdd32a8ba41e266d3e7c88626fedc32fe34 (patch) | |
tree | f23a9790abf675b4460f8a6ed1c48d83377e1a85 /java | |
parent | e75e43e1d9e241ddd6eda60f05b1abd2b5068b49 (diff) |
Updates and additions to add preResolve phase to contribution processing (See TUSCANY-3012)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@772949 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
3 files changed, 92 insertions, 8 deletions
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java index f318525bce..d3dbc66609 100644 --- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java +++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java @@ -119,7 +119,8 @@ public class DefaultURLArtifactProcessorExtensionPoint extends } } - @Override + @SuppressWarnings("unchecked") + @Override public <T> URLArtifactProcessor<T> getProcessor(Class<T> modelType) { loadProcessors(); return (URLArtifactProcessor<T>)super.getProcessor(modelType); @@ -145,7 +146,8 @@ public class DefaultURLArtifactProcessorExtensionPoint extends return processors; } - public URLArtifactProcessor<?> getProcessor(Object artifactType) { + @SuppressWarnings("unchecked") + public URLArtifactProcessor<?> getProcessor(Object artifactType) { Collection<URLArtifactProcessor<?>> processors = getProcessors(artifactType); return processors.isEmpty() ? null : processors.iterator().next(); } @@ -242,7 +244,7 @@ public class DefaultURLArtifactProcessorExtensionPoint extends String modelTypeName = attributes.get("model"); // Create a processor wrapper and register it - URLArtifactProcessor processor = + URLArtifactProcessor<?> processor = new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, extensionPoints, staxProcessor, monitor); addArtifactProcessor(processor); @@ -255,13 +257,13 @@ public class DefaultURLArtifactProcessorExtensionPoint extends * A wrapper around an Artifact processor class allowing lazy loading and * initialization of artifact processors. */ - private static class LazyURLArtifactProcessor implements URLArtifactProcessor { + private static class LazyURLArtifactProcessor implements ExtendedURLArtifactProcessor { private ExtensionPointRegistry extensionPoints; private String artifactType; private String modelTypeName; private ServiceDeclaration processorDeclaration; - private URLArtifactProcessor processor; + private URLArtifactProcessor<?> processor; private Class<?> modelType; private StAXArtifactProcessor<?> staxProcessor; private Monitor monitor; @@ -353,7 +355,18 @@ public class DefaultURLArtifactProcessorExtensionPoint extends @SuppressWarnings("unchecked") public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException { getProcessor().resolve(model, resolver); - } + } // end method resolve + + /** + * Preresolve phase, for ExtendedURLArtifactProcessors only + */ + @SuppressWarnings("unchecked") + public void preResolve( Object model, ModelResolver resolver ) throws ContributionResolveException { + URLArtifactProcessor<?> processor = getProcessor(); + if( processor instanceof ExtendedURLArtifactProcessor ) { + ((ExtendedURLArtifactProcessor)processor).preResolve(model, resolver); + } // end if + } // end method resolve - } -} + } // end class LazyURLArtifactProcessor +} // end class DefaultURLArtifactProcessorExtensionPoint diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java new file mode 100644 index 0000000000..ba8844b41a --- /dev/null +++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java @@ -0,0 +1,41 @@ +/*
+ * 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.processor;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * Interface for extended Artifact Processors which require a pre-resolve phase prior to the resolve phase
+ *
+ * @version $Rev: 704156 $ $Date: 2008-10-13 17:31:59 +0100 (Mon, 13 Oct 2008) $
+ */
+public interface ExtendedArtifactProcessor<M> extends ArtifactProcessor<M> {
+
+ /**
+ * Pre-resolve references from this model to other models. Used for models where initial setup of
+ * the resolve phase is required. An example is Contribution models with imports and exports which must
+ * be set up prior to the main resolve phase
+ *
+ * @param model The model to resolve
+ * @param resolver The resolver to use to resolve referenced models
+ */
+ void preResolve(M model, ModelResolver resolver) throws ContributionResolveException;
+
+} // end interface
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java new file mode 100644 index 0000000000..872b9804ce --- /dev/null +++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java @@ -0,0 +1,30 @@ +/*
+ * 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.processor;
+
+
+/**
+ * An extended artifact processor that can read models from a URL.
+ *
+ * @version $Rev: 704156 $ $Date: 2008-10-13 17:31:59 +0100 (Mon, 13 Oct 2008) $
+ */
+public interface ExtendedURLArtifactProcessor<M> extends ExtendedArtifactProcessor<M>, URLArtifactProcessor<M> {
+
+} // end interface
|