tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r1043310 - /tuscany/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java
Date Wed, 08 Dec 2010 05:47:21 GMT
Author: lresende
Date: Wed Dec  8 05:47:21 2010
New Revision: 1043310

URL: http://svn.apache.org/viewvc?rev=1043310&view=rev
Log:
Allowing more flexible resolution for the widget artifact

Modified:
    tuscany/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java

Modified: tuscany/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java?rev=1043310&r1=1043309&r2=1043310&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java
Wed Dec  8 05:47:21 2010
@@ -20,7 +20,11 @@ package org.apache.tuscany.sca.implement
 
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 
+import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 
 import javax.xml.namespace.QName;
@@ -61,7 +65,6 @@ public class WidgetImplementationProcess
         implementationFactory = modelFactories.getFactory(WidgetImplementationFactory.class);
     }
  
-
     public QName getArtifactType() {
         // Returns the QName of the XML element processed by this processor
         return WidgetImplementation.TYPE;
@@ -103,26 +106,48 @@ public class WidgetImplementationProcess
     public void resolve(WidgetImplementation implementation, ModelResolver resolver, ProcessorContext
context) throws ContributionResolveException {
 
     	if (implementation != null) {
-    		// Resolve the resource directory location
+    	    // Resolve the resource directory location
             Artifact artifact = contributionFactory.createArtifact();
             artifact.setURI(implementation.getLocation());
             Artifact resolved = resolver.resolveModel(Artifact.class, artifact, context);
-            if (resolved.getLocation() != null) {
-                try {
-                    implementation.setLocationURL(new URL(resolved.getLocation()));
-
-                    //introspect implementation
-                    WidgetImplementationIntrospector widgetIntrospector =
-                    	new WidgetImplementationIntrospector(registry, implementation);
-                    widgetIntrospector.introspectImplementation();
-
-                    implementation.setUnresolved(false);
-                } catch (IOException e) {
-                	ContributionResolveException ce = new ContributionResolveException(e);
-                	error(context.getMonitor(), "ContributionResolveException", resolver, ce);
-                    //throw ce;
+            
+            if(resolved.getLocation() == null) {
+                URL resource = null;
+                URI uri = URI.create(implementation.getLocation());
+                Artifact parent = context.getArtifact();
+                if (!uri.isAbsolute()) {
+                    if (parent != null && parent.getURI() != null) {
+                        URI base = URI.create("/" + parent.getURI());
+                        uri = base.resolve(uri);
+                        // Remove the leading / to make artifact resolver happy
+                        if (uri.toString().startsWith("/")) {
+                            uri = URI.create(uri.toString().substring(1));
+                        }
+                    }
                 }
-            } else {
+
+
+                // The resource can be out of scope of the contribution root
+                if (parent != null && parent.getLocation() != null) {
+                    try {
+                        resource = new URL(new URL(parent.getLocation()), implementation.getLocation());
+
+                        implementation.setLocationURL(resource);
+
+                        //introspect implementation
+                        WidgetImplementationIntrospector widgetIntrospector =
+                            new WidgetImplementationIntrospector(registry, implementation);
+                        widgetIntrospector.introspectImplementation();
+
+                        implementation.setUnresolved(false);
+                    } catch (MalformedURLException e) {
+                        ContributionResolveException ce = new ContributionResolveException(e);
+                        error(context.getMonitor(), "ContributionResolveException", resolver,
ce);
+                    }
+                }
+            }
+            
+            if (implementation.isUnresolved()) {
                 error(context.getMonitor(), "CouldNotResolveLocation", resolver, implementation.getLocation());
                 //throw new ContributionResolveException("Could not resolve implementation.widget
location: " + implementation.getLocation());
             }



Mime
View raw message