geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r398358 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.jmxagent/src/org/apache/geronimo/st/jmxagent/ org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/
Date Sun, 30 Apr 2006 15:41:06 GMT
Author: sppatel
Date: Sun Apr 30 08:41:04 2006
New Revision: 398358

URL: http://svn.apache.org/viewcvs?rev=398358&view=rev
Log:
install on startup

Added:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
  (with props)
Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.jmxagent/src/org/apache/geronimo/st/jmxagent/Activator.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ServerLifeCycleListener.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.jmxagent/src/org/apache/geronimo/st/jmxagent/Activator.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.jmxagent/src/org/apache/geronimo/st/jmxagent/Activator.java?rev=398358&r1=398357&r2=398358&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.jmxagent/src/org/apache/geronimo/st/jmxagent/Activator.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.jmxagent/src/org/apache/geronimo/st/jmxagent/Activator.java
Sun Apr 30 08:41:04 2006
@@ -27,6 +27,8 @@
 
 	// The plug-in ID
 	public static final String PLUGIN_ID = "org.apache.geronimo.st.jmxagent";
+	
+	public static final String SERVICE_ID = "default/eclipse-config-store/1.0/car";
 
 	// The shared instance
 	private static Activator plugin;

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.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/ConfigStoreInstaller.java?rev=398358&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
Sun Apr 30 08:41:04 2006
@@ -0,0 +1,83 @@
+package org.apache.geronimo.st.v11.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
+import org.apache.geronimo.st.core.GeronimoConnectionFactory;
+import org.apache.geronimo.st.jmxagent.Activator;
+import org.apache.geronimo.st.v11.core.internal.Trace;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerEvent;
+
+public class ConfigStoreInstaller implements IServerListener {
+
+	public void serverChanged(ServerEvent event) {
+		Trace.trace(Trace.INFO, "--> ConfigStoreInstaller.serverChanged()");
+		if (event.getKind() == (ServerEvent.SERVER_CHANGE | ServerEvent.STATE_CHANGE)) {
+			if (event.getServer().getServerState() == IServer.STATE_STARTED) {
+				install(event.getServer());
+			}
+		}
+		Trace.trace(Trace.INFO, "<-- ConfigStoreInstaller().serverChanged()");
+	}
+
+	private void install(IServer server) {
+		Trace.trace(Trace.INFO, "--> ConfigStoreInstaller.install()");
+		try {
+
+			GeronimoDeploymentManager dm = (GeronimoDeploymentManager) GeronimoConnectionFactory
+					.getInstance().getDeploymentManager(server);
+
+			Target target = dm.getTargets()[0];
+			Trace.trace(Trace.INFO, "target name: " + target.getName());
+
+			File jar = new File(resolveFromBundle(
+					"/lib/config-store-service-1.0-SNAPSHOT.jar").getFile());
+			File plan = new File(resolveFromBundle("/plan.xml").getFile());
+
+			ProgressObject po = dm.distribute(new Target[] { target }, jar,
+					plan);
+			waitForCompletion(po);
+
+			TargetModuleID id = new TargetModuleIDImpl(target,
+					Activator.SERVICE_ID);
+
+			po = dm.start(new TargetModuleID[] { id });
+			waitForCompletion(po);
+
+		} catch (DeploymentManagerCreationException e) {
+			e.printStackTrace();
+		}
+		Trace.trace(Trace.INFO, "--> ConfigStoreInstaller.install()");
+	}
+
+	private URL resolveFromBundle(String path) {
+		try {
+			return Platform.resolve(Activator.getDefault().getBundle()
+					.getEntry(path));
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	private void waitForCompletion(ProgressObject po) {
+		while (po.getDeploymentStatus().isRunning()) {
+			try {
+				Thread.sleep(100);
+			} catch (InterruptedException e) {
+
+			}
+		}
+	}
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
------------------------------------------------------------------------------
    svn:keywords = Date Rev

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.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/GeronimoServer.java?rev=398358&r1=398357&r2=398358&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServer.java
Sun Apr 30 08:41:04 2006
@@ -16,11 +16,13 @@
 package org.apache.geronimo.st.v11.core;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
 
 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
 import org.apache.geronimo.st.core.GenericGeronimoServer;
+import org.apache.geronimo.st.core.GeronimoConnectionFactory;
 import org.apache.geronimo.st.core.IGeronimoVersionHandler;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.wst.server.core.IModule;
@@ -92,10 +94,13 @@
 	 * @see org.apache.geronimo.st.core.IGeronimoServer#getJSR88DeployerJar()
 	 */
 	public IPath getJSR88DeployerJar() {
-		return getServer().getRuntime().getLocation().append("/lib/geronimo-deploy-jsr88-1.1-SNAPSHOT.jar");
+		return getServer().getRuntime().getLocation().append(
+				"/lib/geronimo-deploy-jsr88-1.1-SNAPSHOT.jar");
 	}
-	
-	/* (non-Javadoc)
+
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.apache.geronimo.st.core.IGeronimoServer#getDeploymentFactory()
 	 */
 	public DeploymentFactory getDeploymentFactory() {
@@ -109,7 +114,6 @@
 	 */
 	public void configureDeploymentManager(DeploymentManager dm) {
 		((JMXDeploymentManager) dm).setLogConfiguration(true, true);
-		((JMXDeploymentManager) dm).setInPlace(true);
 	}
 
 	/*
@@ -121,6 +125,16 @@
 		if (versionHandler == null)
 			versionHandler = new GeronimoV11VersionHandler();
 		return versionHandler;
+	}
+
+	public void setInPlaceDeployment(boolean enable) {
+		try {
+			JMXDeploymentManager mgr = (JMXDeploymentManager) GeronimoConnectionFactory
+					.getInstance().getDeploymentManager(getServer());
+			mgr.setInPlace(enable);
+		} catch (DeploymentManagerCreationException 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=398358&r1=398357&r2=398358&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
Sun Apr 30 08:41:04 2006
@@ -36,9 +36,13 @@
 import org.apache.geronimo.st.jmxagent.Activator;
 import org.apache.geronimo.st.v11.core.internal.Trace;
 import org.apache.geronimo.system.jmx.KernelDelegate;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunch;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.util.SocketUtil;
 
 public class GeronimoServerBehaviour extends GenericGeronimoServerBehaviour {
 
@@ -168,5 +172,13 @@
 	 */
 	public String getConfigId(IModule module) {
 		return GeronimoV11Utils.getConfigId(module);
+	}
+
+	protected void setupLaunch(ILaunch launch, String launchMode,
+			IProgressMonitor monitor) throws CoreException {
+		if (SocketUtil.isLocalhost(getServer().getHost())) {
+			getServer().addServerListener(new ConfigStoreInstaller());
+		}
+		super.setupLaunch(launch, launchMode, monitor);
 	}
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ServerLifeCycleListener.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/ServerLifeCycleListener.java?rev=398358&r1=398357&r2=398358&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ServerLifeCycleListener.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ServerLifeCycleListener.java
Sun Apr 30 08:41:04 2006
@@ -21,12 +21,14 @@
 
 import org.apache.geronimo.kernel.config.IOUtil;
 import org.apache.geronimo.st.jmxagent.Activator;
+import org.apache.geronimo.st.v11.core.internal.Trace;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.wst.server.core.IServer;
 
 import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.util.SocketUtil;
 
 public class ServerLifeCycleListener implements IServerLifecycleListener {
 
@@ -36,10 +38,8 @@
 	 * @see org.eclipse.wst.server.core.IServerLifecycleListener#serverAdded(org.eclipse.wst.server.core.IServer)
 	 */
 	public void serverAdded(IServer server) {
-		if (isSupportedServer(server)) {
-			copyToSharedLib(server, "hessian-3.0.8.jar");
-			copyToSharedLib(server, "mx4j-tools-3.0.1.jar");
-		}
+		Trace.trace(Trace.INFO, "--> ServerLifeCycleListener.serverAdded()");
+		copyJars(server);
 	}
 
 	/*
@@ -48,7 +48,8 @@
 	 * @see org.eclipse.wst.server.core.IServerLifecycleListener#serverChanged(org.eclipse.wst.server.core.IServer)
 	 */
 	public void serverChanged(IServer server) {
-
+		Trace.trace(Trace.INFO, "--> ServerLifeCycleListener.serverChanged()");
+		copyJars(server);
 	}
 
 	/*
@@ -70,6 +71,7 @@
 			try {
 				URL url = Platform.resolve(Activator.getDefault().getBundle()
 						.getEntry(path));
+				Trace.trace(Trace.INFO, "copying " + path + " to shared lib");
 				IOUtil.copyFile(new File(url.getFile()), destFile.toFile());
 			} catch (IOException e) {
 				e.printStackTrace();
@@ -78,6 +80,15 @@
 	}
 
 	private boolean isSupportedServer(IServer server) {
-		return server.getAdapter(GeronimoServer.class) != null;
+		return "1.1".equals(server.getServerType().getRuntimeType()
+				.getVersion())
+				&& SocketUtil.isLocalhost(server.getHost());
+	}
+
+	private void copyJars(IServer server) {
+		if (isSupportedServer(server)) {
+			copyToSharedLib(server, "lib/hessian-3.0.8.jar");
+			copyToSharedLib(server, "lib/mx4j-tools-3.0.1.jar");
+		}
 	}
 }



Mime
View raw message