geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcco...@apache.org
Subject svn commit: r939145 [3/7] - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core: ./ META-INF/ src/main/java/org/apache/geronimo/st/v30/core/ src/main/java/org/apache/geronimo/st/v30/core/commands/ src/main/java/org/apache...
Date Thu, 29 Apr 2010 00:45:15 GMT
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,995 @@
+/*
+ * 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.v30.core;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.geronimo.st.v30.core.commands.DeploymentCmdStatus;
+import org.apache.geronimo.st.v30.core.commands.DeploymentCommandFactory;
+import org.apache.geronimo.st.v30.core.commands.IDeploymentCommand;
+import org.apache.geronimo.st.v30.core.internal.Messages;
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.apache.geronimo.st.v30.core.operations.ISharedLibEntryCreationDataModelProperties;
+import org.apache.geronimo.st.v30.core.operations.SharedLibEntryCreationOperation;
+import org.apache.geronimo.st.v30.core.operations.SharedLibEntryDataModelProvider;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.core.IClasspathEntry;
+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;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerEvent;
+import org.eclipse.wst.server.core.ServerPort;
+import org.eclipse.wst.server.core.internal.ProgressUtil;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+import org.eclipse.wst.server.core.util.SocketUtil;
+
+/**
+ * @version $Rev$ $Date$
+ */
+abstract public class GeronimoServerBehaviourDelegate extends ServerBehaviourDelegate implements IGeronimoServerBehavior {
+
+    public static final int TIMER_TASK_INTERVAL = 20;
+    
+    public static final int TIMER_TASK_DELAY = 20;
+
+    protected IProgressMonitor _monitor;
+
+    protected Timer timer = null;
+
+    protected PingThread pingThread;
+
+    protected transient IProcess process;
+
+    protected transient IDebugEventSetListener processListener;
+
+    public static final String ERROR_SETUP_LAUNCH_CONFIGURATION = "errorInSetupLaunchConfiguration";
+
+    abstract protected ClassLoader getContextClassLoader();
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#setupLaunchConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy,
+     *      org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy wc, IProgressMonitor monitor) throws CoreException {
+        if (isRemote())// No launch for remote servers.
+            return;
+
+        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, getRuntimeClass());
+
+        GeronimoRuntimeDelegate runtime = getRuntimeDelegate();
+
+        IVMInstall vmInstall = runtime.getVMInstall();
+        if (vmInstall != null)
+            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
+
+        String existingProgArgs = null;
+        wc.setAttribute(ERROR_SETUP_LAUNCH_CONFIGURATION, (String)null);
+        
+        try{
+            setupLaunchClasspath(wc, vmInstall);
+            existingProgArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
+        }catch (CoreException e){
+            // Throwing a CoreException at this time will not accomplish anything useful as WTP will 
+            // will essentially ignore it. Instead set a flag in the configuration that can 
+            // subsequently be checked when an attempt is made to launch the server in 
+            // GeronimoLaunchConfigurationDelegate.launch(). At that point a CoreException will be
+            // thrown that WTP will handle properly and will display an error dialog which is 
+            // exactly what we want the GEP user to see.
+            wc.setAttribute(ERROR_SETUP_LAUNCH_CONFIGURATION, e.getMessage());
+        }
+        String serverProgArgs = getServerDelegate().getConsoleLogLevel();
+        if (existingProgArgs == null || existingProgArgs.indexOf(serverProgArgs) < 0) {
+            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, serverProgArgs);
+        }
+        
+        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, getServerDelegate().getVMArgs());
+    }
+
+
+    /**
+     * @param launch
+     * @param launchMode
+     * @param monitor
+     * @throws CoreException
+     */
+    synchronized protected void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.setupLaunch", launch, launchMode, monitor); 
+
+        if (!SocketUtil.isLocalhost(getServer().getHost()))
+            return;
+
+        ServerPort[] ports = getServer().getServerPorts(null);
+        for (int i = 0; i < ports.length; i++) {
+            ServerPort sp = ports[i];
+            if (SocketUtil.isPortInUse(ports[i].getPort(), 5))
+                throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.bind(Messages.errorPortInUse, Integer.toString(sp.getPort()), sp.getName()), null));
+        }
+
+        stopUpdateServerStateTask();
+        setServerState(IServer.STATE_STARTING);
+        setMode(launchMode);
+
+        IServerListener listener = new IServerListener() {
+            public void serverChanged(ServerEvent event) {
+                int eventKind = event.getKind();
+                if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
+                    int state = event.getServer().getServerState();
+                    if (state == IServer.STATE_STARTED
+                            || state == IServer.STATE_STOPPED) {
+                        GeronimoServerBehaviourDelegate.this.getServer().removeServerListener(this);
+                        startUpdateServerStateTask();
+                    }
+                }
+            }
+        };
+
+        getServer().addServerListener(listener);
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.setupLaunch");
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#stop(boolean)
+     */
+    synchronized public void stop(final boolean force) {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.stop", force);
+
+        stopPingThread();
+        if (getServer().getServerState() != IServer.STATE_STOPPED) {
+            setServerState(IServer.STATE_STOPPING);
+            stopKernel();
+        }
+        GeronimoConnectionFactory.getInstance().destroy(getServer());
+        if (force) {
+            terminate();
+            return;
+        }
+        int state = getServer().getServerState();
+        if (state == IServer.STATE_STOPPED)
+            return;
+        if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING)
+            terminate();
+                                                   
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.stop");
+    }
+
+    /* 
+     * Override this method to be able to process in-place shared lib entries and restart the shared lib configuration for all projects prior
+     * to publishing each IModule.
+     * 
+     * This overridden method also fixes WTP Bugzilla 123676 to prevent duplicate repdeloys if both parent and child modules have deltas.
+     * 
+     * (non-Javadoc)
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#publishModules(int, java.util.List, java.util.List, org.eclipse.core.runtime.MultiStatus, org.eclipse.core.runtime.IProgressMonitor)
+     */
+    protected void publishModules(int kind, List modules, List deltaKind, MultiStatus multi, IProgressMonitor monitor) {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.publishModules", deltaKindToString(kind), Arrays.asList(modules).toString(), Arrays.asList(deltaKind).toString(), multi, monitor);
+
+        // 
+        // WTP publishes modules in reverse alphabetical order which does not account for possible 
+        // dependencies between modules. If necessary reorder the publish order of the modules 
+        // based on any discovered dependencies. 
+        //
+        if (modules != null && modules.size() > 0) {
+            List list = getOrderedModules(this.getServer(),modules, deltaKind);
+            modules = (List) list.get(0);
+            deltaKind = (List) list.get(1);
+        }
+
+        IStatus status = Status.OK_STATUS;
+        if (modules != null && modules.size() > 0 && getGeronimoServer().isInPlaceSharedLib()) {
+            List rootModules = new ArrayList<IModule>();
+            for(int i = 0; i < modules.size(); i++) {
+                IModule[] module = (IModule[]) modules.get(i);
+                if(!rootModules.contains(module[0])) {
+                    rootModules.add(module[0]);
+                }
+            }
+            IModule[] toProcess = (IModule[])rootModules.toArray(new IModule[rootModules.size()]);
+            status = updateSharedLib(toProcess, ProgressUtil.getSubMonitorFor(monitor, 1000));
+        }
+        if(status.isOK()) {
+            if (modules == null)
+                return;
+            
+            int size = modules.size();
+            if (size == 0)
+                return;
+            
+            if (monitor.isCanceled())
+                return;
+            
+            List rootModulesPublished = new ArrayList<IModule>();
+            for (int i = 0; i < size; i++) {
+                IModule[] module = (IModule[]) modules.get(i);
+                int moduleDeltaKind = ((Integer)deltaKind.get(i)).intValue();
+                //has the root of this module been published already?
+                if(!rootModulesPublished.contains(module[0])) {
+                    status = publishModule(kind, module, moduleDeltaKind, ProgressUtil.getSubMonitorFor(monitor, 3000));
+                    if (status != null && !status.isOK())
+                        multi.add(status);
+                    //cache published root modules to compare against to prevent dup redeploys
+                    if(moduleDeltaKind != NO_CHANGE) {
+                        rootModulesPublished.add(module[0]);
+                    }
+                } else {
+                    setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
+                    Trace.trace(Trace.INFO, "root module for " + Arrays.asList(module).toString() + " already published.  Skipping.");
+                }   
+            }
+        } else {
+            multi.add(status);
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.publishModules");
+    }
+
+    /*
+     * This method is used to invoke DependencyHelper of different version
+     */
+    abstract protected List getOrderedModules(IServer server, List modules, List deltaKind);
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#publishModule(int,
+     *      int, org.eclipse.wst.server.core.IModule[],
+     *      org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor) throws CoreException {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.publishModule", deltaKindToString(kind), deltaKindToString(deltaKind), Arrays.asList(module).toString(), monitor);
+
+        _monitor = monitor;
+
+        setModuleStatus(module, null);
+        setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
+        try {
+            //NO_CHANGE need if app is associated but not started and no delta
+            if (deltaKind == NO_CHANGE && module.length == 1) {
+                invokeCommand(deltaKind, module[0]);
+            }
+            else if (deltaKind == CHANGED || deltaKind == ADDED || deltaKind == REMOVED) {
+                invokeCommand(deltaKind, module[0]);
+            }
+        }
+        catch (CoreException e) {
+            //
+            // Set the module publish state to UNKNOWN so that WTP will display "Republish" instead
+            // "Synchronized" for the server state, and set the module status to an error message 
+            // for the GEP end-user to see. 
+            //
+            setModuleStatus(module, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error publishing module to server"));
+            setModulePublishState(module, IServer.PUBLISH_STATE_UNKNOWN);
+            throw e;
+        }
+
+    //  Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.publishModule");
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#publishFinish(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void publishFinish(IProgressMonitor monitor) throws CoreException {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.publishFinish", monitor);
+
+        IModule[] modules = this.getServer().getModules();
+        boolean allpublished = true;
+        for (int i = 0; i < modules.length; i++) {
+            if (this.getServer().getModulePublishState(new IModule[] { modules[i] }) != IServer.PUBLISH_STATE_NONE)
+                allpublished = false;
+        }
+        if (allpublished)
+            setServerPublishState(IServer.PUBLISH_STATE_NONE);
+
+        GeronimoConnectionFactory.getInstance().destroy(getServer());
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.publishFinish");
+    }
+
+
+    /**
+     * Initializes the Geronimo server delegate. This method is called by the server core framework 
+     * to give delegates a chance to do their own initialization. As such, the GEP proper should 
+     * never call this method.
+     * 
+     * @param monitor a progress monitor, or <code>null</code> if progress reporting and cancellation 
+     * are not desired
+     */
+    protected void initialize(IProgressMonitor monitor) {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.initialize", monitor);
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.initialize");
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#dispose()
+     */
+    public void dispose() {
+        stopUpdateServerStateTask();
+    }
+
+    public abstract String getRuntimeClass();
+
+    public void setServerStarted() {
+        setServerState(IServer.STATE_STARTED);
+    }
+
+    public void setServerStopped() {
+        setServerState(IServer.STATE_STOPPED);
+    }
+
+    public IGeronimoServer getGeronimoServer() {
+        return (IGeronimoServer) getServer().loadAdapter(IGeronimoServer.class, null);
+    }
+
+
+    protected void terminate() {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.terminate");
+
+        if (getServer().getServerState() == IServer.STATE_STOPPED)
+            return;
+
+        try {
+            setServerState(IServer.STATE_STOPPING);
+            Trace.trace(Trace.INFO, "Killing the geronimo server process"); //$NON-NLS-1$
+            if (process != null && !process.isTerminated()) {
+                process.terminate();
+
+            }
+            stopImpl();
+        } catch (Exception e) {
+            Trace.trace(Trace.SEVERE, "Error killing the geronimo server process", e); //$NON-NLS-1$
+            // 
+            // WTP does not allow a CoreException to be thrown in this case 
+            // 
+            throw new RuntimeException(Messages.STOP_FAIL);
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.terminate");
+    }
+
+
+    protected void stopImpl() {
+        if (process != null) {
+            process = null;
+            DebugPlugin.getDefault().removeDebugEventListener(processListener);
+            processListener = null;
+        }
+        setServerState(IServer.STATE_STOPPED);
+    }
+
+    protected void invokeCommand(int deltaKind, IModule module) throws CoreException {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.invokeCommand", deltaKindToString(deltaKind), module.getName());
+        
+        ClassLoader old = Thread.currentThread().getContextClassLoader();
+        try {
+            ClassLoader cl = getContextClassLoader();
+            if (cl != null)
+                Thread.currentThread().setContextClassLoader(cl);
+            switch (deltaKind) {
+            case ADDED: {
+                doAdded(module, null);
+                break;
+            }
+            case CHANGED: {
+                doChanged(module, null);
+                break;
+            }
+            case REMOVED: {
+                doRemoved(module);
+                break;
+            }
+            case NO_CHANGE: {
+                doNoChange(module);
+                break;
+            }
+            default:
+                throw new IllegalArgumentException();
+            }
+        } catch (CoreException e) {
+            throw e;
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            Thread.currentThread().setContextClassLoader(old);
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.invokeCommand");
+    }   
+
+    /**
+     * @param module
+     * @param configId the forced configId to process this method, passed in when this method is invoked from doChanged()
+     * @throws Exception
+     */
+    protected void doAdded(IModule module, String configId) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.doAdded", module.getName(), configId);
+        
+        configId = getLastKnowConfigurationId(module, configId);
+        if (configId == null) {
+            IStatus status = distribute(module);
+            if (!status.isOK()) {
+                doFail(status, Messages.DISTRIBUTE_FAIL);
+            }
+
+            TargetModuleID[] ids = updateServerModuleConfigIDMap(module, status);
+
+            status = start(ids);
+            if (!status.isOK()) {
+                doFail(status, Messages.START_FAIL);
+            }
+        } else {
+            //either (1) a configuration with the same module id exists already on the server
+            //or (2) the module now has a different configId and the configuration on the server using
+            //the old id as specified in the project-configId map should be uninstalled.
+            doChanged(module, configId);
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.doAdded");
+    }
+
+    /**
+     * @param module
+     * @param configId the forced configId to process this method, passed in when invoked from doAdded()
+     * @throws Exception
+     */
+    protected void doChanged(IModule module, String configId) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.doChanged", module.getName(), configId);
+        
+        configId = getLastKnowConfigurationId(module, configId);
+        if(configId != null) {
+            String moduleConfigId = getConfigId(module);
+            if(moduleConfigId.equals(configId)) {
+                
+                if (this.getServerDelegate().isNotRedeployJSPFiles()&&!this.isRemote() && GeronimoUtils.isWebModule(module)
+                        && !module.isExternal()) {
+                    // if only jsp files changed, no redeploy needed
+                    if (findAndReplaceJspFiles(module, configId))
+                        return;
+                }
+                
+                IStatus status = reDeploy(module);
+                if (!status.isOK()) {
+                    doFail(status, Messages.REDEPLOY_FAIL);
+                }
+            } else {
+                //different configIds from what needs to be undeployed to what will be deployed
+                doRemoved(module);
+                doAdded(module, null);
+            }
+        } else {
+            //The checked configuration no longer exists on the server
+            doAdded(module, configId);
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.doChanged");
+    }
+
+    
+    
+    /*
+     * This method is used to replace updated JSP files without deploy it. 
+     */
+    private boolean findAndReplaceJspFiles(IModule module, String configId)
+            throws CoreException {
+        IModule[] modules = { module };
+        IModuleResourceDelta[] deltaArray = this
+                .getPublishedResourceDelta(modules);
+
+        // get repository position
+        String ch = File.separator;
+        String repositoryLocation = this.getRuntimeDelegate().getRuntime()
+                .getLocation().toOSString()
+                + ch + "repository" + ch;
+        // Suppose directory structure of deployed module is
+        // "repository/[groupID]/[artifactId]/[version]/[artifactId]-[version].[artifactType]"
+        // configId contains the groupID,artifactId,version,artifactType
+        String[] segments = configId.split("/");
+        // groupId may contains "." as separator
+        String groupId = null;
+        if (segments[0]!=null)
+            groupId=segments[0].replace(".", "/");
+        String moduleTargetPath = repositoryLocation.concat(groupId)
+                        .concat(ch).concat(segments[1]).concat(ch).concat(segments[2])
+                        .concat(ch).concat(segments[1]).concat("-").concat(segments[2])
+                        .concat(".").concat(segments[3]);
+
+        List<IModuleResourceDelta> jspFiles = new ArrayList<IModuleResourceDelta>();
+        for (IModuleResourceDelta delta : deltaArray) {
+            List<IModuleResourceDelta> partJspFiles= DeploymentUtils
+                    .getAffectedJSPFiles(delta);
+            //if not only Jsp files found, need to redeploy the module, so return false;
+            if (partJspFiles == null) return false;
+            else jspFiles.addAll(partJspFiles);
+        }
+            for (IModuleResourceDelta deltaModule : jspFiles) {
+                IModuleFile moduleFile = (IModuleFile) deltaModule
+                        .getModuleResource();
+
+                String target;
+                String relativePath = moduleFile.getModuleRelativePath()
+                        .toOSString();
+                if (relativePath != null && relativePath.length() != 0) {
+                    target = moduleTargetPath.concat(ch).concat(relativePath)
+                            .concat(ch).concat(moduleFile.getName());
+                } else
+                    target = moduleTargetPath.concat(ch).concat(
+                            moduleFile.getName());
+
+                File file = new File(target);
+                switch (deltaModule.getKind()) {
+                case IModuleResourceDelta.REMOVED:
+                    if (file.exists())
+                        file.delete();
+                    break;
+                case IModuleResourceDelta.ADDED:
+                case IModuleResourceDelta.CHANGED:
+                    if (!file.exists())
+                        try {
+                            file.createNewFile();
+                        } catch (IOException e) {
+                            Trace.trace(Trace.SEVERE, "can't create file "
+                                    + file, e);
+                            throw new CoreException(new Status(IStatus.ERROR,
+                                    Activator.PLUGIN_ID, "can't create file "
+                                            + file, e));
+                        }
+
+                    String rootFolder = GeronimoUtils.getVirtualComponent(
+                            module).getRootFolder().getProjectRelativePath()
+                            .toOSString();
+                    String sourceFile = module.getProject().getFile(
+                            rootFolder + ch
+                                    + moduleFile.getModuleRelativePath() + ch
+                                    + moduleFile.getName()).getLocation()
+                            .toString();
+                    try {
+
+                        FileInputStream in = new FileInputStream(sourceFile);
+                        FileOutputStream out = new FileOutputStream(file);
+                        FileChannel inChannel = in.getChannel();
+                        FileChannel outChannel = out.getChannel();
+                        MappedByteBuffer mappedBuffer = inChannel.map(
+                                FileChannel.MapMode.READ_ONLY, 0, inChannel
+                                        .size());
+                        outChannel.write(mappedBuffer);
+
+                        inChannel.close();
+                        outChannel.close();
+                    } catch (FileNotFoundException e) {
+                        Trace.trace(Trace.SEVERE, "can't find file "
+                                + sourceFile, e);
+                        throw new CoreException(new Status(IStatus.ERROR,
+                                Activator.PLUGIN_ID, "can't find file "
+                                        + sourceFile, e));
+                    } catch (IOException e) {
+                        Trace.trace(Trace.SEVERE, "can't copy file "
+                                + sourceFile, e);
+                        throw new CoreException(new Status(IStatus.ERROR,
+                                Activator.PLUGIN_ID, "can't copy file "
+                                        + sourceFile, e));
+                    }
+                    break;
+                }
+            }
+
+        return true;
+
+    }
+
+
+    private String getLastKnowConfigurationId(IModule module, String configId) throws Exception {
+        Trace.tracePoint("Entry ", "GeronimoServerBehaviourDelegate.getLastKnowConfigurationId", module.getName(), configId);
+
+        //use the correct configId, second from the .metadata, then from the plan
+        configId = configId != null ? configId : DeploymentUtils.getLastKnownConfigurationId(module, getServer());
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.getLastKnowConfigurationId", configId);
+        return configId;
+    }
+
+    protected void doRemoved(IModule module) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.doRemoved", module.getName());
+
+        IStatus status = unDeploy(module);
+        if (!status.isOK()) {
+            doFail(status, Messages.UNDEPLOY_FAIL);
+        }
+        
+        ModuleArtifactMapper.getInstance().removeEntry(getServer(), module.getProject());
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.doRemoved");
+    }
+    
+    protected void doNoChange(IModule module) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.doNoChange", module.getName());
+        
+        if(DeploymentUtils.getLastKnownConfigurationId(module, getServer()) != null) {
+            start(module);
+        } else {
+            doAdded(module, null);
+        }
+        
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.doNoChange");
+    }
+
+    protected void doRestart(IModule module) throws Exception {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.doRestart", module.getName());
+        
+        IStatus status = stop(module);
+        if (!status.isOK()) {
+            doFail(status, Messages.STOP_FAIL);
+        }
+
+        status = start(module);
+        if (!status.isOK()) {
+            doFail(status, Messages.START_FAIL);
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.doRestart");
+    }
+    
+    private TargetModuleID[] updateServerModuleConfigIDMap(IModule module, IStatus status) {
+        TargetModuleID[] ids = ((DeploymentCmdStatus) status).getResultTargetModuleIDs();
+        ModuleArtifactMapper mapper = ModuleArtifactMapper.getInstance();
+        mapper.addEntry(getServer(), module.getProject(), ids[0].getModuleID());
+        return ids;
+    }
+
+    protected void doFail(IStatus status, String message) throws CoreException {
+        MultiStatus ms = new MultiStatus(Activator.PLUGIN_ID, 0, message, null);
+        ms.addAll(status);
+        throw new CoreException(ms);
+    }
+
+    protected IStatus distribute(IModule module) throws Exception {
+        IDeploymentCommand cmd = DeploymentCommandFactory.createDistributeCommand(module, getServer());
+        return cmd.execute(_monitor);
+    }
+
+    protected IStatus start(IModule module) throws Exception {
+        TargetModuleID id = DeploymentUtils.getTargetModuleID(getServer(), module);
+        IDeploymentCommand cmd = DeploymentCommandFactory.createStartCommand(new TargetModuleID[] { id }, module, getServer());
+        return cmd.execute(_monitor);
+    }
+    
+    protected IStatus start(TargetModuleID[] ids) throws Exception {
+        IDeploymentCommand cmd = DeploymentCommandFactory.createStartCommand(ids, null, getServer());
+        return cmd.execute(_monitor);
+    }
+
+    protected IStatus stop(IModule module) throws Exception {
+        IDeploymentCommand cmd = DeploymentCommandFactory.createStopCommand(module, getServer());
+        return cmd.execute(_monitor);
+    }
+
+    protected IStatus unDeploy(IModule module) throws Exception {
+        IDeploymentCommand cmd = DeploymentCommandFactory.createUndeployCommand(module, getServer());
+        return cmd.execute(_monitor);
+    }
+
+    protected IStatus reDeploy(IModule module) throws Exception {
+        IDeploymentCommand cmd = DeploymentCommandFactory.createRedeployCommand(module, getServer());
+        return cmd.execute(_monitor);
+    }
+
+    public Map getServerInstanceProperties() {
+        return getRuntimeDelegate().getServerInstanceProperties();
+    }
+
+    protected GeronimoRuntimeDelegate getRuntimeDelegate() {
+        GeronimoRuntimeDelegate rd = (GeronimoRuntimeDelegate) getServer().getRuntime().getAdapter(GeronimoRuntimeDelegate.class);
+        if (rd == null)
+            rd = (GeronimoRuntimeDelegate) getServer().getRuntime().loadAdapter(GeronimoRuntimeDelegate.class, new NullProgressMonitor());
+        return rd;
+    }
+
+    protected GeronimoServerDelegate getServerDelegate() {
+        GeronimoServerDelegate sd = (GeronimoServerDelegate) getServer().getAdapter(GeronimoServerDelegate.class);
+        if (sd == null)
+            sd = (GeronimoServerDelegate) getServer().loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
+        return sd;
+    }
+
+    protected boolean isRemote() {
+        return getServer().getServerType().supportsRemoteHosts()
+                && !SocketUtil.isLocalhost(getServer().getHost());
+    }
+
+    protected void setupLaunchClasspath(ILaunchConfigurationWorkingCopy wc, IVMInstall vmInstall) throws CoreException {
+        List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();
+        
+        String version = getServer().getRuntime().getRuntimeType().getVersion();
+        
+        if (version.startsWith("3")) {
+            //get required jar file
+            IPath libPath = getServer().getRuntime().getLocation().append("/lib");
+            for (String jarFile: libPath.toFile().list()){
+                IPath serverJar = libPath.append("/"+jarFile);
+                cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(serverJar));
+            }
+            
+        }else{
+             //for 1.1,2.0,2.1,2.2 
+             IPath serverJar = getServer().getRuntime().getLocation().append("/lib/server.jar");
+             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);
+    }
+
+    private List convertCPEntryToMemento(List cpEntryList) {
+        List<String> list = new ArrayList<String>(cpEntryList.size());
+        Iterator iterator = cpEntryList.iterator();
+        while (iterator.hasNext()) {
+            IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) iterator.next();
+            try {
+                list.add(entry.getMemento());
+            } catch (CoreException e) {
+                Trace.trace(Trace.SEVERE, "Could not resolve classpath entry: "
+                        + entry, e);
+            }
+        }
+        return list;
+    }
+
+    public void setProcess(final IProcess newProcess) {
+        if (process != null)
+            return;
+
+        process = newProcess;
+        if (processListener != null)
+            DebugPlugin.getDefault().removeDebugEventListener(processListener);
+        if (newProcess == null)
+            return;
+
+        processListener = new IDebugEventSetListener() {
+            public void handleDebugEvents(DebugEvent[] events) {
+                if (events != null) {
+                    int size = events.length;
+                    for (int i = 0; i < size; i++) {
+                        if (process != null
+                                && process.equals(events[i].getSource())
+                                && events[i].getKind() == DebugEvent.TERMINATE) {
+                            DebugPlugin.getDefault().removeDebugEventListener(this);
+                            stopImpl();
+                        }
+                    }
+                }
+            }
+        };
+        DebugPlugin.getDefault().addDebugEventListener(processListener);
+    }
+
+    protected void startPingThread() {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.startPingThread");
+
+        pingThread = new PingThread(this, getServer());
+        pingThread.start();
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.startPingThread");
+    }
+    
+    protected void stopPingThread() {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.stopPingThread");
+
+        if (pingThread != null) {
+            pingThread.interrupt();
+            pingThread = null;
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.stopPingThread");
+    }
+    
+    protected abstract void stopKernel();
+
+    public void startUpdateServerStateTask() {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.startUpdateServerStateTask", getServer().getName());
+
+        timer = new Timer(true);
+        timer.schedule(new UpdateServerStateTask(this, getServer()), TIMER_TASK_DELAY * 1000, TIMER_TASK_INTERVAL * 1000);
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.startUpdateServerStateTask");
+    }
+
+    public void stopUpdateServerStateTask() {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.stopUpdateServerStateTask", getServer().getName());
+
+        if (timer != null)
+            timer.cancel();
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.stopUpdateServerStateTask");
+    }
+
+    protected IPath getModulePath(IModule[] module, URL baseURL) {
+        Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.getModulePath", Arrays.asList(module).toString(), baseURL);
+
+        IPath modulePath = new Path(baseURL.getFile());
+
+        if (module.length == 2) {
+            IModule workingModule = module[module.length - 1];
+            modulePath = modulePath.append(workingModule.getName());
+            if (GeronimoUtils.isWebModule(workingModule)) {
+                modulePath = modulePath.addFileExtension("war");
+            } else if (GeronimoUtils.isEjbJarModule(workingModule)) {
+                modulePath = modulePath.addFileExtension("jar");
+            } else if (GeronimoUtils.isRARModule(workingModule)) {
+                modulePath = modulePath.addFileExtension("rar");
+            } else if (GeronimoUtils.isEarModule(workingModule)) {
+                modulePath = modulePath.addFileExtension("ear");
+            } else if (GeronimoUtils.isAppClientModule(workingModule)) {
+                modulePath = modulePath.addFileExtension("jar");
+            }
+        }
+
+        Trace.tracePoint("Exit ", "GeronimoServerBehaviourDelegate.getModulePath", modulePath);
+        return modulePath;
+    }
+
+    public MBeanServerConnection getServerConnection() throws Exception {
+        Map map = new HashMap();
+        String user = getGeronimoServer().getAdminID();
+        String password = getGeronimoServer().getAdminPassword();
+        String port = getGeronimoServer().getRMINamingPort();
+        map.put("jmx.remote.credentials", new String[] { user, password });
+        map.put("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
+        map.put("java.naming.factory.url.pkgs", "org.apache.geronimo.naming");
+        map.put("java.naming.provider.url", "rmi://" + getServer().getHost()
+                + ":" + port);
+
+        String url = getGeronimoServer().getJMXServiceURL();
+        if (url != null) {
+            try {
+                JMXServiceURL address = new JMXServiceURL(url);
+                JMXConnector jmxConnector;
+                try {
+                    jmxConnector = JMXConnectorFactory.connect(address, map);
+                } catch (SecurityException se) {
+                    //FIXME once GERONIMO-3467 JIRA is fixed
+                    Thread.sleep(10000);
+                    jmxConnector = JMXConnectorFactory.connect(address, map);
+                }
+                MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
+                Trace.trace(Trace.INFO, "Connected to kernel. " + url);
+                return connection;
+            } catch (MalformedURLException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return null;
+    }
+    
+    public Target[] getTargets() {
+        return null;
+    }
+    
+    public static String deltaKindToString(int kind) {
+        switch(kind) {
+        case NO_CHANGE:
+            return "NO_CHANGE";
+        case ADDED:
+            return "ADDED";
+        case CHANGED:
+            return "CHANGED";
+        case REMOVED:
+            return "REMOVED";
+        }
+        return Integer.toString(kind);
+    }
+    
+    public String getConfigId(IModule module) throws Exception {
+        return getGeronimoServer().getVersionHandler().getConfigID(module);
+    }
+    
+    private IStatus updateSharedLib(IModule[] module, IProgressMonitor monitor) {
+        IDataModel model = DataModelFactory.createDataModel(new SharedLibEntryDataModelProvider());
+        model.setProperty(ISharedLibEntryCreationDataModelProperties.MODULES, module);
+        model.setProperty(ISharedLibEntryCreationDataModelProperties.SERVER, getServer());
+        IDataModelOperation op = new SharedLibEntryCreationOperation(model);
+        try {
+            op.execute(monitor, null);
+        } catch (ExecutionException e) {
+            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, e.getMessage(), e.getCause());
+        }
+        return Status.OK_STATUS;
+    }
+    
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,428 @@
+/*
+ * 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.v30.core;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.server.core.FacetUtil;
+import org.eclipse.jst.server.core.IEnterpriseApplication;
+import org.eclipse.jst.server.core.IWebModule;
+import org.eclipse.jst.server.core.internal.J2EEUtil;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.ServerPort;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ServerMonitorManager;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+
+/**
+ * @version $Rev$ $Date$
+ */
+abstract public class GeronimoServerDelegate extends ServerDelegate implements IGeronimoServer {
+
+    public static final String PROPERTY_ADMIN_ID = "adminID";
+
+    public static final String PROPERTY_ADMIN_PW = "adminPassword";
+
+    public static final String PROPERTY_RMI_PORT = "RMIRegistry";
+
+    public static final String PROPERTY_HTTP_PORT = "WebConnector";
+
+    public static final String PROPERTY_LOG_LEVEL = "logLevel";
+    
+    public static final String PROPERTY_VM_ARGS = "VMArgs";
+    
+    public static final String PROPERTY_PING_DELAY = "pingDelay";
+    
+    public static final String PROPERTY_PING_INTERVAL = "pingInterval";
+    
+    public static final String PROPERTY_MAX_PINGS = "maxPings";
+    
+    public static final String PROPERTY_PUBLISH_TIMEOUT = "publishTimeout";
+    
+    public static final String PROPERTY_IN_PLACE_SHARED_LIB = "inPlaceSharedLib";
+    
+    public static final String PROPERTY_NOT_REDEPLOY_JSP_FILES = "notRedeployJSPFiles";
+    
+    public static final String PROPERTY_RUN_FROM_WORKSPACE = "runFromWorkspace";
+
+    public static final String PROPERTY_SELECT_CLASSPATH_CONTAINERS = "selectClasspathContainers";
+
+    public static final String PROPERTY_CLASSPATH_CONTAINERS = "classpathContainers";
+
+    public static final String CONSOLE_INFO = "--long";
+
+    public static final String CONSOLE_DEBUG = "-vv";
+
+    public abstract String getContextRoot(IModule module) throws Exception ;
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerDelegate#canModifyModules(org.eclipse.wst.server.core.IModule[],
+     *      org.eclipse.wst.server.core.IModule[])
+     */
+    public IStatus canModifyModules(IModule[] add, IModule[] remove) {
+        if (add != null) {
+            for (int i = 0; i < add.length; i++) {
+                IModule module = add[i];
+                if (module.getProject() != null) {
+                    IStatus status = FacetUtil.verifyFacets(module.getProject(), getServer());
+                    if (status != null && !status.isOK()) {
+                        return status;
+                    }
+                }
+            }
+        }
+        return Status.OK_STATUS;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerDelegate#modifyModules(org.eclipse.wst.server.core.IModule[],
+     *      org.eclipse.wst.server.core.IModule[],
+     *      org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void modifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor) throws CoreException {
+        // TODO servermodule.info should be pushed to here and set as instance
+        // property
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerDelegate#getRootModules(org.eclipse.wst.server.core.IModule)
+     */
+    public IModule[] getRootModules(IModule module) throws CoreException {
+        IStatus status = canModifyModules(new IModule[] { module }, null);
+        if (status != null && !status.isOK())
+            throw new CoreException(status);
+        IModule[] childs = doGetParentModules(module);
+        if (childs.length > 0)
+            return childs;
+        return new IModule[] { module };
+    }
+
+    private IModule[] doGetParentModules(IModule module) {
+        ArrayList<IModule> parents = new ArrayList<IModule>();
+        parents.addAll(getApplicationModules(module));
+
+        // also check to see if the module is a utility module for a stand-alone
+        // web module
+        IModule[] wars = J2EEUtil.getWebModules(module, null);
+        for (int i = 0; i < wars.length; i++) {
+            if (getApplicationModules(wars[i]).isEmpty()) {
+                parents.add(wars[i]);
+            }
+        }
+        return (IModule[]) parents.toArray(new IModule[parents.size()]);
+    }
+
+    private List<IModule> getApplicationModules(IModule module) {
+        IModule[] ears = ServerUtil.getModules(IModuleConstants.JST_EAR_MODULE);
+        ArrayList<IModule> list = new ArrayList<IModule>();
+        for (int i = 0; i < ears.length; i++) {
+            IEnterpriseApplication ear = (IEnterpriseApplication) ears[i].loadAdapter(IEnterpriseApplication.class, null);
+            IModule[] childs = ear.getModules();
+            for (int j = 0; j < childs.length; j++) {
+                if (childs[j].equals(module))
+                    list.add(ears[i]);
+            }
+        }
+        return list;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerDelegate#getChildModules(org.eclipse.wst.server.core.IModule[])
+     */
+    public IModule[] getChildModules(IModule[] module) {
+        if (module == null)
+            return null;
+
+        if (module.length == 1 && module[0] != null) {
+            IModuleType moduleType = module[0].getModuleType();
+            if (moduleType != null) {
+                if (IModuleConstants.JST_EAR_MODULE.equals(moduleType.getId())) {
+                    IEnterpriseApplication enterpriseApplication = (IEnterpriseApplication) module[0].loadAdapter(IEnterpriseApplication.class, null);
+                    if (enterpriseApplication != null) {
+                        IModule[] modules = enterpriseApplication.getModules();
+                        if (modules != null)
+                            return modules;
+                    }
+                } else if (IModuleConstants.JST_WEB_MODULE.equals(moduleType.getId())) {
+                    IWebModule webModule = (IWebModule) module[0].loadAdapter(IWebModule.class, null);
+                    if (webModule != null) {
+                        IModule[] modules = webModule.getModules();
+                        if (modules != null)
+                            return modules;
+                    }
+                }
+            }
+        }
+
+        return new IModule[] {};
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerDelegate#getServerPorts()
+     */
+    public ServerPort[] getServerPorts() {
+        List<ServerPort> ports = new ArrayList<ServerPort>();
+        ports.add(new ServerPort(PROPERTY_HTTP_PORT, "Web Connector", Integer.parseInt(getHTTPPort()), "http"));
+        ports.add(new ServerPort(PROPERTY_RMI_PORT, "RMI Naming", Integer.parseInt(getRMINamingPort()), "rmi"));
+        return (ServerPort[]) ports.toArray(new ServerPort[ports.size()]);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.IURLProvider#getModuleRootURL(org.eclipse.wst.server.core.IModule)
+     */
+    public URL getModuleRootURL(IModule module) {
+        try {
+            if (module == null
+                    || module.loadAdapter(IWebModule.class, null) == null)
+                return null;
+
+            String host = getServer().getHost();
+            String url = "http://" + host;
+            int port = 0;
+
+            port = Integer.parseInt(getHTTPPort());
+            port = ServerMonitorManager.getInstance().getMonitoredPort(getServer(), port, "web");
+            if (port != 80)
+                url += ":" + port;
+
+            String moduleId = getContextRoot(module);
+            if (!moduleId.startsWith("/"))
+                url += "/";
+            url += moduleId;
+
+            if (!url.endsWith("/"))
+                url += "/";
+
+            return new URL(url);
+        } catch (Exception e) {
+            Trace.trace(Trace.SEVERE, "Could not get root URL", e);
+            return null;
+        }
+
+    }
+
+    public String getAdminID() {
+        return getInstanceProperty(PROPERTY_ADMIN_ID);
+    }
+
+    public String getAdminPassword() {
+        return getInstanceProperty(PROPERTY_ADMIN_PW);
+    }
+
+    public String getRMINamingPort() {
+        return getInstanceProperty(PROPERTY_RMI_PORT);
+    }
+
+    public String getHTTPPort() {
+        return getInstanceProperty(PROPERTY_HTTP_PORT);
+    }
+
+    public String getConsoleLogLevel() {
+        return getInstanceProperty(PROPERTY_LOG_LEVEL);
+    }
+    
+    public String getVMArgs() {
+        return getInstanceProperty(PROPERTY_VM_ARGS);
+    }
+
+    public void setAdminID(String value) {
+        setInstanceProperty(PROPERTY_ADMIN_ID, value);
+    }
+
+    public void setAdminPassword(String value) {
+        setInstanceProperty(PROPERTY_ADMIN_PW, value);
+    }
+
+    public void setRMINamingPort(String value) {
+        setInstanceProperty(PROPERTY_RMI_PORT, value);
+    }
+
+    public void setHTTPPort(String value) {
+        setInstanceProperty(PROPERTY_HTTP_PORT, value);
+    }
+
+    public void setConsoleLogLevel(String value) {
+        setInstanceProperty(PROPERTY_LOG_LEVEL, value);
+    }
+    
+    public void setVMArgs(String value) {
+        setInstanceProperty(PROPERTY_VM_ARGS, value);
+    }
+    
+    public int getPingDelay() {
+        String pingDelay = getInstanceProperty(PROPERTY_PING_DELAY);
+        return Integer.parseInt(pingDelay);
+    }
+    
+    public int getPingInterval() {
+        String pingInterval = getInstanceProperty(PROPERTY_PING_INTERVAL);
+        return Integer.parseInt(pingInterval);
+    }
+    
+    public int getMaxPings() {
+        String maxPings = getInstanceProperty(PROPERTY_MAX_PINGS);
+        return Integer.parseInt(maxPings);
+    }
+    
+    public long getPublishTimeout() {
+        String timeout = getInstanceProperty(PROPERTY_PUBLISH_TIMEOUT);
+        return Long.parseLong(timeout);
+    }
+    
+    public void setPingDelay(Integer delay) {
+        setInstanceProperty(PROPERTY_PING_DELAY, delay.toString());
+    }
+    
+    public void setPingInterval(Integer interval) {
+        setInstanceProperty(PROPERTY_PING_INTERVAL, interval.toString());
+    }
+    
+    public void setMaxPings(Integer maxPings) {
+        setInstanceProperty(PROPERTY_MAX_PINGS, maxPings.toString());
+    }
+    
+    public void setPublishTimeout(long timeout) {
+        setInstanceProperty(PROPERTY_PUBLISH_TIMEOUT, Long.toString(timeout));
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.st.v30.core.IGeronimoServer#isInPlace()
+     */
+    public boolean isInPlaceSharedLib() {
+        return getAttribute(PROPERTY_IN_PLACE_SHARED_LIB, false);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.st.v30.core.IGeronimoServer#isRunFromWorkspace()
+     */
+    public boolean isRunFromWorkspace() {
+        return getAttribute(PROPERTY_RUN_FROM_WORKSPACE, false);
+    }
+    
+    
+    //
+    // PROPERTY_SELECT_CLASSPATH_CONTAINERS
+    //
+    public boolean isSelectClasspathContainers() {
+        return getAttribute(PROPERTY_SELECT_CLASSPATH_CONTAINERS, false);
+    }
+    public void setSelectClasspathContainers(boolean enable) {
+        setAttribute(PROPERTY_SELECT_CLASSPATH_CONTAINERS, enable);
+    }
+    
+    
+    //
+    // PROPERTY_CLASSPATH_CONTAINERS
+    //
+    public List<String> getClasspathContainers() {
+        return getAttribute(PROPERTY_CLASSPATH_CONTAINERS, new ArrayList<String>() );
+    }
+    public void setClasspathContainers( List<String> list ) {
+        setAttribute(PROPERTY_CLASSPATH_CONTAINERS, list);
+    }
+    
+    
+    public void setInPlaceSharedLib(boolean enable) {
+        setAttribute(PROPERTY_IN_PLACE_SHARED_LIB, enable);
+    }
+
+    public void setNotRedeployJSPFiles(boolean enable){
+        setAttribute(PROPERTY_NOT_REDEPLOY_JSP_FILES,enable);
+    }
+
+    public void setRunFromWorkspace(boolean enable) {
+        setAttribute(PROPERTY_RUN_FROM_WORKSPACE, enable);
+    }
+    
+    public String discoverDeploymentFactoryClassName(IPath jarPath) {
+        try {
+            JarFile deployerJar = new JarFile(jarPath.toFile());
+            Manifest manifestFile = deployerJar.getManifest();
+            Attributes attributes = manifestFile.getMainAttributes();
+            return attributes.getValue("J2EE-DeploymentFactory-Implementation-Class");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.wst.server.core.model.ServerDelegate#setDefaults(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void setDefaults(IProgressMonitor monitor) {
+        setAdminID("system");
+        setAdminPassword("manager");
+        setHTTPPort("8080");
+        setRMINamingPort("1099");
+        setConsoleLogLevel(CONSOLE_INFO);
+        setPingDelay(new Integer(10000));
+        setMaxPings(new Integer(40));
+        setPingInterval(new Integer(5000));
+        setPublishTimeout(900000);
+        setInPlaceSharedLib(false);
+        setRunFromWorkspace(false);
+        setSelectClasspathContainers(false);
+    }
+
+    public String getInstanceProperty(String name) {
+        return (String) getServerInstanceProperties().get(name);
+    }
+
+    public void setInstanceProperty(String name, String value) {
+        Map map = getServerInstanceProperties();
+        map.put(name, value);
+        setServerInstanceProperties(map);
+    }
+
+    public Map getServerInstanceProperties() {
+        return getAttribute(GeronimoRuntimeDelegate.SERVER_INSTANCE_PROPERTIES, new HashMap());
+    }
+
+    public void setServerInstanceProperties(Map map) {
+        setAttribute(GeronimoRuntimeDelegate.SERVER_INSTANCE_PROPERTIES, map);
+    }
+
+    
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerInfo.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerInfo.java?rev=939145&r1=939144&r2=939145&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerInfo.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerInfo.java Thu Apr 29 00:45:13 2010
@@ -40,7 +40,6 @@ import org.apache.geronimo.kernel.Kernel
 import org.apache.geronimo.kernel.NoSuchAttributeException;
 import org.apache.geronimo.kernel.NoSuchOperationException;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate;
 import org.apache.geronimo.st.v30.core.internal.Trace;
 import org.apache.geronimo.system.jmx.KernelDelegate;
 import org.eclipse.core.runtime.IProgressMonitor;

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerRuntimeTargetHandler.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerRuntimeTargetHandler.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerRuntimeTargetHandler.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerRuntimeTargetHandler.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,68 @@
+/*
+ * 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.v30.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.geronimo.st.v30.core.internal.Messages;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate;
+import org.eclipse.wst.server.core.IRuntime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoServerRuntimeTargetHandler extends RuntimeClasspathProviderDelegate {
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate#getClasspathContainerLabel(org.eclipse.wst.server.core.IRuntime)
+     */
+    public String getClasspathContainerLabel(IRuntime runtime) {
+        return Messages.targetRuntime;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate#resolveClasspathContainer(org.eclipse.wst.server.core.IRuntime)
+     */
+    public IClasspathEntry[] resolveClasspathContainer(IRuntime runtime) {
+        return getServerClassPathEntry(runtime);
+    }
+
+    public IClasspathEntry[] getServerClassPathEntry(IRuntime runtime) {
+
+        List<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
+        IPath path = runtime.getLocation().append("lib");
+        addLibraryEntries(list, path.toFile(), true);
+
+        //TODO: review list here when server 3.0 is ready
+        IPath javaMailSpec    = runtime.getLocation().append("repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/");
+        IPath jstlSpec        = runtime.getLocation().append("repository/org/apache/geronimo/bundles/jstl/");
+        IPath myfacesSpec     = runtime.getLocation().append("repository/org/apache/myfaces/core/myfaces-api/");
+        IPath myfacesImplSpec = runtime.getLocation().append("repository/org/apache/myfaces/core/myfaces-impl/");
+        IPath jdbcSpec        = runtime.getLocation().append("repository/org/apache/geronimo/framework/geronimo-jdbc/");
+        addLibraryEntries(list, javaMailSpec.toFile(),      true);
+        addLibraryEntries(list, jstlSpec.toFile(),          true);
+        addLibraryEntries(list, myfacesSpec.toFile(),       true);
+        addLibraryEntries(list, myfacesImplSpec.toFile(),   true);
+        addLibraryEntries(list, jdbcSpec.toFile(),          true);
+
+        return(IClasspathEntry[])list.toArray(new IClasspathEntry[list.size()]);
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerRuntimeTargetHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerRuntimeTargetHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerRuntimeTargetHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,188 @@
+/*
+ * 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.v30.core;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourcePathComputer;
+import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
+import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoSourcePathComputerDelegate implements ISourcePathComputerDelegate {
+    
+    private HashSet additionalSrcPathComputerIds = null;
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration,
+     *      org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
+        Trace.trace(Trace.INFO, ">> GeronimoSourcePathComputerDelegate.computeSourceContainers()");
+        
+        IServer server = ServerUtil.getServer(configuration);
+        IModule[] modules = server.getModules();
+
+        List<IJavaProject> javaProjectList = new ArrayList<IJavaProject>();
+        // populate list of java projects and their source folders
+        processModules(modules, javaProjectList, server, monitor);
+
+        // create a ProjectRuntime classpath entry for each JavaProject
+        IRuntimeClasspathEntry[] projectEntries = new IRuntimeClasspathEntry[javaProjectList.size()];
+        for (int i = 0; i < javaProjectList.size(); i++) {
+            projectEntries[i] = JavaRuntime.newProjectRuntimeClasspathEntry((IJavaProject) javaProjectList.get(i));
+        }
+
+        // combine unresolved entries and project entries
+        IRuntimeClasspathEntry[] unresolvedEntries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
+        IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[projectEntries.length + unresolvedEntries.length];
+        System.arraycopy(unresolvedEntries, 0, entries, 0, unresolvedEntries.length);
+        System.arraycopy(projectEntries, 0, entries, unresolvedEntries.length, projectEntries.length);
+
+        IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
+        ISourceContainer[] defaultContainers = JavaRuntime.getSourceContainers(resolved);
+        
+        HashSet allContainers = new HashSet(Arrays.asList(defaultContainers));
+        Iterator i = getAdditionalSrcPathComputers().iterator();
+        ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
+        Trace.trace(Trace.INFO, "Total # of unique source containers: " + allContainers.size());
+        while(i.hasNext()) {
+            ISourcePathComputer computer = mgr.getSourcePathComputer((String) i.next());
+            Trace.trace(Trace.INFO, "Invoking Source Path Computer " +  computer.getId());
+            ISourceContainer[] jsc = computer.computeSourceContainers(configuration, monitor);
+            if(jsc != null) {
+                Trace.trace(Trace.INFO, "Additional Source Containers returned ...");
+                for(int j = 0; j < jsc.length; j++) {
+                    String name = jsc[j].getName();
+                    Trace.trace(Trace.INFO, "name = " + name);
+                }
+            }
+            allContainers.addAll(Arrays.asList(jsc));
+            Trace.trace(Trace.INFO, "Number # of unique source containers: " + allContainers.size());
+        }
+        
+        //add source container for Geroniom Runtime
+        ISourceContainer[] runtimeContainers = processServer(server);
+        allContainers.addAll(Arrays.asList(runtimeContainers));
+
+        return (ISourceContainer[])allContainers.toArray(new ISourceContainer[allContainers.size()]);
+    }
+    
+    private ISourceContainer[] processServer(IServer server) {
+        IRuntime runtime = server.getRuntime();
+        IGeronimoRuntime gRuntime = (IGeronimoRuntime) runtime.getAdapter(IGeronimoRuntime.class);
+        if (gRuntime != null) {
+            IPath sourcePath = gRuntime.getRuntimeSourceLocation();
+            if (sourcePath != null) {
+                File file = sourcePath.toFile();
+                if (file.isFile()) {
+                    ExternalArchiveSourceContainer sourceContainer = new ExternalArchiveSourceContainer(file.getAbsolutePath(), true);
+                    return new ISourceContainer[] { sourceContainer };
+                } else if (file.isDirectory()) {
+                    // TODO implement me using DirectorySourceContainer
+                }
+            }
+        }
+        return new ISourceContainer[] {};
+    }
+
+    private void processModules(IModule[] modules, List javaProjectList, IServer server, IProgressMonitor monitor) {
+        for (int i = 0; i < modules.length; i++) {
+            IProject project = modules[i].getProject();
+
+            IModule[] childModules = server.getChildModules(new IModule[] { modules[i] }, monitor);
+            if (childModules != null && childModules.length > 0) {
+                processModules(childModules, javaProjectList, server, monitor);
+            }
+
+            if (project != null) {
+                //process referenced projects for shared lib
+                try {
+                    IProject[] referencedProjects = project.getReferencedProjects();
+                    for(int j = 0; j < referencedProjects.length; j++) {
+                        processJavaProject(javaProjectList, referencedProjects[j]);
+                    }
+                } catch (CoreException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+                processJavaProject(javaProjectList, project);
+            }
+        }
+    }
+
+    private void processJavaProject(List javaProjectList, IProject project) {
+        try {
+            if (project.hasNature(JavaCore.NATURE_ID)) {
+                IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
+                if (!javaProjectList.contains(javaProject)) {
+                    javaProjectList.add(javaProject);
+                }
+            }
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+    
+    private synchronized void init() {
+        if(additionalSrcPathComputerIds == null) {
+            additionalSrcPathComputerIds = new HashSet();
+            IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "sourcePathComputerMapping");
+            IConfigurationElement[] extensions = extensionPoint.getConfigurationElements();
+            for (int i = 0; i < extensions.length; i++) {
+                String id = extensions[i].getAttribute("id");
+                Trace.trace(Trace.INFO, "Found extension point " +  id);
+                additionalSrcPathComputerIds.add(id);
+            }
+        }
+    }
+
+    public HashSet getAdditionalSrcPathComputers() {
+        init();
+        return additionalSrcPathComputerIds;
+    }
+
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message