geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r359948 - in /geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core: commands/SynchronizedDeploymentOp.java internal/GeronimoServerBehaviour.java
Date Fri, 30 Dec 2005 00:29:27 GMT
Author: sppatel
Date: Thu Dec 29 16:29:23 2005
New Revision: 359948

URL: http://svn.apache.org/viewcvs?rev=359948&view=rev
Log:
update server state timer task, synced deployment op updates

Modified:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/SynchronizedDeploymentOp.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/commands/SynchronizedDeploymentOp.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/SynchronizedDeploymentOp.java?rev=359948&r1=359947&r2=359948&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/SynchronizedDeploymentOp.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/commands/SynchronizedDeploymentOp.java
Thu Dec 29 16:29:23 2005
@@ -32,7 +32,7 @@
 
 /**
  * This class is a wrapper IDeploymentCommand that when executed blocks the
- * callee's thread until completed, either when its waiting thread times out, or
+ * callee's thread until completed, either when the waiting thread times out, or
  * a failed or completed notification is recieved from the DeploymentManager.
  */
 public class SynchronizedDeploymentOp implements ProgressListener,
@@ -42,12 +42,12 @@
 
 	private IDeploymentCommand command;
 
-	private Thread waitThread;
-
 	private IStatus status = null;
 
 	private IProgressMonitor _monitor = null;
 
+	private boolean timedOut = true;
+
 	public SynchronizedDeploymentOp(IDeploymentCommand command) {
 		super();
 		this.command = command;
@@ -59,48 +59,48 @@
 	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
 	 */
 	public IStatus execute(IProgressMonitor monitor) {
-
+		
 		_monitor = monitor;
 
 		if (_monitor == null) {
 			_monitor = new NullProgressMonitor();
 		}
 
-		waitThread = new WaitForNotificationThread();
-		waitThread.start();
+		ProgressObject po = run();
+
+		return new DeploymentCmdStatus(status, po);
+	}
+	
+	private synchronized ProgressObject run() {
+		Trace.trace(Trace.INFO, "--> run()");
 
 		IStatus ds = command.execute(_monitor);
 
 		ProgressObject po = null;
-
+		
 		if (ds instanceof DeploymentCmdStatus) {
-
 			po = ((DeploymentCmdStatus) ds).getProgressObject();
-
 			po.addProgressListener(this);
-
+			
 			try {
-				waitThread.join();
+				wait(TIMEOUT);
 			} catch (InterruptedException e) {
-			} finally {
-				po.removeProgressListener(this);
 			}
-
+			
+			po.removeProgressListener(this);
+			if (timedOut) {
+				Trace.trace(Trace.SEVERE, "Command Timed Out!");
+			}
 		}
-
-		return new DeploymentCmdStatus(status, po);
-
+		
+		Trace.trace(Trace.INFO, "<-- run()");
+		return po;
 	}
 
-	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");
-			}
-		}
+	private synchronized void sendNotification() {
+		timedOut = false;
+		Trace.trace(Trace.INFO, "notifyAll()");
+		notifyAll();
 	}
 
 	/*
@@ -119,11 +119,11 @@
 				if (deploymentStatus.isCompleted()) {
 					status = new Status(IStatus.OK, GeronimoPlugin.PLUGIN_ID,
 							0, dsm.getMessage(), null);
-					waitThread.interrupt();
+					sendNotification();
 				} else if (deploymentStatus.isFailed()) {
 					status = new Status(IStatus.ERROR,
 							GeronimoPlugin.PLUGIN_ID, 0, dsm.getMessage(), null);
-					waitThread.interrupt();
+					sendNotification();
 				}
 			}
 		}

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=359948&r1=359947&r2=359948&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
Thu Dec 29 16:29:23 2005
@@ -20,6 +20,8 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
 
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.management.MBeanServerConnection;
@@ -56,8 +58,12 @@
 
 	private Kernel kernel = null;
 
+	private Timer timer;
+
 	public GeronimoServerBehaviour() {
 		super();
+		timer = new Timer();
+		//timer.schedule(new UpdateServerStateTask(), 0, 60000);
 	}
 
 	/*
@@ -175,11 +181,6 @@
 		return false;
 	}
 
-	private boolean isRuntimeDeployerRunning() {
-		// TODO Implement Me
-		return true;
-	}
-
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -202,8 +203,6 @@
 
 	private void invokeCommand(int deltaKind, IModule module)
 			throws CoreException {
-		Trace.trace(Trace.INFO, ">> invokeCommand()");
-
 		switch (deltaKind) {
 		case ADDED: {
 			doDeploy(module);
@@ -220,8 +219,6 @@
 		default:
 			throw new IllegalArgumentException();
 		}
-
-		Trace.trace(Trace.INFO, "<< invokeCommand()");
 	}
 
 	private void doDeploy(IModule module) throws CoreException {
@@ -330,6 +327,31 @@
 			workingCopy.setAttribute(
 					IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
 					existingPrgArgs);
+		}
+	}
+
+	private class UpdateServerStateTask extends TimerTask {
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see java.lang.Runnable#run()
+		 */
+		public void run() {
+			int currentState = getServer().getServerState();
+			if (currentState == IServer.STATE_STARTED) {
+				if(!isKernelAlive()) {
+					setServerState(IServer.STATE_STOPPED);
+				}
+			} else if (currentState == IServer.STATE_STOPPED) {
+				if (isKernelAlive()) {
+					if (isKernelFullyStarted()) {
+						setServerState(IServer.STATE_STARTED);
+					} else {
+						setServerState(IServer.STATE_STARTING);
+					}
+				}
+			}
 		}
 	}
 



Mime
View raw message