You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ad...@apache.org on 2008/04/14 10:13:50 UTC

svn commit: r647689 - in /incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded: SCADomain.java impl/DefaultSCADomain.java

Author: adrianocrestani
Date: Mon Apr 14 01:13:43 2008
New Revision: 647689

URL: http://svn.apache.org/viewvc?rev=647689&view=rev
Log:
-updating Android test files on the sandbox

Modified:
    incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java
    incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java

Modified: incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java?rev=647689&r1=647688&r2=647689&view=diff
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java (original)
+++ incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java Mon Apr 14 01:13:43 2008
@@ -30,8 +30,7 @@
 
 import org.apache.tuscany.sca.host.embedded.impl.ContextRegistry;
 import org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain;
-import org.apache.tuscany.sca.host.embedded.management.AndroidURLConnection;
-import org.apache.tuscany.sca.host.embedded.management.AndroidURLStreamHandlerFactory;
+import org.apache.tuscany.sca.host.embedded.management.DexURLStreamHandlerFactory;
 import org.apache.tuscany.sca.host.embedded.management.ComponentManager;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.ServiceReference;
@@ -55,7 +54,7 @@
     protected static SCADomain theDomain;
     
     static {
-    	URL.setURLStreamHandlerFactory(new AndroidURLStreamHandlerFactory());
+    	URL.setURLStreamHandlerFactory(new DexURLStreamHandlerFactory());
     }
     
     private Context context;
@@ -89,7 +88,7 @@
      * @return
      */
     public static SCADomain newInstance(Context context, String composite) {
-        return createNewInstance(context, LOCAL_DOMAIN_URI, "/", composite);
+        return createNewInstance(context, LOCAL_DOMAIN_URI, "dex:/" + context.getPackageName() + "/raw/", composite);
     }
     
     /**

Modified: incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java?rev=647689&r1=647688&r2=647689&view=diff
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java (original)
+++ incubator/tuscany/sandbox/mobile-android/host-android/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java Mon Apr 14 01:13:43 2008
@@ -19,12 +19,8 @@
 
 package org.apache.tuscany.sca.host.embedded.impl;
 
-import java.io.File;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -363,87 +359,31 @@
      */
     protected URL getContributionLocation(ClassLoader classLoader, String contributionPath, String[] composites)
         throws MalformedURLException {
-       /* if (contributionPath != null && contributionPath.length() > 0) {
-            //encode spaces as they would cause URISyntaxException
-            contributionPath = contributionPath.replace(" ", "%20");
-            URI contributionURI = URI.create(contributionPath);
-            if (contributionURI.isAbsolute() || composites.length == 0) {
-                return new URL(contributionPath);
-            }
-        }*/
-
-        String contributionArtifactPath = null;
-        URL contributionArtifactURL = null;
-        if (composites != null && composites.length > 0 && composites[0].length() > 0) {
-        	String packageName = getContext().getPackageName();
-
-            // Here the SCADomain was started with a reference to a composite file
-            contributionArtifactPath = composites[0];
-            int contributionId = getContext().getResources().getIdentifier(contributionArtifactPath, "raw", packageName);
-            
-            if (contributionId == 0) {
-                throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
-            }
-            
-            contributionArtifactURL = new URL("android", packageName, "raw/" + contributionArtifactPath);
-            
-        } /*else {
-
-            // Here the SCADomain was started without any reference to a composite file
-            // We are going to look for an sca-contribution.xml or sca-contribution-generated.xml
-
-            // Look for META-INF/sca-contribution.xml
-            contributionArtifactPath = Contribution.SCA_CONTRIBUTION_META;
-            contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
-
-            // Look for META-INF/sca-contribution-generated.xml
-            if (contributionArtifactURL == null) {
-                contributionArtifactPath = Contribution.SCA_CONTRIBUTION_GENERATED_META;
-                contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
-            }
-
-            // Look for META-INF/sca-deployables directory
-            if (contributionArtifactURL == null) {
-                contributionArtifactPath = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
-                contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
-            }
-        }*/
-
-        if (contributionArtifactURL == null) {
-            throw new IllegalArgumentException(
-                                               "Can't determine contribution deployables. Either specify a composite file, or use an sca-contribution.xml file to specify the deployables.");
-        }
-
-        //URL contributionURL = contributionArtifactURL;
-        // "jar:file://....../something.jar!/a/b/c/app.composite"
-        /*try {
-            String url = contributionArtifactURL.toExternalForm();
-            String protocol = contributionArtifactURL.getProtocol();
-            if ("file".equals(protocol)) {
-                // directory contribution
-                if (url.endsWith(contributionArtifactPath)) {
-                    String location = url.substring(0, url.lastIndexOf(contributionArtifactPath));
-                    // workaround from evil url/uri form maven
-                    contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
-                }
-
-            } else if ("jar".equals(protocol)) {
-                // jar contribution
-                String location = url.substring(4, url.lastIndexOf("!/"));
-                // workaround for evil url/uri from maven
-                contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
-                
-            } else if (protocol != null && (protocol.equals("bundle")||protocol.equals("bundleresource"))){
-                contributionURL = new URL(contributionArtifactURL.getProtocol(), 
-                                          contributionArtifactURL.getHost(), 
-                                          contributionArtifactURL.getPort(), 
-                                          "/");
-            }          
-        } catch (MalformedURLException mfe) {
-            throw new IllegalArgumentException(mfe);
-        }*/
-
-        return contributionArtifactURL;
+    
+        int colonIndex = contributionPath.indexOf(':');
+        String protocol;
+        
+        if (colonIndex == -1) {
+        	throw new IllegalArgumentException("can't determine the protocol!");
+        	
+        } else {
+        	protocol = contributionPath.substring(0, colonIndex);
+        }
+        
+        int slashIndex = contributionPath.indexOf('/');
+        
+        if (slashIndex == -1 || slashIndex == contributionPath.length()) {
+        	throw new IllegalArgumentException("can't determine the host!");
+        }
+        
+        String host = contributionPath.substring(slashIndex + 1);
+        slashIndex = host.indexOf('/');
+        
+        if (slashIndex != -1) {
+        	host = host.substring(0, slashIndex);
+        }
+        
+        return new URL(protocol, host, "");
         
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org