geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r344151 - in /geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core: ./ commands/ internal/
Date Mon, 14 Nov 2005 16:13:56 GMT
Author: sppatel
Date: Mon Nov 14 08:13:46 2005
New Revision: 344151

URL: http://svn.apache.org/viewcvs?rev=344151&view=rev
Log:
rewrite a bunch of stuff

Added:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/CommandLauncher.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoConnectionFactory.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoPublisher.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/AbstractDeploymentCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DistributeCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/IDeploymentCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/RedeployCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StartCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StopCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java
Modified:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/DeploymentStatusMessageTranslator.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoPlugin.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.properties

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/CommandLauncher.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/CommandLauncher.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/CommandLauncher.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/CommandLauncher.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,128 @@
+package org.apache.geronimo.core;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.status.DeploymentStatus;
+import javax.enterprise.deploy.spi.status.ProgressEvent;
+import javax.enterprise.deploy.spi.status.ProgressListener;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.core.commands.AbstractDeploymentCommand;
+import org.apache.geronimo.core.commands.IDeploymentCommand;
+import org.apache.geronimo.core.internal.DeploymentStatusMessageTranslator;
+import org.apache.geronimo.core.internal.GeronimoPlugin;
+import org.apache.geronimo.core.internal.Messages;
+import org.apache.geronimo.core.internal.Trace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+public class CommandLauncher implements ProgressListener {
+
+	private static final long TIMEOUT = 10000;
+
+	private IDeploymentCommand command;
+
+	private IModule module;
+
+	private IServer server;
+
+	private Thread waitThread;
+
+	private IStatus status = null;
+
+	private TargetModuleID[] result;
+
+	private IProgressMonitor _monitor = null;
+
+	public CommandLauncher(IDeploymentCommand command, IModule module,
+			IServer server) {
+		super();
+		this.command = command;
+		this.module = module;
+		this.server = server;
+	}
+
+	public IStatus executeCommand(IProgressMonitor monitor)
+			throws CoreException {
+
+		if (monitor == null) {
+			monitor = new NullProgressMonitor();
+		}
+
+		_monitor = monitor;
+
+		try {
+			setDeploymentManager();
+		} catch (DeploymentManagerCreationException e) {
+			throw new CoreException(
+					new Status(IStatus.ERROR, GeronimoPlugin.PLUGIN_ID, 0,
+							Messages.DM_CONNECTION_FAIL, e));
+		}
+
+		waitThread = new WaitForNotificationThread();
+		waitThread.start();
+		ProgressObject po = command.execute(module);
+		po.addProgressListener(this);
+
+		try {
+			waitThread.join();
+		} catch (InterruptedException e) {
+		} finally {
+			po.removeProgressListener(this);
+		}
+
+		result = po.getResultTargetModuleIDs();
+
+		return status;
+	}
+
+	private void setDeploymentManager()
+			throws DeploymentManagerCreationException {
+		DeploymentManager mgr = GeronimoConnectionFactory.getInstance()
+				.getDeploymentManager(server);
+		((AbstractDeploymentCommand) command).setDeploymentManager(mgr);
+	}
+
+	class WaitForNotificationThread extends Thread {
+		public void run() {
+			try {
+				sleep(TIMEOUT);
+				Trace.trace(Trace.INFO, "Wait thread TIMEOUT!");
+			} catch (InterruptedException e) {
+				Trace.trace(Trace.INFO, "Wait thread interrupted");
+			}
+		}
+	}
+
+	public void handleProgressEvent(ProgressEvent event) {
+		DeploymentStatus deploymentStatus = event.getDeploymentStatus();
+		if (deploymentStatus != null) {
+			String msg = DeploymentStatusMessageTranslator
+					.getTranslatedMessage(event, module.getProject());
+			Trace.trace(Trace.INFO, msg);
+			_monitor.subTask(msg);
+			if (command.getCommandType() == deploymentStatus.getCommand()) {
+				if (deploymentStatus.isCompleted()) {
+					status = new Status(IStatus.OK, GeronimoPlugin.PLUGIN_ID,
+							0, msg, null);
+					waitThread.interrupt();
+				} else if (deploymentStatus.isFailed()) {
+					status = new Status(IStatus.ERROR,
+							GeronimoPlugin.PLUGIN_ID, 0, msg, null);
+					waitThread.interrupt();
+				}
+			}
+		}
+	}
+
+	public TargetModuleID[] getResultTargetModuleIDs() {
+		return result;
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoConnectionFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoConnectionFactory.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoConnectionFactory.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoConnectionFactory.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,99 @@
+package org.apache.geronimo.core;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+
+import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+
+import org.apache.geronimo.core.internal.GeronimoServer;
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.eclipse.wst.server.core.IServer;
+
+public class GeronimoConnectionFactory {
+
+	private final static String DEFAULT_URI = "deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";
+
+	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 {
+		DeploymentManager dm = (DeploymentManager) connections.get(server
+				.getId());
+
+		if (dm == null) {
+			DeploymentFactoryManager mgr = DeploymentFactoryManager
+					.getInstance();
+			DeploymentFactory factory = discoverDeploymentFactory(server);
+			if (factory == null) {
+				factory = new DeploymentFactoryImpl();
+			}
+			mgr.registerDeploymentFactory(factory);
+			dm = mgr.getDeploymentManager(DEFAULT_URI, getUserName(server),
+					getPassword(server));
+			connections.put(server.getId(), dm);
+		}
+
+		return dm;
+	}
+
+	public void destroy(IServer server) {
+		connections.remove(server.getId());
+	}
+
+	private DeploymentFactory discoverDeploymentFactory(IServer server) {
+
+		try {
+			JarFile deployerJar = new JarFile(server.getRuntime().getLocation()
+					.append("/deployer.jar").toFile());
+			java.util.jar.Manifest manifestFile = deployerJar.getManifest();
+			Attributes attributes = manifestFile.getMainAttributes();
+			String key = "J2EE-DeploymentFactory-Implementation-Class";
+			String className = attributes.getValue(key);
+			Class deploymentFactory = Class.forName(className);
+			DeploymentFactory df = (DeploymentFactory) deploymentFactory
+					.newInstance();
+			return df;
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ClassNotFoundException e) {
+			e.printStackTrace();
+		} catch (InstantiationException e) {
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+		}
+
+		return null;
+	}
+
+	public String getUserName(IServer server) {
+		GeronimoServer gserver = (GeronimoServer) server
+				.getAdapter(GeronimoServer.class);
+		return gserver.getAdminID();
+	}
+
+	public String getPassword(IServer server) {
+		GeronimoServer gserver = (GeronimoServer) server
+				.getAdapter(GeronimoServer.class);
+		return gserver.getAdminPassword();
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoPublisher.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoPublisher.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoPublisher.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoPublisher.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,23 @@
+package org.apache.geronimo.core;
+
+import org.eclipse.core.runtime.IStatus;
+
+public class GeronimoPublisher {
+
+	public GeronimoPublisher() {
+		super();
+	}
+	
+	public IStatus deploy() {
+		return  null;
+	}
+	
+	public IStatus redeploy() {
+		return null;
+	}
+	
+	public IStatus undeploy() {
+		return null;
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/AbstractDeploymentCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/AbstractDeploymentCommand.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/AbstractDeploymentCommand.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/AbstractDeploymentCommand.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,127 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.core.commands;
+
+import java.io.File;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.TargetException;
+
+import org.apache.geronimo.core.internal.GeronimoPlugin;
+import org.apache.geronimo.core.internal.GeronimoUtils;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IPath;
+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.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;
+
+public abstract class AbstractDeploymentCommand implements IDeploymentCommand {
+
+	DeploymentManager deploymentManager;
+
+	public AbstractDeploymentCommand() {
+		super();
+	}
+
+	public DeploymentManager getDeploymentManager() {
+		return deploymentManager;
+	}
+
+	public void setDeploymentManager(DeploymentManager deploymentManager) {
+		this.deploymentManager = deploymentManager;
+	}
+
+	public File createJarFile(IModule module) {
+		IDataModel model = getExportDataModel(module);
+
+		IVirtualComponent comp = ComponentCore.createComponent(module
+				.getProject());
+
+		IPath path = GeronimoPlugin.getInstance().getStateLocation();
+
+		model.setProperty(J2EEComponentExportDataModelProvider.PROJECT_NAME,
+				module.getProject());
+		model.setProperty(
+				J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION, path
+						.append(module.getName())
+						+ ".zip");
+		model.setProperty(J2EEComponentExportDataModelProvider.COMPONENT, comp);
+		model.setBooleanProperty(
+				J2EEComponentExportDataModelProvider.OVERWRITE_EXISTING, true);
+
+		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 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());
+		}
+		return null;
+	}
+
+	public TargetModuleID getTargetModuleID(IModule module) {
+		try {
+			TargetModuleID ids[] = getDeploymentManager().getAvailableModules(
+					GeronimoUtils.getJSR88ModuleType(module),
+					getDeploymentManager().getTargets());
+			if (ids != null) {
+				for (int i = 0; i < ids.length; i++) {
+					if (ids[i].getModuleID().equals(
+							GeronimoUtils.getConfigId(module))) {
+						return ids[i];
+					}
+				}
+			}
+		} catch (IllegalStateException e) {
+			e.printStackTrace();
+		} catch (TargetException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DistributeCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DistributeCommand.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DistributeCommand.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DistributeCommand.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.core.commands;
+
+import java.io.File;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.wst.server.core.IModule;
+
+public class DistributeCommand extends AbstractDeploymentCommand {
+
+	public DistributeCommand() {
+		super();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.wst.server.core.IModule)
+	 */
+	public ProgressObject execute(IModule module) {
+		Target[] targets = getDeploymentManager().getTargets();
+		File jarFile = createJarFile(module);
+		return getDeploymentManager().distribute(targets, jarFile, null);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.DISTRIBUTE;
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/IDeploymentCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/IDeploymentCommand.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/IDeploymentCommand.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/IDeploymentCommand.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.wst.server.core.IModule;
+
+public interface IDeploymentCommand {
+	
+	public ProgressObject execute(IModule module);
+	
+	public CommandType getCommandType();
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/RedeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/RedeployCommand.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/RedeployCommand.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/RedeployCommand.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.core.commands;
+
+import java.io.File;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.wst.server.core.IModule;
+
+public class RedeployCommand extends AbstractDeploymentCommand {
+
+	public RedeployCommand() {
+		super();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.wst.server.core.IModule)
+	 */
+	public ProgressObject execute(IModule module) {
+		TargetModuleID id = getTargetModuleID(module);
+		if (id != null) {
+			File jarFile = createJarFile(module);
+			return getDeploymentManager().redeploy(new TargetModuleID[] { id },
+					jarFile, null);
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.REDEPLOY;
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StartCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StartCommand.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StartCommand.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StartCommand.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.wst.server.core.IModule;
+
+public class StartCommand extends AbstractDeploymentCommand {
+	
+	TargetModuleID[] targetModuleIDs;
+
+	public StartCommand() {
+		super();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.wst.server.core.IModule)
+	 */
+	public ProgressObject execute(IModule module) {
+		return getDeploymentManager().start(getTargetModuleIDs());
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.START;
+	}
+
+	public TargetModuleID[] getTargetModuleIDs() {
+		return targetModuleIDs;
+	}
+
+	public void setTargetModuleIDs(TargetModuleID[] targetModuleIDs) {
+		this.targetModuleIDs = targetModuleIDs;
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StopCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StopCommand.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StopCommand.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StopCommand.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.wst.server.core.IModule;
+
+public class StopCommand extends AbstractDeploymentCommand {
+
+	public StopCommand() {
+		super();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.wst.server.core.IModule)
+	 */
+	public ProgressObject execute(IModule module) {
+		TargetModuleID id = getTargetModuleID(module);
+		if (id != null) {
+			return getDeploymentManager().stop(new TargetModuleID[] { id });
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.STOP;
+	}
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java?rev=344151&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java Mon Nov 14 08:13:46 2005
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.wst.server.core.IModule;
+
+public class UndeployCommand extends AbstractDeploymentCommand {
+
+	public UndeployCommand() {
+		super();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.wst.server.core.IModule)
+	 */
+	public ProgressObject execute(IModule module) {
+		TargetModuleID id = getTargetModuleID(module);
+		if (id != null) {
+			return getDeploymentManager().undeploy(new TargetModuleID[] { id });
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.UNDEPLOY;
+	}
+
+}

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/DeploymentStatusMessageTranslator.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/DeploymentStatusMessageTranslator.java?rev=344151&r1=344150&r2=344151&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/DeploymentStatusMessageTranslator.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/DeploymentStatusMessageTranslator.java Mon Nov 14 08:13:46 2005
@@ -57,6 +57,10 @@
 		if (type == CommandType.UNDEPLOY) {
 			return "Undeploying";
 		}
+		
+		if (type == CommandType.STOP) {
+			return "Stopping";
+		}
 
 		return "";
 	}

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoPlugin.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoPlugin.java?rev=344151&r1=344150&r2=344151&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoPlugin.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoPlugin.java Mon Nov 14 08:13:46 2005
@@ -21,7 +21,7 @@
  * The main plugin class.
  */
 public class GeronimoPlugin extends Plugin {
-    protected static final String PLUGIN_ID = "org.apache.geronimo.devtools.eclipse.core";
+    public static final String PLUGIN_ID = "org.apache.geronimo.devtools.eclipse.core";
 
     private static GeronimoPlugin singleton;
 

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java?rev=344151&r1=344150&r2=344151&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java Mon Nov 14 08:13:46 2005
@@ -15,75 +15,43 @@
  */
 package org.apache.geronimo.core.internal;
 
-import java.io.File;
-import java.io.IOException;
 import java.net.MalformedURLException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
 
-import javax.enterprise.deploy.shared.CommandType;
-import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
-import javax.enterprise.deploy.spi.DeploymentManager;
-import javax.enterprise.deploy.spi.Target;
-import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
-import javax.enterprise.deploy.spi.exceptions.TargetException;
-import javax.enterprise.deploy.spi.factories.DeploymentFactory;
-import javax.enterprise.deploy.spi.status.DeploymentStatus;
-import javax.enterprise.deploy.spi.status.ProgressEvent;
-import javax.enterprise.deploy.spi.status.ProgressListener;
-import javax.enterprise.deploy.spi.status.ProgressObject;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 
-import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.geronimo.core.CommandLauncher;
+import org.apache.geronimo.core.GeronimoConnectionFactory;
+import org.apache.geronimo.core.commands.DistributeCommand;
+import org.apache.geronimo.core.commands.RedeployCommand;
+import org.apache.geronimo.core.commands.StartCommand;
+import org.apache.geronimo.core.commands.StopCommand;
+import org.apache.geronimo.core.commands.UndeployCommand;
 import org.apache.geronimo.gbean.GBeanQuery;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.NoSuchAttributeException;
 import org.apache.geronimo.kernel.config.PersistentConfigurationList;
 import org.apache.geronimo.kernel.jmx.KernelDelegate;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
 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.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.generic.core.internal.GenericServerBehaviour;
-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;
 
 public class GeronimoServerBehaviour extends GenericServerBehaviour {
 
-	private final static String DEFAULT_URI = "deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";
-
-	private final static String J2EE_DEPLOYER_ID = "org/apache/geronimo/RuntimeDeployer";
-
 	private static final int MAX_TRIES = 15;
 
-	private static final long TIMEOUT = 10000;
-
-	private DeploymentFactoryManager dfm = null;
-
-	private DeploymentManager dm = null;
-
 	private IProgressMonitor _monitor = null;
 
 	private Kernel kernel = null;
@@ -92,60 +60,6 @@
 		super();
 	}
 
-	private void discoverDeploymentFactory() {
-
-		try {
-			JarFile deployerJar = new JarFile(getServer().getRuntime()
-					.getLocation().append("/deployer.jar").toFile());
-			java.util.jar.Manifest manifestFile = deployerJar.getManifest();
-			Attributes attributes = manifestFile.getMainAttributes();
-			String key = "J2EE-DeploymentFactory-Implementation-Class";
-			String className = attributes.getValue(key);
-			dfm = DeploymentFactoryManager.getInstance();
-			Class deploymentFactory = Class.forName(className);
-			DeploymentFactory deploymentFactoryInstance = (DeploymentFactory) deploymentFactory
-					.newInstance();
-			dfm.registerDeploymentFactory(deploymentFactoryInstance);
-		} catch (IOException e) {
-			e.printStackTrace();
-		} catch (ClassNotFoundException e) {
-			e.printStackTrace();
-		} catch (InstantiationException e) {
-			e.printStackTrace();
-		} catch (IllegalAccessException e) {
-			e.printStackTrace();
-		}
-	}
-
-	public DeploymentManager getDeploymentManager()
-			throws DeploymentManagerCreationException {
-
-		if (dm == null) {
-			discoverDeploymentFactory();
-			if (dfm != null) {
-				dm = dfm.getDeploymentManager(DEFAULT_URI, getUserName(),
-						getPassword());
-			} else {
-				DeploymentFactory df = new DeploymentFactoryImpl();
-				dm = df.getDeploymentManager(DEFAULT_URI, getUserName(),
-						getPassword());
-			}
-		}
-		return dm;
-	}
-
-	private String getUserName() {
-		GeronimoServer server = (GeronimoServer) getServer().getAdapter(
-				GeronimoServer.class);
-		return server.getAdminID();
-	}
-
-	private String getPassword() {
-		GeronimoServer server = (GeronimoServer) getServer().getAdapter(
-				GeronimoServer.class);
-		return server.getAdminPassword();
-	}
-
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -159,7 +73,7 @@
 			kernel.shutdown();
 		}
 
-		dm = null;
+		GeronimoConnectionFactory.getInstance().destroy(getServer());
 		kernel = null;
 
 		// kill the process
@@ -245,26 +159,6 @@
 				Trace.trace(Trace.INFO, "configList is Empty");
 			}
 		}
-
-		/*
-		 * try { ObjectName configName = Configuration
-		 * .getConfigurationObjectName(new URI(J2EE_DEPLOYER_ID));
-		 * 
-		 * for (int tries = MAX_TRIES; tries > 0 && !started; tries--) { try {
-		 * if (getKernel() != null) { if (kernel.getGBeanState(configName) == 1) {
-		 * started = true; setServerState(IServer.STATE_STARTED);
-		 * Trace.trace(Trace.INFO, "RuntimeDeployer has started."); } else {
-		 * Trace.trace(Trace.INFO, "RuntimeDeployer has not yet started."); } } }
-		 * catch (InternalKernelException e) { } catch (GBeanNotFoundException
-		 * e) { } Thread.sleep(2000); } } catch (MalformedObjectNameException e) {
-		 * e.printStackTrace(); } catch (URISyntaxException e) {
-		 * e.printStackTrace(); } catch (InterruptedException e) {
-		 * e.printStackTrace(); }
-		 * 
-		 * if (!started) { Trace.trace(Trace.SEVERE, "Runtime deployer failed to
-		 * start."); }
-		 */
-
 	}
 
 	/*
@@ -293,86 +187,6 @@
 		}
 	}
 
-	class WaitForNotificationThread extends Thread {
-		public void run() {
-			try {
-				sleep(TIMEOUT);
-				Trace.trace(Trace.INFO, "Wait thread TIMEOUT!");
-			} catch (InterruptedException e) {
-				Trace.trace(Trace.INFO, "Wait thread interrupted");
-			}
-		}
-	}
-
-	class GeronimoDeploymentProgressListener implements ProgressListener {
-
-		private Thread waitThread;
-
-		private CommandType cmd = null;
-
-		private IProject project = null;
-
-		public String lastMessage = null;
-
-		public GeronimoDeploymentProgressListener() {
-			waitThread = new WaitForNotificationThread();
-		}
-
-		public void handleProgressEvent(ProgressEvent event) {
-			String message = DeploymentStatusMessageTranslator
-					.getTranslatedMessage(event, project);
-			if (!message.equals(lastMessage)) {
-				_monitor.setTaskName(message);
-				Trace.trace(Trace.INFO, message);
-			}
-			lastMessage = message;
-			DeploymentStatus status = event.getDeploymentStatus();
-			if (status.getMessage() != null) {
-				Trace.trace(Trace.INFO, "\t" + status.getMessage());
-				_monitor.subTask(status.getMessage());
-			}
-
-			if (cmd == null || cmd == status.getCommand()) {
-				if (status.isCompleted() || status.isFailed()) {
-					waitThread.interrupt();
-				}
-			}
-		}
-
-		public void start() {
-			waitThread.start();
-		}
-
-		public void setType(CommandType cmd) {
-			this.cmd = cmd;
-		}
-
-		public Thread getWaitThread() {
-			return waitThread;
-		}
-
-		public void setProject(IProject project) {
-			this.project = project;
-		}
-	}
-
-	private void waitForCompletion(ProgressObject po,
-			GeronimoDeploymentProgressListener listener, CommandType cmd,
-			IProject project) {
-
-		listener.setType(cmd);
-		listener.setProject(project);
-
-		po.addProgressListener(listener);
-
-		try {
-			listener.getWaitThread().join();
-		} catch (InterruptedException e) {
-		} finally {
-			po.removeProgressListener(listener);
-		}
-	}
-
 	private void invokeCommand(int deltaKind, IModule module)
 			throws CoreException {
 
@@ -405,196 +219,68 @@
 		}
 	}
 
-	private void doDeploy(IModule module) throws CoreException,
-			DeploymentManagerCreationException {
-
-		Target[] targets = getDeploymentManager().getTargets();
-		GeronimoDeploymentProgressListener listener = createAndStartListener();
-		File jarFile = createJarFile(module);
-		ProgressObject po = getDeploymentManager().distribute(targets, jarFile,
-				null);
-		waitForCompletion(po, listener, CommandType.DISTRIBUTE, module
-				.getProject());
-
-		if (po.getDeploymentStatus().isCompleted()) {
-			listener = createAndStartListener();
-			po = getDeploymentManager().start(po.getResultTargetModuleIDs());
-			waitForCompletion(po, listener, CommandType.START, module
-					.getProject());
-			if (po.getDeploymentStatus().isCompleted()) {
-				// TODO
-			} else if (po.getDeploymentStatus().isFailed()) {
-				// TODO
-			}
-		} else if (po.getDeploymentStatus().isFailed()) {
-			IStatus status = new Status(
-					IStatus.ERROR,
-					GeronimoPlugin.PLUGIN_ID,
-					0,
-					"Distribution of application failed.  See .log for details.",
-					new Exception(listener.lastMessage));
-			throw new CoreException(status);
+	private void doDeploy(IModule module) throws CoreException {
+		CommandLauncher launcher = new CommandLauncher(new DistributeCommand(),
+				module, getServer());
+		IStatus status = launcher.executeCommand(_monitor);
+		
+		if(!status.isOK()) {
+			doFail(status, Messages.DISTRIBUTE_FAIL);
+		}
+		
+		StartCommand startCmd = new StartCommand();
+		startCmd.setTargetModuleIDs(launcher.getResultTargetModuleIDs());
+		launcher = new CommandLauncher(startCmd, module, getServer());
+		status = launcher.executeCommand(_monitor);
+		if(!status.isOK()) {
+			doFail(status, Messages.START_FAIL);
 		}
 	}
 
-	private void doRedeploy(IModule module) throws CoreException,
-			DeploymentManagerCreationException {
-
-		TargetModuleID id = getTargetModuleID(module);
-		if (id != null) {
-			File jarFile = createJarFile(module);
-			GeronimoDeploymentProgressListener listener = createAndStartListener();
-			ProgressObject po = getDeploymentManager().redeploy(
-					new TargetModuleID[] { id }, jarFile, null);
-			waitForCompletion(po, listener, CommandType.REDEPLOY, module
-					.getProject());
-			if (po.getDeploymentStatus().isCompleted()) {
-				// TODO
-			} else if (po.getDeploymentStatus().isFailed()) {
-				// TODO
-			}
+	private void doRedeploy(IModule module) throws CoreException {
+		CommandLauncher launcher = new CommandLauncher(new RedeployCommand(),
+				module, getServer());
+		IStatus status = launcher.executeCommand(_monitor);
+		if (!status.isOK()) {
+			doFail(status, Messages.REDEPLOY_FAIL);
 		}
 	}
 
 	private void doUndeploy(IModule module) throws CoreException,
 			DeploymentManagerCreationException {
-		TargetModuleID id = getTargetModuleID(module);
-		if (id != null) {
-			GeronimoDeploymentProgressListener listener = createAndStartListener();
-			ProgressObject po = getDeploymentManager().undeploy(
-					new TargetModuleID[] { id });
-			waitForCompletion(po, listener, CommandType.UNDEPLOY, module
-					.getProject());
-			if (po.getDeploymentStatus().isCompleted()) {
-				// TODO
-			} else if (po.getDeploymentStatus().isFailed()) {
-				// TODO
-			}
-		}
-	}
+		CommandLauncher launcher = new CommandLauncher(new StopCommand(),
+				module, getServer());
+		IStatus status = launcher.executeCommand(_monitor);
 
-	private GeronimoDeploymentProgressListener createAndStartListener() {
-		GeronimoDeploymentProgressListener listener = new GeronimoDeploymentProgressListener();
-		listener.start();
-		return listener;
-	}
-
-	// TODO find a better way to get TargetModuleID for IModule
-	private TargetModuleID getTargetModuleID(IModule module)
-			throws DeploymentManagerCreationException {
-		try {
-			TargetModuleID ids[] = getDeploymentManager().getAvailableModules(
-					GeronimoUtils.getJSR88ModuleType(module),
-					getDeploymentManager().getTargets());
-			if (ids != null) {
-				for (int i = 0; i < ids.length; i++) {
-					if (ids[i].getModuleID().equals(
-							GeronimoUtils.getConfigId(module))) {
-						return ids[i];
-					}
-				}
-			}
-		} catch (IllegalStateException e) {
-			e.printStackTrace();
-		} catch (TargetException e) {
-			e.printStackTrace();
+		if (!status.isOK()) {
+			doFail(status, Messages.STOP_FAIL);
 		}
-		return null;
-	}
-
-	private File createJarFile(IModule module) {
-		IDataModel model = getExportDataModel(module);
 
-		IVirtualComponent comp = ComponentCore.createComponent(module
-				.getProject());
-
-		IPath path = GeronimoPlugin.getInstance().getStateLocation();
-
-		model.setProperty(J2EEComponentExportDataModelProvider.PROJECT_NAME,
-				module.getProject());
-		model.setProperty(
-				J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION, path
-						.append(module.getName())
-						+ ".zip");
-		model.setProperty(J2EEComponentExportDataModelProvider.COMPONENT, comp);
-		model.setBooleanProperty(
-				J2EEComponentExportDataModelProvider.OVERWRITE_EXISTING, true);
-
-		if (model != null) {
-			try {
-				model.getDefaultOperation().execute(_monitor, null);
-				return new File(
-						model
-								.getStringProperty(J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION));
-			} catch (ExecutionException e) {
-				e.printStackTrace();
-			}
+		launcher = new CommandLauncher(new UndeployCommand(), module,
+				getServer());
+		status = launcher.executeCommand(_monitor);
+		
+		if (!status.isOK()) {
+			doFail(status, Messages.UNDEPLOY_FAIL);
 		}
-
-		return null;
 	}
 
-	private 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());
-		}
-		return null;
+	private void doFail(IStatus status, String message) throws CoreException {
+		throw new CoreException(new Status(IStatus.ERROR,
+				GeronimoPlugin.PLUGIN_ID, 0, message, new Exception(status
+						.getMessage())));
 	}
 
-	/*
-	 * private File createJarFile2(IModule module) { J2EEFlexProjDeployable
-	 * j2eeModule = (J2EEFlexProjDeployable) module
-	 * .loadAdapter(J2EEFlexProjDeployable.class, null);
-	 * 
-	 * Path path = new Path(j2eeModule.getURI(module));
-	 * 
-	 * try { File rootDir = new File(path.toOSString()); String zipFilePrefix =
-	 * rootDir.getName(); if (zipFilePrefix.length() < 3) zipFilePrefix +=
-	 * "123"; File zipFile = File.createTempFile(zipFilePrefix, null);
-	 * 
-	 * if (zipFile.exists()) zipFile.delete();
-	 * 
-	 * FileOutputStream fos = new FileOutputStream(zipFile); JarOutputStream jos =
-	 * new JarOutputStream(fos);
-	 * 
-	 * addToJar("", rootDir, jos);
-	 * 
-	 * jos.close(); fos.close();
-	 * 
-	 * zipFile.deleteOnExit();
-	 * 
-	 * return zipFile;
-	 *  } catch (IOException e) { Trace.trace(Trace.SEVERE, "Error creating zip
-	 * file", e); return null; } }
-	 */
-
-	/*
-	 * private void addToJar(String namePrefix, File dir, JarOutputStream jos)
-	 * throws IOException { File[] contents = dir.listFiles(); for (int i = 0; i <
-	 * contents.length; i++) { File f = contents[i]; if (f.isDirectory()) { //
-	 * Recurse into the directory addToJar(namePrefix + f.getName() + "/", f,
-	 * jos); } else { JarEntry entry = new JarEntry(namePrefix + f.getName());
-	 * jos.putNextEntry(entry);
-	 * 
-	 * byte[] buffer = new byte[10000]; FileInputStream fis = new
-	 * FileInputStream(f); int bytesRead = 0; while (bytesRead != -1) {
-	 * bytesRead = fis.read(buffer); if (bytesRead > 0) jos.write(buffer, 0,
-	 * bytesRead); } } } }
-	 */
-
 	public Map getServerInstanceProperties() {
 		return getRuntimeDelegate().getServerInstanceProperties();
+	}
+
+	public String getUserName() {
+		return GeronimoConnectionFactory.getInstance().getUserName(getServer());
+	}
+
+	public String getPassword() {
+		return GeronimoConnectionFactory.getInstance().getPassword(getServer());
 	}
 
 }

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java?rev=344151&r1=344150&r2=344151&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoUtils.java Mon Nov 14 08:13:46 2005
@@ -62,23 +62,23 @@
 
         if (isWebModule(module)) {
             WebAppType plan = getWebDeploymentPlan(module);
-            if (plan.eIsSet(WebPackage.eINSTANCE.getWebAppType_ConfigId())) {
+            if (plan != null && plan.eIsSet(WebPackage.eINSTANCE.getWebAppType_ConfigId())) {
                 return plan.getConfigId();
             }
         } else if (isEjbJarModule(module)) {
             OpenejbJarType plan = getOpenEjbDeploymentPlan(module);
-            if (plan.eIsSet(JarPackage.eINSTANCE.getOpenejbJarType_ConfigId())) {
+            if (plan != null && plan.eIsSet(JarPackage.eINSTANCE.getOpenejbJarType_ConfigId())) {
                 return plan.getConfigId();
             }
         } else if (isEarModule(module)) {
             ApplicationType plan = getApplicationDeploymentPlan(module);
-            if (plan.eIsSet(ApplicationPackage.eINSTANCE
+            if (plan != null && plan.eIsSet(ApplicationPackage.eINSTANCE
                     .getApplicationType_ConfigId())) {
                 return plan.getConfigId();
             }
         } else if (isRARModule(module)) {
             ConnectorType plan = getConnectorDeploymentPlan(module);
-            if (plan.eIsSet(ConnectorPackage.eINSTANCE
+            if (plan != null && plan.eIsSet(ConnectorPackage.eINSTANCE
                     .getConnectorType_ConfigId())) {
                 return plan.getConfigId();
             }

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.java?rev=344151&r1=344150&r2=344151&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.java Mon Nov 14 08:13:46 2005
@@ -20,7 +20,16 @@
  * Translated messages.
  */
 public class Messages extends NLS {
+	
 	static {
 		NLS.initializeMessages(GeronimoPlugin.PLUGIN_ID + ".internal.Messages", Messages.class);
 	}
+	
+	public static String DISTRIBUTE_FAIL;
+	public static String START_FAIL;
+	public static String STOP_FAIL;
+	public static String UNDEPLOY_FAIL;
+	public static String REDEPLOY_FAIL;
+	public static String DM_CONNECTION_FAIL;
+	
 }

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.properties
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.properties?rev=344151&r1=344150&r2=344151&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.properties (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/Messages.properties Mon Nov 14 08:13:46 2005
@@ -1 +1,6 @@
-
+DISTRIBUTE_FAIL=Distribution of configuration failed.  See .log for details.
+START_FAIL=Starting of configuration failed.  See .log for details.
+STOP_FAIL=Stopping of configuration failed.  See .log for details.
+UNDEPLOY_FAIL=Undeploy of configuration failed.  See .log for details.
+REDEPLOY_FAIL=Redeploy of configuration failed.  See .log for details.
+DM_CONNECTION_FAIL=Connection to deployment manager failed.  See .log for details.
\ No newline at end of file



Mime
View raw message