You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/06/03 23:29:30 UTC

svn commit: r662896 - in /incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core: classpath/ launch/ log/ newwizards/

Author: jsdelfino
Date: Tue Jun  3 14:29:30 2008
New Revision: 662896

URL: http://svn.apache.org/viewvc?rev=662896&view=rev
Log:
Added some logging. Made the determination of the location of the runtime feature more reliable by using the Bundle API to find it.

Added:
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/log/
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/log/LogUtil.java
Modified:
    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/launch/TuscanyLaunchDomainManagerAction.java
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchNodeShortcut.java
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewComponentTypeWizardPage.java
    incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewCompositeWizardPage.java

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=662896&r1=662895&r2=662896&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 14:29:30 2008
@@ -19,12 +19,14 @@
 
 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.List;
 
-import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
@@ -44,11 +46,8 @@
     private static final String TUSCANY_HOME = "TUSCANY_HOME";
     private static final String TUSCANY_SRC = "TUSCANY_SRC";
     
-    private static final String TUSCANY_FEATURE = "features/org.apache.tuscany.sca.feature_1.2.0";
+    private static final String TUSCANY_FEATURE = "org.apache.tuscany.sca.feature";
     
-    private static final String TUSCANY_FEATURE_RUNTIME = TUSCANY_FEATURE + "/runtime"; 
-    private static final String TUSCANY_FEATURE_SRC = TUSCANY_FEATURE + "/src"; 
-
     public TuscanyClasspathContainer() {
     }
 
@@ -61,9 +60,8 @@
             
             // 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);
+            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()) {
@@ -79,9 +77,17 @@
                             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);
         }
 
         if (runtimePath == null) {
@@ -105,9 +111,8 @@
 
             // Find the Tuscany source distribution under the feature's src directory
             // Typically src/distro-archive-src.zip
-            URL url = FileLocator.toFileURL(Platform.getInstallLocation().getURL());
-            File file = new File(url.toURI());
-            file = new File(file, TUSCANY_FEATURE_SRC);
+            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()) {

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchDomainManagerAction.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchDomainManagerAction.java?rev=662896&r1=662895&r2=662896&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchDomainManagerAction.java (original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchDomainManagerAction.java Tue Jun  3 14:29:30 2008
@@ -1,13 +1,11 @@
 package org.apache.tuscany.sca.core.launch;
 
 import static org.apache.tuscany.sca.core.launch.DomainManagerLauncherUtil.launchDomainManager;
+import static org.apache.tuscany.sca.core.log.LogUtil.error;
 
 import java.lang.reflect.InvocationTargetException;
 
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.ISelection;
@@ -47,9 +45,7 @@
             });
 
         } catch (Exception e) {
-            Platform.getLog(
-                Platform.getBundle("org.apache.tuscany.sca.core")).log(
-                new Status(IStatus.ERROR, "org.apache.tuscany.sca.core", IStatus.OK, "Could not launch SCA Domain Manager", e));
+            error("Could not launch SCA Domain Manager", e);
         }
     }
 

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchNodeShortcut.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchNodeShortcut.java?rev=662896&r1=662895&r2=662896&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchNodeShortcut.java (original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/launch/TuscanyLaunchNodeShortcut.java Tue Jun  3 14:29:30 2008
@@ -20,14 +20,12 @@
 package org.apache.tuscany.sca.core.launch;
 
 import static org.apache.tuscany.sca.core.launch.NodeLauncherUtil.launchNode;
+import static org.apache.tuscany.sca.core.log.LogUtil.error;
 
 import java.lang.reflect.InvocationTargetException;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
 import org.eclipse.debug.ui.ILaunchShortcut;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.ISelection;
@@ -79,9 +77,7 @@
             });
 
         } catch (Exception e) {
-            Platform.getLog(
-                Platform.getBundle("org.apache.tuscany.sca.core")).log(
-                new Status(IStatus.ERROR, "org.apache.tuscany.sca.core", IStatus.OK, "Could not launch SCA composite", e));
+            error("Could not launch SCA composite", e);
         }
     }
 

Added: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/log/LogUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/log/LogUtil.java?rev=662896&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/log/LogUtil.java (added)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/log/LogUtil.java Tue Jun  3 14:29:30 2008
@@ -0,0 +1,39 @@
+/*
+ * 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.core.log;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * A log utility
+ *
+ * @version $Rev: $ $Date: $
+ */
+public class LogUtil {
+    
+    public static void error(String msg, Exception e) {
+        Platform.getLog(
+                        Platform.getBundle("org.apache.tuscany.sca.core")).log(
+                        new Status(IStatus.ERROR, "org.apache.tuscany.sca.core", IStatus.OK, msg, e));
+    }
+
+}

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewComponentTypeWizardPage.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewComponentTypeWizardPage.java?rev=662896&r1=662895&r2=662896&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewComponentTypeWizardPage.java (original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewComponentTypeWizardPage.java Tue Jun  3 14:29:30 2008
@@ -19,6 +19,8 @@
 
 package org.apache.tuscany.sca.core.newwizards;
 
+import static org.apache.tuscany.sca.core.log.LogUtil.error;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
@@ -26,9 +28,7 @@
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.graphics.ImageLoader;
@@ -59,9 +59,7 @@
                         String location = FileLocator.toFileURL(Platform.getBundle("org.apache.tuscany.sca.core").getEntry("/")).getFile().toString();
                         setImageDescriptor(ImageDescriptor.createFromImageData((new ImageLoader()).load(location + "/icons/tuscany.gif")[0]));
                 } catch (Exception e) {
-                    Platform.getLog(
-                                    Platform.getBundle("org.apache.tuscany.sca.core")).log(
-                                    new Status(IStatus.ERROR, "org.apache.tuscany.sca.core", IStatus.OK, "Could not create wizard", e));
+                    error("Could not create wizard", e);
                 }
                 
                 setFileName("sample.componentType");
@@ -76,10 +74,8 @@
                 IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
                 IDE.openEditor(workbenchPage, file, true);
                 } catch (Exception e) {
-                    Platform.getLog(
-                                    Platform.getBundle("org.apache.tuscany.sca.core")).log(
-                                    new Status(IStatus.ERROR, "org.apache.tuscany.sca.core", IStatus.OK, "Could not open editor", e));
-                        return false;
+                    error("Could not open editor", e);
+                    return false;
                 }
                 return true;
         }

Modified: incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewCompositeWizardPage.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewCompositeWizardPage.java?rev=662896&r1=662895&r2=662896&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewCompositeWizardPage.java (original)
+++ incubator/tuscany/java/sca/tools/eclipse/plugins/core/org/apache/tuscany/sca/core/newwizards/NewCompositeWizardPage.java Tue Jun  3 14:29:30 2008
@@ -19,6 +19,8 @@
 
 package org.apache.tuscany.sca.core.newwizards;
 
+import static org.apache.tuscany.sca.core.log.LogUtil.error;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
@@ -27,10 +29,8 @@
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.graphics.ImageLoader;
@@ -61,9 +61,7 @@
                         String location = FileLocator.toFileURL(Platform.getBundle("org.apache.tuscany.sca.core").getEntry("/")).getFile().toString();
                         setImageDescriptor(ImageDescriptor.createFromImageData((new ImageLoader()).load(location + "/icons/tuscany.gif")[0]));
                 } catch (Exception e) {
-                    Platform.getLog(
-                                    Platform.getBundle("org.apache.tuscany.sca.core")).log(
-                                    new Status(IStatus.ERROR, "org.apache.tuscany.sca.core", IStatus.OK, "Could not create wizard", e));
+                    error("Could not create wizard", e);
                 }
                 
                 setFileName("sample.composite");
@@ -78,9 +76,7 @@
                 IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
                 IDE.openEditor(workbenchPage, file, true);
                 } catch (Exception e) {
-                    Platform.getLog(
-                                    Platform.getBundle("org.apache.tuscany.sca.core")).log(
-                                    new Status(IStatus.ERROR, "org.apache.tuscany.sca.core", IStatus.OK, "Could not open editor", e));
+                    error("Could not open editor", e);
                         return false;
                 }
                 return true;