geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r376051 - in /geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core: ./ internal/
Date Wed, 08 Feb 2006 20:26:19 GMT
Author: sppatel
Date: Wed Feb  8 12:26:02 2006
New Revision: 376051

URL: http://svn.apache.org/viewcvs?rev=376051&view=rev
Log:
handle server cleanup

Added:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerLifeCycleListener.java
  (with props)
Modified:
    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/internal/GeronimoPlugin.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/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=376051&r1=376050&r2=376051&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoConnectionFactory.java
(original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/GeronimoConnectionFactory.java
Wed Feb  8 12:26:02 2006
@@ -15,12 +15,14 @@
 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 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 final static String DEFAULT_URI =
+	// "deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";
 
 	private HashMap connections = new HashMap();
 
@@ -51,7 +53,7 @@
 			Trace.trace(Trace.INFO, "DeployerURL: " + deployerURL);
 			dm = mgr.getDeploymentManager(deployerURL, getUserName(server),
 					getPassword(server));
-			if(dm instanceof JMXDeploymentManager) {
+			if (dm instanceof JMXDeploymentManager) {
 				((JMXDeploymentManager) dm).setLogConfiguration(true, true);
 			}
 			connections.put(server.getId(), dm);
@@ -63,17 +65,22 @@
 	public void destroy(IServer server) {
 		connections.remove(server.getId());
 	}
-	
+
 	private String getDeployerURL(IServer server) {
-		//return "deployer:geronimo:jmx:rmi://" + server.getHost()  + "/jndi/rmi://" + server.getHost()
+ ":" + getRMINamingPort(server) + "/JMXConnector";
-		return "deployer:geronimo:jmx://" + server.getHost() + ":" + getRMINamingPort(server);
+		// return "deployer:geronimo:jmx:rmi://" + server.getHost() +
+		// "/jndi/rmi://" + server.getHost() + ":" + getRMINamingPort(server) +
+		// "/JMXConnector";
+		return "deployer:geronimo:jmx://" + server.getHost() + ":"
+				+ getRMINamingPort(server);
 	}
 
 	private DeploymentFactory discoverDeploymentFactory(IServer server) {
 
 		try {
-			
-			IPath path = server.getRuntime().getLocation().removeLastSegments(1).append("/lib/geronimo-deploy-jsr88-1.0.jar");
+
+			IPath path = server.getRuntime().getLocation()
+					.removeLastSegments(1).append(
+							"/lib/geronimo-deploy-jsr88-1.0.jar");
 
 			JarFile deployerJar = new JarFile(path.toFile());
 			java.util.jar.Manifest manifestFile = deployerJar.getManifest();
@@ -98,21 +105,28 @@
 	}
 
 	public String getUserName(IServer server) {
-		GeronimoServer gserver = (GeronimoServer) server
-				.getAdapter(GeronimoServer.class);
-		return gserver.getAdminID();
+		GeronimoServer gServer = getGeronimoServer(server);
+		return gServer.getAdminID();
 	}
 
 	public String getPassword(IServer server) {
-		GeronimoServer gserver = (GeronimoServer) server
-				.getAdapter(GeronimoServer.class);
-		return gserver.getAdminPassword();
+		GeronimoServer gServer = getGeronimoServer(server);
+		return gServer.getAdminPassword();
 	}
-	
+
 	public String getRMINamingPort(IServer server) {
-		GeronimoServer gserver = (GeronimoServer) server
+		GeronimoServer gServer = getGeronimoServer(server);
+		return gServer.getRMINamingPort();
+	}
+	
+	private GeronimoServer getGeronimoServer(IServer server) {
+		GeronimoServer gServer = (GeronimoServer) server
 				.getAdapter(GeronimoServer.class);
-		return gserver.getRMINamingPort();
+		if (gServer == null) {
+			gServer = (GeronimoServer) server.loadAdapter(GeronimoServer.class,
+					new NullProgressMonitor());
+		}
+		return gServer;
 	}
 
 }

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=376051&r1=376050&r2=376051&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
Wed Feb  8 12:26:02 2006
@@ -17,6 +17,11 @@
 
 import org.eclipse.core.runtime.Plugin;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.internal.ResourceManager;
+import org.eclipse.wst.server.core.internal.ServerListener;
+import org.eclipse.wst.server.core.util.ServerLifecycleAdapter;
+import org.osgi.framework.BundleContext;
 
 /**
  * The main plugin class.
@@ -25,6 +30,8 @@
 	public static final String PLUGIN_ID = "org.apache.geronimo.devtools.eclipse.core";
 
 	private static GeronimoPlugin singleton;
+	
+	private static final IServerLifecycleListener listener = new GeronimoServerLifeCycleListener();
 
 	/**
 	 * The constructor.
@@ -46,6 +53,22 @@
 	public static void log(int severity, String message, Throwable throwable) {
 		singleton.getLog().log(
 				new Status(severity, PLUGIN_ID, 0, message, throwable));
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		ResourceManager.getInstance().addServerLifecycleListener(listener);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		super.stop(context);
+		ResourceManager.getInstance().removeServerLifecycleListener(listener);
 	}
 
 }

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=376051&r1=376050&r2=376051&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
Wed Feb  8 12:26:02 2006
@@ -470,5 +470,12 @@
 		Trace.trace(Trace.INFO, "GeronimoServerBehavior.initialize()");
 		startUpdateServerStateTask();
 	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#dispose()
+	 */
+	public void dispose() {
+		stopUpdateServerStateTask();
+	}
 
 }

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerLifeCycleListener.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/GeronimoServerLifeCycleListener.java?rev=376051&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerLifeCycleListener.java
(added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerLifeCycleListener.java
Wed Feb  8 12:26:02 2006
@@ -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.internal;
+
+import org.apache.geronimo.core.GeronimoConnectionFactory;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+
+public class GeronimoServerLifeCycleListener implements
+		IServerLifecycleListener {
+
+	public GeronimoServerLifeCycleListener() {
+		super();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.wst.server.core.IServerLifecycleListener#serverAdded(org.eclipse.wst.server.core.IServer)
+	 */
+	public void serverAdded(IServer server) {
+		//do nothing
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.wst.server.core.IServerLifecycleListener#serverChanged(org.eclipse.wst.server.core.IServer)
+	 */
+	public void serverChanged(IServer server) {
+		Trace.trace(Trace.INFO, "GeronimoServerLifeCycleListener.serverChanged()");
+		GeronimoConnectionFactory.getInstance().destroy(server);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.wst.server.core.IServerLifecycleListener#serverRemoved(org.eclipse.wst.server.core.IServer)
+	 */
+	public void serverRemoved(IServer server) {
+		Trace.trace(Trace.INFO, "GeronimoServerLifeCycleListener.serverRemoved()");
+		GeronimoConnectionFactory.getInstance().destroy(server);
+	}
+
+}

Propchange: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerLifeCycleListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerLifeCycleListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.devtools.eclipse.core/src/org/apache/geronimo/core/internal/GeronimoServerLifeCycleListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message