geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r372086 - in /geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core: ./ commands/ internal/
Date Wed, 25 Jan 2006 03:37:15 GMT
Author: sppatel
Date: Tue Jan 24 19:37:08 2006
New Revision: 372086

URL: http://svn.apache.org/viewcvs?rev=372086&view=rev
Log:
- override setupLaunch to fix generic server remote host bug
- handle configuration already exists scenario

Modified:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/DeploymentUtils.java
    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/DeploymentCommandFactory.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/StopCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerBehaviour.java

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/DeploymentUtils.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/DeploymentUtils.java?rev=372086&r1=372085&r2=372086&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/DeploymentUtils.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/DeploymentUtils.java
Tue Jan 24 19:37:08 2006
@@ -17,7 +17,14 @@
 
 import java.io.File;
 
+import javax.enterprise.deploy.shared.ModuleType;
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.TargetException;
+
+import org.apache.geronimo.core.commands.TargetModuleIdNotFoundException;
 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.AppClientComponentExportDataModelProvider;
@@ -95,6 +102,42 @@
 					.createDataModel(new AppClientComponentExportDataModelProvider());
 		}
 		return null;
+	}
+
+	public static TargetModuleID getTargetModuleID(IModule module,
+			DeploymentManager dm) throws TargetModuleIdNotFoundException {
+
+		String configId = GeronimoUtils.getConfigId(module);
+		ModuleType moduleType = GeronimoUtils.getJSR88ModuleType(module);
+
+		try {
+			TargetModuleID ids[] = dm.getAvailableModules(moduleType, dm
+					.getTargets());
+			if (ids != null) {
+				for (int i = 0; i < ids.length; i++) {
+					if (ids[i].getModuleID().equals(configId)) {
+						return ids[i];
+					}
+				}
+			}
+		} catch (IllegalStateException e) {
+			e.printStackTrace();
+		} catch (TargetException e) {
+			e.printStackTrace();
+		}
+
+		throw new TargetModuleIdNotFoundException(
+				"Could not find TargetModuleID for module " + module.getName()
+						+ " with configId " + configId);
+	}
+
+	public static boolean configurationExists(IModule module,
+			DeploymentManager dm) {
+		try {
+			return getTargetModuleID(module, dm) != null;
+		} catch (TargetModuleIdNotFoundException e) {
+			return false;
+		}
 	}
 
 }

Modified: 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=372086&r1=372085&r2=372086&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/AbstractDeploymentCommand.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/AbstractDeploymentCommand.java
Tue Jan 24 19:37:08 2006
@@ -15,12 +15,8 @@
  */
 package org.apache.geronimo.core.commands;
 
-import javax.enterprise.deploy.shared.ModuleType;
 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.GeronimoUtils;
 import org.eclipse.wst.server.core.IModule;
 
 abstract class AbstractDeploymentCommand implements IDeploymentCommand {
@@ -42,31 +38,4 @@
 	public IModule getModule() {
 		return module;
 	}
-
-	public TargetModuleID getTargetModuleID(IModule module)
-			throws TargetModuleIdNotFoundException {
-
-		String configId = GeronimoUtils.getConfigId(module);
-		ModuleType moduleType = GeronimoUtils.getJSR88ModuleType(module);
-
-		try {
-			TargetModuleID ids[] = dm.getAvailableModules(moduleType, dm.getTargets());
-			if (ids != null) {
-				for (int i = 0; i < ids.length; i++) {
-					if (ids[i].getModuleID().equals(configId)) {
-						return ids[i];
-					}
-				}
-			}
-		} catch (IllegalStateException e) {
-			e.printStackTrace();
-		} catch (TargetException e) {
-			e.printStackTrace();
-		}
-
-		throw new TargetModuleIdNotFoundException(
-				"Could not find TargetModuleID for module " + module.getName()
-						+ " with configId " + configId);
-	}
-
 }

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DeploymentCommandFactory.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/DeploymentCommandFactory.java?rev=372086&r1=372085&r2=372086&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DeploymentCommandFactory.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/DeploymentCommandFactory.java
Tue Jan 24 19:37:08 2006
@@ -36,8 +36,6 @@
  */
 public class DeploymentCommandFactory {
 
-	private static final DeploymentCommandFactory INSTANCE = new DeploymentCommandFactory();
-
 	private DeploymentCommandFactory() {
 	}
 
@@ -47,10 +45,10 @@
 	 * @return
 	 * @throws CoreException
 	 */
-	public static IDeploymentCommand createDistributeCommand(
-			IModule module, IServer server) throws CoreException {
+	public static IDeploymentCommand createDistributeCommand(IModule module,
+			IServer server) throws CoreException {
 		return new SynchronizedDeploymentOp(new DistributeCommand(module,
-				INSTANCE.getDeploymentManager(server)));
+				getDeploymentManager(server)));
 	}
 
 	/**
@@ -60,11 +58,10 @@
 	 * @return
 	 * @throws CoreException
 	 */
-	public static IDeploymentCommand createStartCommand(
-			TargetModuleID[] ids, IModule module, IServer server)
-			throws CoreException {
+	public static IDeploymentCommand createStartCommand(TargetModuleID[] ids,
+			IModule module, IServer server) throws CoreException {
 		return new SynchronizedDeploymentOp(new StartCommand(ids, module,
-				INSTANCE.getDeploymentManager(server)));
+				getDeploymentManager(server)));
 	}
 
 	/**
@@ -75,8 +72,8 @@
 	 */
 	public static IDeploymentCommand createStopCommand(IModule module,
 			IServer server) throws CoreException {
-		return new SynchronizedDeploymentOp(new StopCommand(module, INSTANCE
-				.getDeploymentManager(server)));
+		return new SynchronizedDeploymentOp(new StopCommand(module,
+				getDeploymentManager(server)));
 	}
 
 	/**
@@ -85,10 +82,10 @@
 	 * @return
 	 * @throws CoreException
 	 */
-	public static IDeploymentCommand createRedeployCommand(
-			IModule module, IServer server) throws CoreException {
+	public static IDeploymentCommand createRedeployCommand(IModule module,
+			IServer server) throws CoreException {
 		return new SynchronizedDeploymentOp(new RedeployCommand(module,
-				INSTANCE.getDeploymentManager(server)));
+				getDeploymentManager(server)));
 	}
 
 	/**
@@ -97,10 +94,10 @@
 	 * @return
 	 * @throws CoreException
 	 */
-	public static IDeploymentCommand createUndeployCommand(
-			IModule module, IServer server) throws CoreException {
+	public static IDeploymentCommand createUndeployCommand(IModule module,
+			IServer server) throws CoreException {
 		return new SynchronizedDeploymentOp(new UndeployCommand(module,
-				INSTANCE.getDeploymentManager(server)));
+				getDeploymentManager(server)));
 	}
 
 	/**
@@ -108,7 +105,7 @@
 	 * @return
 	 * @throws CoreException
 	 */
-	private DeploymentManager getDeploymentManager(IServer server)
+	public static DeploymentManager getDeploymentManager(IServer server)
 			throws CoreException {
 		try {
 			return GeronimoConnectionFactory.getInstance()

Modified: 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=372086&r1=372085&r2=372086&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/RedeployCommand.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/RedeployCommand.java
Tue Jan 24 19:37:08 2006
@@ -41,7 +41,7 @@
 	public IStatus execute(IProgressMonitor monitor)
 			throws TargetModuleIdNotFoundException {
 		
-		TargetModuleID id = getTargetModuleID(getModule());
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getModule(), getDeploymentManager());
 		File jarFile = DeploymentUtils.createJarFile(getModule());
 		return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager()
 				.redeploy(new TargetModuleID[] { id }, jarFile, null));

Modified: 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=372086&r1=372085&r2=372086&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StopCommand.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/StopCommand.java
Tue Jan 24 19:37:08 2006
@@ -19,6 +19,7 @@
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
+import org.apache.geronimo.core.DeploymentUtils;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -38,7 +39,7 @@
 	public IStatus execute(IProgressMonitor monitor)
 			throws TargetModuleIdNotFoundException {
 
-		TargetModuleID id = getTargetModuleID(getModule());
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getModule(), getDeploymentManager());
 		return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager()
 				.stop(new TargetModuleID[] { id }));
 	}

Modified: 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=372086&r1=372085&r2=372086&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/UndeployCommand.java
Tue Jan 24 19:37:08 2006
@@ -19,6 +19,7 @@
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
+import org.apache.geronimo.core.DeploymentUtils;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -38,7 +39,7 @@
 	public IStatus execute(IProgressMonitor monitor)
 			throws TargetModuleIdNotFoundException {
 
-		TargetModuleID id = getTargetModuleID(getModule());
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getModule(), getDeploymentManager());
 		return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager()
 				.undeploy(new TargetModuleID[] { id }));
 	}

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=372086&r1=372085&r2=372086&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
Tue Jan 24 19:37:08 2006
@@ -16,13 +16,13 @@
 package org.apache.geronimo.core.internal;
 
 import java.net.MalformedURLException;
-import java.rmi.ConnectException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.Timer;
 
+import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
@@ -30,6 +30,7 @@
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 
+import org.apache.geronimo.core.DeploymentUtils;
 import org.apache.geronimo.core.GeronimoConnectionFactory;
 import org.apache.geronimo.core.commands.DeploymentCmdStatus;
 import org.apache.geronimo.core.commands.DeploymentCommandFactory;
@@ -45,14 +46,22 @@
 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.ILaunchConfigurationWorkingCopy;
 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jst.server.generic.core.internal.CorePlugin;
 import org.eclipse.jst.server.generic.core.internal.GenericServerBehaviour;
+import org.eclipse.jst.server.generic.core.internal.GenericServerCoreMessages;
+import org.eclipse.jst.server.generic.core.internal.PingThread;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerPort;
+import org.eclipse.wst.server.core.util.SocketUtil;
 
 public class GeronimoServerBehaviour extends GenericServerBehaviour {
 
+	private static final String ATTR_STOP = "stop-server";
+
 	private static final int MAX_TRIES = 30;
 
 	private static final int TIMER_TASK_INTERVAL = 10;
@@ -70,7 +79,7 @@
 	 * 
 	 * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#stop(boolean)
 	 */
-	public synchronized void stop(boolean force) {
+	public void stop(boolean force) {
 
 		Trace.trace(Trace.INFO, "--> stop()");
 
@@ -140,7 +149,7 @@
 	 * 
 	 * @see org.eclipse.jst.server.generic.core.internal.GenericServerBehaviour#setServerStarted()
 	 */
-	protected synchronized void setServerStarted() {
+	protected void setServerStarted() {
 		Trace.trace(Trace.INFO, "--> setServerStarted()");
 		for (int tries = MAX_TRIES; tries > 0; tries--) {
 			try {
@@ -162,7 +171,11 @@
 		try {
 			return getKernel() != null && kernel.isRunning();
 		} catch (Exception e) {
-			GeronimoPlugin.log(Status.WARNING, "Geronimo Server may have been terminated manually
outside of workspace.", e);
+			GeronimoPlugin
+					.log(
+							Status.WARNING,
+							"Geronimo Server may have been terminated manually outside of workspace.",
+							e);
 			kernel = null;
 		}
 		return false;
@@ -243,6 +256,23 @@
 		}
 	}
 
+	private void deploy(IModule module) throws Exception {
+		DeploymentManager dm = DeploymentCommandFactory
+				.getDeploymentManager(getServer());
+		if (!DeploymentUtils.configurationExists(module, dm)) {
+			doDeploy(module);
+		} else {
+			GeronimoPlugin
+					.log(
+							Status.WARNING,
+							"Configuration with id "
+									+ GeronimoUtils.getConfigId(module)
+									+ "already exists.  Existing configuration will be overwritten with redeploy.",
+							null);
+			doRedeploy(module);
+		}
+	}
+
 	private void doDeploy(IModule module) throws Exception {
 		Trace.trace(Trace.INFO, ">> doDeploy() " + module.toString());
 
@@ -360,6 +390,41 @@
 		}
 	}
 
+	protected void setupLaunch(ILaunch launch, String launchMode,
+			IProgressMonitor monitor) throws CoreException {
+		if ("true".equals(launch.getLaunchConfiguration().getAttribute(ATTR_STOP, "false"))) //$NON-NLS-1$
//$NON-NLS-2$
+			return;
+
+		String host = getServer().getHost();
+		ServerPort[] ports = getServer().getServerPorts(null);
+		ServerPort sp = null;
+		if (SocketUtil.isLocalhost(host)) {
+			for (int i = 0; i < ports.length; i++) {
+				sp = ports[i];
+				if (SocketUtil.isPortInUse(ports[i].getPort(), 5))
+					throw new CoreException(new Status(IStatus.ERROR,
+							CorePlugin.PLUGIN_ID, 0,
+							GenericServerCoreMessages.bind(
+									GenericServerCoreMessages.errorPortInUse,
+									Integer.toString(sp.getPort()), sp
+											.getName()), null));
+			}
+		}
+		setServerState(IServer.STATE_STARTING);
+		setMode(launchMode);
+
+		// ping server to check for startup
+		try {
+			String url = "http://" + host; //$NON-NLS-1$
+			int port = sp.getPort();
+			if (port != 80)
+				url += ":" + port; //$NON-NLS-1$
+			ping = new PingThread(getServer(), url, this);
+		} catch (Exception e) {
+			Trace.trace(Trace.SEVERE, "Can't ping for server startup."); //$NON-NLS-1$
+		}
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -368,8 +433,8 @@
 	protected void initialize(IProgressMonitor monitor) {
 		Trace.trace(Trace.INFO, "GeronimoServerBehavior.initialize()");
 		Timer timer = new Timer(true);
-		timer.schedule(new UpdateServerStateTask(this), 0,
-				TIMER_TASK_INTERVAL * 1000);
+		// timer.schedule(new UpdateServerStateTask(this), 0,
+		// TIMER_TASK_INTERVAL * 1000);
 	}
 
 }



Mime
View raw message