diff options
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
|