You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by mc...@apache.org on 2008/02/04 03:32:47 UTC

svn commit: r618156 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/ org.apache.geronimo.st.ui/src/org/apache/geroni...

Author: mcconne
Date: Sun Feb  3 18:32:46 2008
New Revision: 618156

URL: http://svn.apache.org/viewvc?rev=618156&view=rev
Log:
GERONIMODEVTOOLS-264 Backend support for classpath containers

Added:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ClasspathContainersHelper.java
Removed:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/util/
Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Trace.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ClasspathContainersHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ClasspathContainersHelper.java?rev=618156&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ClasspathContainersHelper.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ClasspathContainersHelper.java Sun Feb  3 18:32:46 2008
@@ -0,0 +1,134 @@
+/*
+ * 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.geronimo.st.core;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ *
+ * Helper class for ClasspathContainers support
+ *
+ */
+public class ClasspathContainersHelper {
+
+    //
+    // Query the workspace for the list of classpath containers and return as a 
+    // sorted List<String> for display and for WTP to ultimately persist as server 
+    // instance properties in servers.xml
+    // 
+    public static List<String> queryWorkspace() {
+        Trace.tracePoint("ENTRY", "ClasspathContainersHelper.queryWorkspace");
+
+        ArrayList<String> containers = new ArrayList<String>();
+
+        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+
+        for ( IProject project : projects ) {
+
+            try {
+
+                if ( project.getNature(JavaCore.NATURE_ID) != null ) {
+
+                    IJavaProject javaProject = JavaCore.create(project);
+                    IClasspathEntry[] cp = javaProject.getRawClasspath();
+
+                    for ( IClasspathEntry cpEntry : cp ) {
+
+                        if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+                            addEntry( containers, cpEntry.getPath().toString());
+                        }
+                    }
+                }
+            }
+            catch ( CoreException e ) {
+                e.printStackTrace();
+            }
+        }
+
+        Collections.sort( containers );
+        Trace.tracePoint("EXIT", "ClasspathContainersHelper.queryWorkspace", containers);
+        return containers;
+    }
+
+
+    //
+    // Query the workspace to find the classapth entries for a specific classpath container,
+    // 
+    public static List<IClasspathEntry> queryWorkspace( String containerPath ) {
+        Trace.tracePoint("ENTRY", "ClasspathContainersHelper.queryWorkspace", containerPath );
+
+        List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
+
+        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+
+        for ( IProject project : projects ) {
+
+            try {
+
+                if ( project.getNature(JavaCore.NATURE_ID) !=null ) {
+
+                    IJavaProject javaProject = JavaCore.create(project);
+                    IClasspathEntry[] cp = javaProject.getRawClasspath();
+
+                    for ( IClasspathEntry cpEntry : cp ) {
+
+                        if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+
+                            if ( cpEntry.getPath().toString().equals( containerPath )) {
+
+                                IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(cpEntry.getPath(), javaProject);
+                                IClasspathEntry[] containerEntries = classpathContainer.getClasspathEntries();
+
+                                for (int ii = 0; ii  < containerEntries.length; ii++) {
+                                    classpathEntries.add(containerEntries[ii]);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            catch ( CoreException e ) {
+                e.printStackTrace();
+            }
+        }
+
+        Trace.tracePoint("EXIT", "ClasspathContainersHelper.queryWorkspace", classpathEntries);
+        return classpathEntries;
+    }
+
+
+    //
+    // Ensure no duplicates in the list
+    //
+    private static void addEntry( List<String> containers, String container ) {
+
+        if ( containers.indexOf( container ) < 0 ) {
+            containers.add( container );
+        }
+    }
+}
\ No newline at end of file

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java?rev=618156&r1=618155&r2=618156&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoRuntimeDelegate.java Sun Feb  3 18:32:46 2008
@@ -49,8 +49,6 @@
 
 	public static final String SERVER_INSTANCE_PROPERTIES = "geronimo_server_instance_properties";
 	
-	public static final String SERVER_CLASSPATH_CONTAINERS = "classpathContainers";
-	
 	public static final String RUNTIME_SOURCE= "runtime.source";
 
 	public static final int NO_IMAGE = 0;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java?rev=618156&r1=618155&r2=618156&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java Sun Feb  3 18:32:46 2008
@@ -41,6 +41,7 @@
 import org.apache.geronimo.st.core.operations.ISharedLibEntryCreationDataModelProperties;
 import org.apache.geronimo.st.core.operations.SharedLibEntryCreationOperation;
 import org.apache.geronimo.st.core.operations.SharedLibEntryDataModelProvider;
+import org.apache.geronimo.st.core.ClasspathContainersHelper;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -56,6 +57,10 @@
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.launching.RuntimeClasspathEntry;
 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
 import org.eclipse.jdt.launching.IVMInstall;
@@ -572,11 +577,31 @@
 		cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(serverJar));
 		// merge existing classpath with server classpath
 		IRuntimeClasspathEntry[] existingCps = JavaRuntime.computeUnresolvedRuntimeClasspath(wc);
+
 		for (int i = 0; i < existingCps.length; i++) {
+            Trace.trace(Trace.INFO, "cpentry: " + cp );
 			if (cp.contains(existingCps[i]) == false) {
 				cp.add(existingCps[i]);
 			}
 		}
+
+        //
+        // Add classpath entries from any selected classpath containers
+        //
+        if ( getGeronimoServer().isSelectClasspathContainers()) {
+            List<String> containers = getGeronimoServer().getClasspathContainers();
+            for ( String containerPath : containers ) {
+                List<IClasspathEntry> cpes = ClasspathContainersHelper.queryWorkspace( containerPath );
+                for ( IClasspathEntry cpe : cpes ) {
+                    RuntimeClasspathEntry rcpe = new RuntimeClasspathEntry( cpe );
+                    Trace.trace(Trace.INFO, "Classpath Container Entry: " + rcpe );
+                    if (cp.contains(rcpe) == false) {
+                        cp.add( rcpe );
+                    }
+                }
+            }
+        }
+
 		wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, convertCPEntryToMemento(cp));
 		wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
 	}

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Trace.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Trace.java?rev=618156&r1=618155&r2=618156&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Trace.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/internal/Trace.java Sun Feb  3 18:32:46 2008
@@ -79,4 +79,48 @@
 		if (t != null)
 			t.printStackTrace();
 	}
+
+    /**
+     * Trace the given message 
+     * 
+     * @param tracePoint
+     *            The trace point (e.g., "Exit", "Entry", "Constructor", etc....
+     *            
+     * @param classDotMethod
+     *            The class name + method name (e.g., "Class.method()")
+     *            
+     * @param parm1,2,3,4,5
+     *            Method parameters if the trace point is an "Entry"
+     *            or
+     *            Return value if the trace point is an "Exit"
+     */
+    public static void tracePoint(String tracePoint, String classDotMethod) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "()" );
+    }   
+    public static void tracePoint(String tracePoint, String classDotMethod, Object parm1) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "] )" );
+    }
+
+    public static void tracePoint(String tracePoint, String classDotMethod, Object parm1, Object parm2) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
+                                                                 "parm2=[" + (parm2 == null ? null : parm2.toString()) + "] )" );
+    }
+    public static void tracePoint(String tracePoint, String classDotMethod, Object parm1, Object parm2, Object parm3) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
+                                                                 "parm2=[" + (parm2 == null ? null : parm2.toString()) + "], " +
+                                                                 "parm3=[" + (parm3 == null ? null : parm3.toString()) + "] )" );
+    }
+    public static void tracePoint(String tracePoint, String classDotMethod, Object parm1, Object parm2, Object parm3, Object parm4) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
+                                                                 "parm2=[" + (parm2 == null ? null : parm2.toString()) + "], " +
+                                                                 "parm3=[" + (parm3 == null ? null : parm3.toString()) + "], " +
+                                                                 "parm4=[" + (parm4 == null ? null : parm4.toString()) + "] )" );
+    }
+    public static void tracePoint(String tracePoint, String classDotMethod, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5) {
+        trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
+                                                                 "parm2=[" + (parm2 == null ? null : parm2.toString()) + "], " +
+                                                                 "parm3=[" + (parm3 == null ? null : parm3.toString()) + "], " +
+                                                                 "parm4=[" + (parm4 == null ? null : parm4.toString()) + "], " +
+                                                                 "parm5=[" + (parm5 == null ? null : parm5.toString()) + "] )" );
+    }
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java?rev=618156&r1=618155&r2=618156&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/org/apache/geronimo/st/ui/sections/ServerEditorTestEnvSection.java Sun Feb  3 18:32:46 2008
@@ -17,6 +17,8 @@
 package org.apache.geronimo.st.ui.sections;
 
 import java.util.List;
+
+import org.apache.geronimo.st.core.ClasspathContainersHelper;
 import org.apache.geronimo.st.core.IGeronimoServer;
 import org.apache.geronimo.st.ui.commands.SetInPlaceSharedLibCommand;
 import org.apache.geronimo.st.ui.commands.SetRunFromWorkspaceCommand;
@@ -24,7 +26,6 @@
 import org.apache.geronimo.st.ui.commands.SetSelectClasspathContainersCommand;
 import org.apache.geronimo.st.ui.internal.Messages;
 import org.apache.geronimo.st.ui.internal.Trace;
-import org.apache.geronimo.st.ui.util.ClasspathContainersHelper;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.CheckboxTableViewer;
 import org.eclipse.jface.viewers.CheckStateChangedEvent;