geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r405427 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/ org.apache.geronimo.st.v11.core/src/org/apache/ger...
Date Tue, 09 May 2006 13:27:35 GMT
Author: sppatel
Date: Tue May  9 06:27:33 2006
New Revision: 405427

URL: http://svn.apache.org/viewcvs?rev=405427&view=rev
Log:
handle updateserver state for multiple servers

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/UpdateServerStateTask.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoServerBehaviour.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/UpdateServerStateTask.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/UpdateServerStateTask.java?rev=405427&r1=405426&r2=405427&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/UpdateServerStateTask.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/UpdateServerStateTask.java
Tue May  9 06:27:33 2006
@@ -19,11 +19,13 @@
 
 import org.apache.geronimo.st.core.internal.Trace;
 import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
 import org.eclipse.wst.server.core.internal.Server;
 
 public class UpdateServerStateTask extends TimerTask {
 
 	private IGeronimoServerBehavior delegate;
+
 	private IServer server;
 
 	public UpdateServerStateTask(IGeronimoServerBehavior delegate,
@@ -42,30 +44,68 @@
 		synchronized (delegate) {
 			Trace.trace(Trace.INFO, "--> UpdateServerStateTask.run() "
 					+ server.getName());
-			try {
-				switch (server.getServerState()) {
-				case IServer.STATE_STOPPED:
-					if (delegate.isKernelAlive())
-						updateFromStopped();
-					break;
-				case IServer.STATE_STARTING:
-					if (delegate.isKernelAlive())
-						updateFromStarting();
-					else
-						delegate.setServerStopped();
-					break;
-				case IServer.STATE_STARTED:
-					updateFromStarted();
-					break;
+
+			// Only start the task if the connection URL is unqiue for all
+			// g-servers or if other servers that are different instances but do
+			// share the same connection URL's are stopped
+			IGeronimoServer thisServer = (IGeronimoServer) this.server
+					.loadAdapter(IGeronimoServer.class, null);
+
+			IServer[] allServers = ServerCore.getServers();
+			boolean allUnique = true;
+			boolean allNonUniqueStopped = true;
+			for (int i = 0; i < allServers.length; i++) {
+				IServer server = allServers[i];
+				IGeronimoServer gs = (IGeronimoServer) server.loadAdapter(
+						IGeronimoServer.class, null);
+				if (gs != null && !this.server.getId().equals(server.getId())) {
+					if (gs.getJMXServiceURL().equals(
+							thisServer.getJMXServiceURL())) {
+						allUnique = false;
+						if (!server.getRuntime().getLocation().equals(
+								this.server.getRuntime().getLocation())
+								&& server.getServerState() != IServer.STATE_STOPPED) {
+							allNonUniqueStopped = false;
+						}
+					}
 				}
-			} catch (Exception e) {
-				e.printStackTrace();
 			}
+
+			Trace.trace(Trace.INFO, "allUnique = " + allUnique
+					+ ", allNonUniqueStopped = " + allNonUniqueStopped);
+
+			if (allUnique || allNonUniqueStopped) {
+				Trace.trace(Trace.INFO, "updating state...");
+				updateServerState();
+			}
+
 			Trace.trace(Trace.INFO, "<-- UpdateServerStateTask.run() "
 					+ server.getName());
 		}
 	}
 
+	private void updateServerState() {
+		try {
+			switch (server.getServerState()) {
+			case IServer.STATE_STOPPED:
+				if (delegate.isKernelAlive())
+					updateFromStopped();
+				break;
+			case IServer.STATE_STARTING:
+				if (delegate.isKernelAlive())
+					updateFromStarting();
+				else
+					delegate.setServerStopped();
+				break;
+			case IServer.STATE_STARTED:
+				updateFromStarted();
+				break;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
 	private void updateFromStopped() {
 		if (isFullyStarted()) {
 			delegate.setServerStarted();
@@ -83,11 +123,13 @@
 		if (!isFullyStarted())
 			delegate.setServerStopped();
 	}
-	
+
 	private boolean isFullyStarted() {
 		ClassLoader old = Thread.currentThread().getContextClassLoader();
 		try {
-			Thread.currentThread().setContextClassLoader(((GenericGeronimoServerBehaviour) delegate).getContextClassLoader());
+			Thread.currentThread().setContextClassLoader(
+					((GenericGeronimoServerBehaviour) delegate)
+							.getContextClassLoader());
 			return delegate.isFullyStarted();
 		} finally {
 			Thread.currentThread().setContextClassLoader(old);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoServerBehaviour.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoServerBehaviour.java?rev=405427&r1=405426&r2=405427&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoServerBehaviour.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoServerBehaviour.java
Tue May  9 06:27:33 2006
@@ -89,7 +89,6 @@
 			map.put("jmx.remote.credentials", new String[] { user, password });
 			try {
 				String url = getGeronimoServer().getJMXServiceURL();
-				Trace.trace(Trace.INFO, "URL = " + url);
 				if (url == null)
 					return null;
 				JMXServiceURL address = new JMXServiceURL(url);
@@ -97,11 +96,11 @@
 					JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map);
 					MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection();
 					kernel = new KernelDelegate(mbServerConnection);
-					Trace.trace(Trace.INFO, "Connected to kernel.");
+					Trace.trace(Trace.INFO, "Connected to kernel: " + url);
 				} catch (SecurityException e) {
 					throw e;
 				} catch (Exception e) {
-					Trace.trace(Trace.WARNING, "Kernel connection failed.");
+					Trace.trace(Trace.WARNING, "Kernel connection failed." + url);
 				}
 			} catch (MalformedURLException e) {
 				e.printStackTrace();

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java?rev=405427&r1=405426&r2=405427&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java
Tue May  9 06:27:33 2006
@@ -98,7 +98,6 @@
 			map.put("jmx.remote.credentials", new String[] { user, password });
 			try {
 				String url = getGeronimoServer().getJMXServiceURL();
-				Trace.trace(Trace.INFO, "URL = " + url);
 				if (url == null)
 					return null;
 				JMXServiceURL address = new JMXServiceURL(url);
@@ -106,11 +105,11 @@
 					JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map);
 					MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection();
 					kernel = new KernelDelegate(mbServerConnection);
-					Trace.trace(Trace.INFO, "Connected to kernel.");
+					Trace.trace(Trace.INFO, "Connected to kernel." + url);
 				} catch (SecurityException e) {
 					throw e;
 				} catch (Exception e) {
-					Trace.trace(Trace.WARNING, "Kernel connection failed.");
+					Trace.trace(Trace.WARNING, "Kernel connection failed." + url);
 				}
 			} catch (MalformedURLException e) {
 				e.printStackTrace();



Mime
View raw message