tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r662938 - in /incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core: classpath/ launch/
Date Wed, 04 Jun 2008 01:24:31 GMT
Author: jsdelfino
Date: Tue Jun  3 18:24:31 2008
New Revision: 662938

URL: http://svn.apache.org/viewvc?rev=662938&view=rev
Log:
Fixed determination of Tuscany feature location.

Modified:
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/ClasspathUtil.java
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyClasspathContainer.java
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyRuntimeClasspathContainer.java
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/DomainManagerLauncherUtil.java
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/NodeLauncherUtil.java

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/ClasspathUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/ClasspathUtil.java?rev=662938&r1=662937&r2=662938&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/ClasspathUtil.java
(original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/ClasspathUtil.java
Tue Jun  3 18:24:31 2008
@@ -19,6 +19,11 @@
 
 package org.apache.tuscany.sca.core.classpath;
 
+import static org.apache.tuscany.sca.core.log.LogUtil.error;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -26,12 +31,14 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
 
 /**
- * Utility functions handling the runtime classpath.
+ * Utility functions to help determine the runtime classpath.
  *
  * @version $Rev: $ $Date: $
  */
@@ -39,6 +46,9 @@
 
     private static final String TUSCANY_RUNTIME_LIBRARIES = "org.apache.tuscany.sca.core.runtimeLibraries";
 
+    private static final String TUSCANY_FEATURE = "org.apache.tuscany.sca.feature";
+    private static final String TUSCANY_VERSION = "1.2.0";
+    
     /**
      * Return the installed runtime classpath entries.
      * 
@@ -68,4 +78,93 @@
         return classpath.toString();
     }
 
+    /**
+     * Returns the Tuscany feature location.
+     *  
+     * @return
+     */
+    static IPath feature() {
+        try {
+            URL location = Platform.getInstallLocation().getURL();
+            File feature = new File(location.getPath() + "/features/" + TUSCANY_FEATURE +
"_" + TUSCANY_VERSION);
+            return new Path(feature.getPath());
+        } catch (Exception e) {
+            error("Tuscany runtime feature not found", e);
+            return null;
+        }
+    }
+
+    /**
+     * Returns the location of the runtime distribution under the Tuscany feature.
+     * 
+     * @param feature
+     * @return
+     */
+    static IPath runtime(IPath feature) {
+        IPath runtimePath = null;
+        try {
+            
+            // Find the Tuscany distribution under the feature's runtime directory
+            // Typically runtime/distro-archive-name/un-archived-distro-dir
+            File file = new File(feature.toFile(), "runtime");
+            if (file.exists()) {
+                File distro = null;
+                for (File f: file.listFiles()) {
+                    if (f.getName().contains("tuscany-sca")) {
+                        distro = f;
+                        break;
+                    }
+                }
+                if (distro != null) {
+                    for (File f: distro.listFiles()) {
+                        if (f.getName().contains("tuscany-sca")) {
+                            runtimePath = new Path(f.getPath());
+                            break;
+                        }
+                    }
+                    if (runtimePath == null) {
+                        error("Tuscany runtime distribution directory not found", new FileNotFoundException(distro.getAbsolutePath()));
+                    }
+                } else {
+                    error("Tuscany runtime distribution archive not found", new FileNotFoundException(file.getAbsolutePath()));
+                }
+            } else {
+                error("Tuscany runtime feature not found", new FileNotFoundException(file.getAbsolutePath()));
+            }
+        } catch (Exception e) {
+            error("Tuscany runtime feature not found", e);
+        }
+        return runtimePath;
+    }
+
+    /**
+     * Returns the location of the src distribution under the Tuscany feature.
+     * 
+     * @param feature
+     * @return
+     */
+    static IPath src(IPath feature) {
+        IPath sourcePath = null;
+        try {
+
+            // Find the Tuscany source distribution under the feature's src directory
+            // Typically src/distro-archive-src.zip
+            File file = new File(feature.toFile(), "src");
+            if (file.exists()) {
+                File distro = null;
+                for (File f: file.listFiles()) {
+                    if (f.getName().contains("tuscany-sca") && f.getName().endsWith("-src.zip"))
{
+                        distro = f;
+                        break;
+                    }
+                }
+                if (distro != null) {
+                    sourcePath = new Path(distro.getPath());
+                }
+            }
+        } catch (Exception e) {
+        }
+        return sourcePath;
+    }
+    
 }

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyClasspathContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyClasspathContainer.java?rev=662938&r1=662937&r2=662938&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyClasspathContainer.java
(original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyClasspathContainer.java
Tue Jun  3 18:24:31 2008
@@ -19,17 +19,16 @@
 
 package org.apache.tuscany.sca.core.classpath;
 
-import static org.apache.tuscany.sca.core.log.LogUtil.error;
+import static org.apache.tuscany.sca.core.classpath.ClasspathUtil.feature;
+import static org.apache.tuscany.sca.core.classpath.ClasspathUtil.runtime;
+import static org.apache.tuscany.sca.core.classpath.ClasspathUtil.src;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.JavaCore;
@@ -46,49 +45,17 @@
     private static final String TUSCANY_HOME = "TUSCANY_HOME";
     private static final String TUSCANY_SRC = "TUSCANY_SRC";
     
-    private static final String TUSCANY_FEATURE = "org.apache.tuscany.sca.feature";
-    
     public TuscanyClasspathContainer() {
     }
 
     public IClasspathEntry[] getClasspathEntries() {
         List<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
         
+        // Find the Tuscany feature
+        IPath feature = feature();
+        
         // Get the runtime location from the installed Tuscany feature
-        IPath runtimePath = null;
-        try {
-            
-            // Find the Tuscany distribution under the feature's runtime directory
-            // Typically runtime/distro-archive-name/un-archived-distro-dir
-            URL url = Platform.getBundle(TUSCANY_FEATURE).getResource("runtime");
-            File file = new File(url.getPath());
-            if (file.exists()) {
-                File distro = null;
-                for (File f: file.listFiles()) {
-                    if (f.getName().contains("tuscany-sca")) {
-                        distro = f;
-                        break;
-                    }
-                }
-                if (distro != null) {
-                    for (File f: distro.listFiles()) {
-                        if (f.getName().contains("tuscany-sca")) {
-                            runtimePath = new Path(f.getPath());
-                            break;
-                        }
-                    }
-                    if (runtimePath == null) {
-                        error("Tuscany runtime distribution directory not found", new FileNotFoundException(distro.getAbsolutePath()));
-                    }
-                } else {
-                    error("Tuscany runtime distribution archive not found", new FileNotFoundException(file.getAbsolutePath()));
-                }
-            } else {
-                error("Tuscany runtime feature not found", new FileNotFoundException(file.getAbsolutePath()));
-            }
-        } catch (Exception e) {
-            error("Tuscany runtime feature not found", e);
-        }
+        IPath runtimePath = runtime(feature);
 
         if (runtimePath == null) {
 
@@ -106,27 +73,7 @@
         }
         
         // Get the source location from the installed Tuscany feature
-        IPath sourcePath = null;
-        try {
-
-            // Find the Tuscany source distribution under the feature's src directory
-            // Typically src/distro-archive-src.zip
-            URL url = Platform.getBundle(TUSCANY_FEATURE).getResource("src");
-            File file = new File(url.getPath());
-            if (file.exists()) {
-                File distro = null;
-                for (File f: file.listFiles()) {
-                    if (f.getName().contains("tuscany-sca") && f.getName().endsWith("-src.zip"))
{
-                        distro = f;
-                        break;
-                    }
-                }
-                if (distro != null) {
-                    sourcePath = new Path(distro.getPath());
-                }
-            }
-        } catch (Exception e) {
-        }
+        IPath sourcePath = src(feature);
 
         if (sourcePath == null) {
             

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyRuntimeClasspathContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyRuntimeClasspathContainer.java?rev=662938&r1=662937&r2=662938&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyRuntimeClasspathContainer.java
(original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/classpath/TuscanyRuntimeClasspathContainer.java
Tue Jun  3 18:24:31 2008
@@ -19,13 +19,13 @@
 
 package org.apache.tuscany.sca.core.classpath;
 
+import static org.apache.tuscany.sca.core.classpath.ClasspathUtil.feature;
+import static org.apache.tuscany.sca.core.classpath.ClasspathUtil.runtime;
+
 import java.io.File;
-import java.net.URL;
 
-import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.JavaCore;
@@ -41,43 +41,16 @@
     
     private static final String TUSCANY_HOME = "TUSCANY_HOME";
     
-    private static final String TUSCANY_FEATURE = "features/org.apache.tuscany.sca.feature_1.2.0";
-    
-    private static final String TUSCANY_FEATURE_RUNTIME = TUSCANY_FEATURE + "/runtime"; 
-
     public TuscanyRuntimeClasspathContainer() {
     }
 
     public IClasspathEntry[] getClasspathEntries() {
         
+        // Find the Tuscany feature
+        IPath feature = feature();
+        
         // Get the runtime location from the installed Tuscany feature
-        IPath runtimePath = null;
-        try {
-            
-            // Find the Tuscany distribution under the feature's runtime directory
-            // Typically runtime/distro-archive-name/un-archived-distro-dir
-            URL url = FileLocator.toFileURL(Platform.getInstallLocation().getURL());
-            File file = new File(url.toURI());
-            file = new File(file, TUSCANY_FEATURE_RUNTIME);
-            if (file.exists()) {
-                File distro = null;
-                for (File f: file.listFiles()) {
-                    if (f.getName().contains("tuscany-sca")) {
-                        distro = f;
-                        break;
-                    }
-                }
-                if (distro != null) {
-                    for (File f: distro.listFiles()) {
-                        if (f.getName().contains("tuscany-sca")) {
-                            runtimePath = new Path(f.getPath());
-                            break;
-                        }
-                    }
-                }
-            }
-        } catch (Exception e) {
-        }
+        IPath runtimePath = runtime(feature);
 
         if (runtimePath == null) {
 

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/DomainManagerLauncherUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/DomainManagerLauncherUtil.java?rev=662938&r1=662937&r2=662938&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/DomainManagerLauncherUtil.java
(original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/DomainManagerLauncherUtil.java
Tue Jun  3 18:24:31 2008
@@ -204,7 +204,7 @@
                 newConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
domainProject.getLocation().toString());
                 
                 // Pass the runtime classpath as a system property
-                newConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
"-DTUSCANY_PATH=" + ClasspathUtil.installedRuntimeClasspath());
+                newConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
"\"-DTUSCANY_PATH=" + ClasspathUtil.installedRuntimeClasspath() + "\"");
 
                 // Save the configuration
                 newConfiguration.doSave();

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/NodeLauncherUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/NodeLauncherUtil.java?rev=662938&r1=662937&r2=662938&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/NodeLauncherUtil.java
(original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/NodeLauncherUtil.java
Tue Jun  3 18:24:31 2008
@@ -41,7 +41,6 @@
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.internal.core.LaunchManager;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
@@ -131,7 +130,7 @@
             newConfiguration.setAttribute("COMPOSITE_PATH", file.getFullPath().toString());
 
             // Pass the runtime classpath as a system property
-            newConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
"-DTUSCANY_PATH=" + ClasspathUtil.installedRuntimeClasspath());
+            newConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
"\"-DTUSCANY_PATH=" + ClasspathUtil.installedRuntimeClasspath() + "\"");
 
             // Save the configuration
             newConfiguration.doSave();



Mime
View raw message