Author: edwardsmj
Date: Fri May  8 12:01:56 2009
New Revision: 772949

URL: http://svn.apache.org/viewvc?rev=772949&view=rev
Log:
Updates and additions to add preResolve phase to contribution processing (See 
TUSCANY-3012)

Added:
    
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java
    
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java
Modified:
    
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java

Modified: 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java?rev=772949&r1=772948&r2=772949&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
 (original)
+++ 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
 Fri May  8 12:01:56 2009
@@ -119,7 +119,8 @@
         }
     }
 
-    @Override
+    @SuppressWarnings("unchecked")
+       @Override
     public <T> URLArtifactProcessor<T> getProcessor(Class<T> modelType) {
         loadProcessors();
         return (URLArtifactProcessor<T>)super.getProcessor(modelType);
@@ -145,7 +146,8 @@
         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 @@
             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 @@
      * 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 @@
         @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

Added: 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java?rev=772949&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java
 (added)
+++ 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java
 Fri May  8 12:01:56 2009
@@ -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

Added: 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java?rev=772949&view=auto
==============================================================================
--- 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java
 (added)
+++ 
tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java
 Fri May  8 12:01:56 2009
@@ -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


Reply via email to