You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by de...@apache.org on 2010/06/08 06:40:28 UTC

svn commit: r952535 [19/26] - in /geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins: org.apache.geronimo.j2ee.v11.jaxbmodel/ org.apache.geronimo.j2ee.v11.jaxbmodel/META-INF/ org.apache.geronimo.j2ee.v11.jaxbmodel/src/main/java/org/apache/geronimo...

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/DeploymentUtils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/DeploymentUtils.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/DeploymentUtils.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/DeploymentUtils.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,297 @@
+/*
+ * 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.v21.core;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.TargetException;
+
+import org.apache.geronimo.st.v21.core.commands.DeploymentCommandFactory;
+import org.apache.geronimo.st.core.ModuleArtifactMapper;
+import org.apache.geronimo.st.core.commands.TargetModuleIdNotFoundException;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jst.j2ee.application.internal.operations.AppClientComponentExportDataModelProvider;
+import org.eclipse.jst.j2ee.application.internal.operations.EARComponentExportDataModelProvider;
+import org.eclipse.jst.j2ee.application.internal.operations.J2EEComponentExportDataModelProvider;
+import org.eclipse.jst.j2ee.internal.ejb.project.operations.EJBComponentExportDataModelProvider;
+import org.eclipse.jst.j2ee.internal.jca.operations.ConnectorComponentExportDataModelProvider;
+import org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider;
+import org.eclipse.jst.server.core.IEnterpriseApplication;
+import org.eclipse.jst.server.core.IWebModule;
+import org.eclipse.jst.server.core.PublishUtil;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.util.ProjectModule;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleFolder;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public class DeploymentUtils {
+
+	public static final IPath STATE_LOC = Activator.getDefault().getStateLocation();
+
+	private DeploymentUtils() {
+	}
+	
+	public static IPath generateExplodedConfiguration(IModule module, IPath outputPath) {
+		
+		IPath output = outputPath.append(module.getName() + getModuleExtension(module));
+		try {
+			IModuleResource[] resources = getModuleResources(module);
+			PublishUtil.publishSmart(resources, output, new NullProgressMonitor());
+			if(GeronimoUtils.isEarModule(module)) {
+				IEnterpriseApplication application = (IEnterpriseApplication) module.loadAdapter(IEnterpriseApplication.class, null);
+				if( application != null ){
+					IModule[] children = application.getModules();
+					 for (int i = 0; i < children.length; i++) {
+						 	IModule child = children[i];
+							IPath childPath = output.append(child.getName() + getModuleExtension(child));
+							IModuleResource[] childResources = getModuleResources(child);
+							PublishUtil.publishSmart(childResources, childPath, new NullProgressMonitor());
+							if(GeronimoUtils.isWebModule(child)) {
+								IWebModule webModule = (IWebModule) module.loadAdapter(IWebModule.class, null);
+								IModule[] libs = webModule.getModules();
+								IPath webLibPath = childPath.append("WEB-INF").append("lib");
+								for(int j = 0; j < libs.length; j++) {
+									IModule lib = libs[j];
+									IModuleResource[] libResources = getModuleResources(lib);
+									PublishUtil.publishSmart(libResources, webLibPath.append(lib.getName() + getModuleExtension(lib)), new NullProgressMonitor());
+								}
+							}
+					 }
+				}
+			}
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+		
+		return output;
+	}
+	
+	public static IModuleResource[] getModuleResources(IModule module) throws CoreException {
+		ProjectModule pm = (ProjectModule)module.loadAdapter(ProjectModule.class, null);
+		if (pm != null) {
+			return pm.members();
+		}
+		return null;
+	}
+	
+	private static String getModuleExtension(IModule module) {
+		if(GeronimoUtils.isEarModule(module)) {
+			return ".ear";
+		}else if(GeronimoUtils.isWebModule(module)) {
+			return ".war";
+		}else if(GeronimoUtils.isRARModule(module)) {
+			return ".rar";
+		}else if(GeronimoUtils.isAppClientModule(module)) {
+			return ".car";
+ 		}
+
+		return ".jar";
+	}
+
+	public static File createJarFile(IModule module, IPath outputPath) {
+		IDataModel model = getExportDataModel(module);
+
+		if (model != null) {
+
+			IVirtualComponent comp = ComponentCore.createComponent(module.getProject());
+
+			//Here, specific extension name should be got, in case module has no standard JEE descriptor file included
+			String extensionName = getModuleExtension(module);
+			
+			model.setProperty(J2EEComponentExportDataModelProvider.PROJECT_NAME, module.getProject());
+			model.setProperty(J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION, outputPath.append(module.getName())
+					+ extensionName);
+
+			model.setProperty(J2EEComponentExportDataModelProvider.COMPONENT, comp);
+			model.setBooleanProperty(J2EEComponentExportDataModelProvider.OVERWRITE_EXISTING, true);
+			model.setBooleanProperty(J2EEComponentExportDataModelProvider.RUN_BUILD, false);
+
+			if (model != null) {
+				try {
+					model.getDefaultOperation().execute(null, null);
+					return new File(model.getStringProperty(J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION));
+				} catch (ExecutionException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+
+		return null;
+	}
+
+	public static IDataModel getExportDataModel(IModule module) {
+		String type = module.getModuleType().getId();
+		if (IModuleConstants.JST_WEB_MODULE.equals(type)) {
+			return DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());
+		} else if (IModuleConstants.JST_EJB_MODULE.equals(type)) {
+			return DataModelFactory.createDataModel(new EJBComponentExportDataModelProvider());
+		} else if (IModuleConstants.JST_EAR_MODULE.equals(type)) {
+			return DataModelFactory.createDataModel(new EARComponentExportDataModelProvider());
+		} else if (IModuleConstants.JST_CONNECTOR_MODULE.equals(type)) {
+			return DataModelFactory.createDataModel(new ConnectorComponentExportDataModelProvider());
+		} else if (IModuleConstants.JST_APPCLIENT_MODULE.equals(type)) {
+			return DataModelFactory.createDataModel(new AppClientComponentExportDataModelProvider());
+		}
+		return null;
+	}
+	
+	public static TargetModuleID getTargetModuleID(IServer server, IModule module) throws TargetModuleIdNotFoundException {
+		String configId = ModuleArtifactMapper.getInstance().resolve(server, module);
+		if(configId == null) {
+			throw new TargetModuleIdNotFoundException("Could not do a local TargetModuleID lookup for module " + module.getName());
+		}
+		
+		IGeronimoServer gs = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+		return gs.getVersionHandler().createTargetModuleId(configId);
+	}
+
+	public static TargetModuleID getTargetModuleID(DeploymentManager dm, String configId) throws TargetModuleIdNotFoundException {
+
+		try {
+			TargetModuleID id = isInstalledModule(dm,configId);
+			if (id!=null) return id;
+		} catch (IllegalStateException e) {
+			e.printStackTrace();
+		} catch (TargetException e) {
+			e.printStackTrace();
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+
+		throw new TargetModuleIdNotFoundException("Could not find TargetModuleID with configId " + configId);
+	}
+
+	/**
+	 * This method determines the last known config id for an IModule that has been deployed to the server.  The
+	 * configId from the plan cannot be used as the project may have been previously deployed with a different
+	 * configId.  In which case the lookup is done through the ModuleArtifactMapper first.
+	 * 
+	 * @param module
+	 * @param server
+	 * @return For a given module associated with a given server, this method returns the last known configuration id.
+	 * @throws Exception 
+	 */
+	public static String getLastKnownConfigurationId(IModule module, IServer server) throws Exception {
+		
+		IGeronimoServer gs = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+		String currentId = gs.getVersionHandler().getConfigID(module);
+		String publishedId = ModuleArtifactMapper.getInstance().resolve(server, module);
+		String query = publishedId != null ? publishedId : currentId;
+		
+		Trace.trace(Trace.INFO, "currentConfigId = " + currentId + " previousConfigId = " + publishedId);
+		
+		DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(server);
+		
+		try {
+			getTargetModuleID(dm, query);
+			return query;
+		} catch (TargetModuleIdNotFoundException e) {
+			Trace.trace(Trace.INFO, e.getMessage());
+		}
+		
+		if(query != currentId) {
+			try {
+				getTargetModuleID(dm, currentId);
+				return currentId;
+			} catch (TargetModuleIdNotFoundException e) {
+				Trace.trace(Trace.INFO, e.getMessage());
+			}
+		}
+		
+		return null;
+	}
+    
+    
+    public static List<IModuleResourceDelta> getAffectedJSPFiles(IModuleResourceDelta delta) {
+        if (delta == null) return null;
+
+        IModuleResource resource = delta.getModuleResource();
+        List<IModuleResourceDelta> fileList = new ArrayList<IModuleResourceDelta>();
+
+        if (resource instanceof IModuleFile) {
+            IModuleFile moduleFile = (IModuleFile)resource;
+            if (moduleFile.getName().endsWith(".jsp")) {
+                fileList.add(delta);
+            }
+            else return null;   //not only jsp changed
+        }
+        else if (resource instanceof IModuleFolder) {
+             IModuleResourceDelta[] deltaArray = delta.getAffectedChildren();
+			 for (IModuleResourceDelta childDelta : deltaArray) {
+				List<IModuleResourceDelta> deltaChildren = getAffectedJSPFiles(childDelta);
+				if (deltaChildren != null) fileList.addAll(deltaChildren);
+				else return null;
+			}
+        }
+
+        return fileList;
+    }
+    
+    public static boolean isInstalledModule(IServer server, String configId) {
+		DeploymentManager dm;
+		try {
+			dm = DeploymentCommandFactory.getDeploymentManager(server);
+			TargetModuleID id=isInstalledModule(dm,configId);
+			if (id==null) return false;
+			else return true;
+		} catch (CoreException e) {
+			e.printStackTrace();
+			return false;
+		} catch (IllegalStateException e) {
+			e.printStackTrace();
+			return false;
+		} catch (TargetException e) {
+			e.printStackTrace();
+			return false;
+		}
+		
+	}
+	
+	private static TargetModuleID isInstalledModule(DeploymentManager dm, String configId) throws CoreException, IllegalStateException, TargetException{
+		
+		TargetModuleID[] ids = dm.getAvailableModules(null, dm.getTargets());
+		if(ids == null) return null;
+		if (ids != null) {
+			for (int i = 0; i < ids.length; i++) {
+				if (ids[i].getModuleID().equals(configId)) {
+					Trace.trace(Trace.INFO, "Found configuration " + configId +  " on server.");
+					return ids[i];
+				}
+			}
+		}
+		return null;
+	}
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoConnectionFactory.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoConnectionFactory.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoConnectionFactory.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoConnectionFactory.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,101 @@
+/*
+ * 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.v21.core;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+import javax.naming.Context;
+
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+
+/**
+ * @version $Rev: 471551 $ $Date: 2006-11-06 06:47:11 +0800 (Mon, 06 Nov 2006) $
+ */
+public class GeronimoConnectionFactory {
+
+	private HashMap connections = new HashMap();
+
+	private static GeronimoConnectionFactory instance;
+
+	private GeronimoConnectionFactory() {
+		super();
+	}
+
+	public static GeronimoConnectionFactory getInstance() {
+		if (instance == null) {
+			instance = new GeronimoConnectionFactory();
+		}
+		return instance;
+	}
+
+	public DeploymentManager getDeploymentManager(IServer server)
+			throws DeploymentManagerCreationException {
+
+		System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
+		DeploymentManager dm = (DeploymentManager) connections.get(server.getId());
+
+		if (dm == null) {
+			DeploymentFactory factory = getGeronimoServer(server).getDeploymentFactory();
+			String deployerURL = getGeronimoServer(server).getDeployerURL();
+			Trace.trace(Trace.INFO, "DeployerURL: " + deployerURL);
+			String user = getGeronimoServer(server).getAdminID();
+			String pw = getGeronimoServer(server).getAdminPassword();
+			dm = factory.getDeploymentManager(deployerURL, user, pw);
+			connections.put(server.getId(), dm);
+		}
+		
+		getGeronimoServer(server).configureDeploymentManager(dm);
+		
+		return dm;
+	}
+
+	private IGeronimoServer getGeronimoServer(IServer server) {
+		IGeronimoServer gServer = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+		if (gServer == null) {
+			gServer = (IGeronimoServer) server.loadAdapter(IGeronimoServer.class, new NullProgressMonitor());
+		}
+		return gServer;
+	}
+
+	public IGeronimoServer getGeronimoServer(DeploymentManager dm) {
+		if (dm != null && connections.containsValue(dm)) {
+			Iterator i = connections.keySet().iterator();
+			while (i.hasNext()) {
+				String serverId = (String) i.next();
+				Object o = connections.get(serverId);
+				if (dm.equals(o)) {
+					IServer server = ServerCore.findServer(serverId);
+					if (server != null)
+						return getGeronimoServer(server);
+				}
+			}
+		}
+		return null;
+	}
+
+	public void destroy(IServer server) {
+		Trace.trace(Trace.INFO, "deploymentManager destroy");
+		connections.remove(server.getId());
+	}
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchConfigurationDelegate.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchConfigurationDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchConfigurationDelegate.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,122 @@
+/*
+ * 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.v21.core;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.geronimo.st.core.internal.Messages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
+import org.eclipse.jdt.launching.ExecutionArguments;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.jst.server.core.ServerProfilerDelegate;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+
+/**
+ * @version $Rev: 797342 $ $Date: 2009-07-24 15:00:11 +0800 (Fri, 24 Jul 2009) $
+ */
+public class GeronimoLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate {
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
+     *      java.lang.String, org.eclipse.debug.core.ILaunch,
+     *      org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+        if (configuration.hasAttribute(GeronimoServerBehaviourDelegate.ERROR_SETUP_LAUNCH_CONFIGURATION)){
+            //get error flag from configuration if it's set in setLaunchConfiguration
+            String errorMessage = configuration.getAttribute(GeronimoServerBehaviourDelegate.ERROR_SETUP_LAUNCH_CONFIGURATION,"");
+            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, errorMessage, null));
+        }
+        
+		IServer server = ServerUtil.getServer(configuration);
+		if (server == null) {
+			throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, Messages.missingServer, null));
+		}
+		GeronimoServerBehaviourDelegate geronimoServer = (GeronimoServerBehaviourDelegate) server.loadAdapter(GeronimoServerBehaviourDelegate.class, null);
+		geronimoServer.setupLaunch(launch, mode, monitor);
+
+		if (geronimoServer.isRemote()) {
+			// no support for launching remote servers
+			return;
+		}
+
+		String mainTypeName = geronimoServer.getRuntimeClass();
+		IVMInstall vm = verifyVMInstall(configuration);
+		IVMRunner runner = vm.getVMRunner(mode);
+		
+		if(runner == null && ILaunchManager.PROFILE_MODE.equals(mode)){
+			runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
+		}
+
+		File workingDir = verifyWorkingDirectory(configuration);
+		String workingDirName = null;
+		if (workingDir != null)
+			workingDirName = workingDir.getAbsolutePath();
+
+		String pgmArgs = getProgramArguments(configuration);
+		String vmArgs = getVMArguments(configuration);
+		String[] envp = getEnvironment(configuration);
+
+		ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
+		Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
+		String[] classpath = getClasspath(configuration);
+
+		// Create VM config
+		VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
+		runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
+		runConfig.setVMArguments(execArgs.getVMArgumentsArray());
+		runConfig.setWorkingDirectory(workingDirName);
+		runConfig.setEnvironment(envp);
+		runConfig.setVMSpecificAttributesMap(vmAttributesMap);
+
+		// Bootpath
+		String[] bootpath = getBootpath(configuration);
+		if (bootpath != null && bootpath.length > 0)
+			runConfig.setBootClassPath(bootpath);
+
+		setDefaultSourceLocator(launch, configuration);
+		
+		if (ILaunchManager.PROFILE_MODE.equals(mode)) {
+			try {
+				ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor);
+			} catch (CoreException ce) {
+				geronimoServer.stopImpl();
+				throw ce;
+			}
+		}
+
+		geronimoServer.startPingThread();
+		runner.run(runConfig, launch, monitor);
+		geronimoServer.setProcess(launch.getProcesses()[0]);
+	}
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchableAdapterDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchableAdapterDelegate.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchableAdapterDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoLaunchableAdapterDelegate.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.v21.core;
+
+import java.net.URL;
+
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.server.core.Servlet;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IURLProvider;
+import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+import org.eclipse.wst.server.core.util.HttpLaunchable;
+import org.eclipse.wst.server.core.util.WebResource;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public class GeronimoLaunchableAdapterDelegate extends LaunchableAdapterDelegate {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.wst.server.core.model.LaunchableAdapterDelegate#getLaunchable(org.eclipse.wst.server.core.IServer,
+	 *      org.eclipse.wst.server.core.IModuleArtifact)
+	 */
+	public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException {
+
+		GeronimoServerDelegate delegate = (GeronimoServerDelegate) server.getAdapter(GeronimoServerDelegate.class);
+		if (delegate == null)
+			delegate = (GeronimoServerDelegate) server.loadAdapter(GeronimoServerDelegate.class, new NullProgressMonitor());
+		if (delegate == null)
+			return null;
+
+		if ((moduleArtifact instanceof Servlet)
+				|| (moduleArtifact instanceof WebResource))
+			return getHttpLaunchable(moduleArtifact, delegate);
+
+		return null;
+	}
+
+	private Object getHttpLaunchable(IModuleArtifact moduleObject, ServerDelegate delegate) throws CoreException {
+		URL url = ((IURLProvider) delegate).getModuleRootURL(moduleObject.getModule());
+		try {
+			if (moduleObject instanceof Servlet) {
+				Servlet servlet = (Servlet) moduleObject;
+				if (servlet.getAlias() != null) {
+					String path = servlet.getAlias();
+					if (path.startsWith("/"))
+						path = path.substring(1);
+					url = new URL(url, path);
+				} else
+					url = new URL(url, "servlet/"
+							+ servlet.getServletClassName());
+			} else if (moduleObject instanceof WebResource) {
+				WebResource resource = (WebResource) moduleObject;
+				String path = resource.getPath().toString();
+				if (path != null && path.startsWith("/") && path.length() > 0)
+					path = path.substring(1);
+				if (path != null && path.length() > 0)
+					url = new URL(url, path);
+			}
+			return new HttpLaunchable(url);
+		} catch (Exception e) {
+			Trace.trace(Trace.SEVERE, "Error getting URL for " + moduleObject, e);
+			throw new CoreException (new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Error getting URL for " + moduleObject,e));
+		}
+	}
+
+}

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServer.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServer.java?rev=952535&r1=952534&r2=952535&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServer.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServer.java Tue Jun  8 04:40:16 2010
@@ -23,8 +23,8 @@ import javax.enterprise.deploy.spi.facto
 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
 import org.apache.geronimo.st.core.GeronimoRuntimeDelegate;
-import org.apache.geronimo.st.core.GeronimoServerDelegate;
-import org.apache.geronimo.st.core.IGeronimoVersionHandler;
+import org.apache.geronimo.st.v21.core.GeronimoServerDelegate;
+import org.apache.geronimo.st.v21.core.IGeronimoVersionHandler;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
@@ -60,7 +60,7 @@ public class GeronimoServer extends Gero
     /*
      * (non-Javadoc)
      *
-     * @see org.apache.geronimo.st.core.IGeronimoServer#getDeployerURL()
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#getDeployerURL()
      */
     public String getDeployerURL() {
         return "deployer:geronimo:jmx://" + getServer().getHost() + ":" + getRMINamingPort();
@@ -118,7 +118,7 @@ public class GeronimoServer extends Gero
     /*
      * (non-Javadoc)
      *
-     * @see org.apache.geronimo.st.core.IGeronimoServer#getJMXServiceURL()
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#getJMXServiceURL()
      */
     public String getJMXServiceURL() {
         String host = getServer().getHost();
@@ -128,7 +128,7 @@ public class GeronimoServer extends Gero
     /*
      * (non-Javadoc)
      *
-     * @see org.apache.geronimo.st.core.IGeronimoServer#getJSR88DeployerJar()
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#getJSR88DeployerJar()
      */
     public IPath getJSR88DeployerJar() {
         return getServer().getRuntime().getLocation().append("/lib/jsr88-deploymentfactory.jar");
@@ -137,7 +137,7 @@ public class GeronimoServer extends Gero
     /*
      * (non-Javadoc)
      *
-     * @see org.apache.geronimo.st.core.IGeronimoServer#getDeploymentFactory()
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#getDeploymentFactory()
      */
     public DeploymentFactory getDeploymentFactory() {
         return deploymentFactory;
@@ -146,7 +146,7 @@ public class GeronimoServer extends Gero
     /*
      * (non-Javadoc)
      *
-     * @see org.apache.geronimo.st.core.IGeronimoServer#configureDeploymentManager(javax.enterprise.deploy.spi.DeploymentManager)
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#configureDeploymentManager(javax.enterprise.deploy.spi.DeploymentManager)
      */
     public void configureDeploymentManager(DeploymentManager dm) {
         ((JMXDeploymentManager) dm).setLogConfiguration(true, true);
@@ -157,7 +157,7 @@ public class GeronimoServer extends Gero
     /*
      * (non-Javadoc)
      *
-     * @see org.apache.geronimo.st.core.IGeronimoServer#getVersionHandler()
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#getVersionHandler()
      */
     public IGeronimoVersionHandler getVersionHandler() {
         if (versionHandler == null)
@@ -170,14 +170,14 @@ public class GeronimoServer extends Gero
     }
 
     /* (non-Javadoc)
-     * @see org.apache.geronimo.st.core.IGeronimoServer#isInPlace()
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#isInPlace()
      */
     public boolean isInPlaceSharedLib() {
         return getAttribute(PROPERTY_IN_PLACE_SHARED_LIB, false);
     }
 
     /* (non-Javadoc)
-     * @see org.apache.geronimo.st.core.IGeronimoServer#isRunFromWorkspace()
+     * @see org.apache.geronimo.st.v21.core.IGeronimoServer#isRunFromWorkspace()
      */
     public boolean isRunFromWorkspace() {
         return getAttribute(PROPERTY_RUN_FROM_WORKSPACE, false);

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviour.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviour.java?rev=952535&r1=952534&r2=952535&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviour.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviour.java Tue Jun  8 04:40:16 2010
@@ -33,9 +33,9 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.config.PersistentConfigurationList;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.st.core.Activator;
-import org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate;
-import org.apache.geronimo.st.core.internal.DependencyHelper;
+import org.apache.geronimo.st.v21.core.Activator;
+import org.apache.geronimo.st.v21.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v21.core.internal.DependencyHelper;
 import org.apache.geronimo.st.v21.core.internal.Trace;
 import org.apache.geronimo.system.jmx.KernelDelegate;
 import org.eclipse.core.runtime.IPath;
@@ -93,7 +93,7 @@ public class GeronimoServerBehaviour ext
 	/*
 	 * (non-Javadoc)
 	 * 
-	 * @see org.apache.geronimo.st.core.IGeronimoServerBehavior#isKernelAlive()
+	 * @see org.apache.geronimo.st.v21.core.IGeronimoServerBehavior#isKernelAlive()
 	 */
 	public boolean isKernelAlive() {
 		try {
@@ -150,7 +150,7 @@ public class GeronimoServerBehaviour ext
 	/*
 	 * (non-Javadoc)
 	 * 
-	 * @see org.apache.geronimo.st.core.IGeronimoServerBehavior#isFullyStarted()
+	 * @see org.apache.geronimo.st.v21.core.IGeronimoServerBehavior#isFullyStarted()
 	 */
 	public boolean isFullyStarted() {
 		if (isKernelAlive()) {

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviourDelegate.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviourDelegate.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/GeronimoServerBehaviourDelegate.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,986 @@
+/*
+ * 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.v21.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.v21.core.commands.DeploymentCmdStatus;
+import org.apache.geronimo.st.v21.core.commands.DeploymentCommandFactory;
+import org.apache.geronimo.st.v21.core.commands.IDeploymentCommand;
+import org.apache.geronimo.st.core.ClasspathContainersHelper;
+import org.apache.geronimo.st.core.GeronimoRuntimeDelegate;
+import org.apache.geronimo.st.core.ModuleArtifactMapper;
+import org.apache.geronimo.st.core.internal.Messages;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.apache.geronimo.st.core.operations.ISharedLibEntryCreationDataModelProperties;
+import org.apache.geronimo.st.v21.core.operations.SharedLibEntryCreationOperation;
+import org.apache.geronimo.st.v21.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: 824225 $ $Date: 2009-10-12 12:59:59 +0800 (Mon, 12 Oct 2009) $
+ */
+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 String getRuntimeClass() {
+		return "org.apache.geronimo.system.main.Daemon";
+	}
+
+	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>();
+		IPath serverJar = getServer().getRuntime().getLocation().append("/bin/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;
+	}
+	
+}