geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r409237 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/
Date Wed, 24 May 2006 20:07:10 GMT
Author: sppatel
Date: Wed May 24 13:07:10 2006
New Revision: 409237

URL: http://svn.apache.org/viewvc?rev=409237&view=rev
Log:
BUG FIX: update server state task incorrect for updateFromStarting /  fix configStore install

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.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.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/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/UpdateServerStateTask.java?rev=409237&r1=409236&r2=409237&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
Wed May 24 13:07:10 2006
@@ -116,7 +116,7 @@
 
 	private void updateFromStarting() {
 		if (isFullyStarted())
-			delegate.setServerStopped();
+			delegate.setServerStarted();
 	}
 
 	private void updateFromStarted() {

Modified: 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/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java?rev=409237&r1=409236&r2=409237&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/ConfigStoreInstaller.java
Wed May 24 13:07:10 2006
@@ -6,14 +6,20 @@
 
 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.TargetModuleIDImpl;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.IOUtil;
+import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.kernel.repository.Artifact;
 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.IPath;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.IServerListener;
@@ -25,6 +31,7 @@
 		if (event.getKind() == (ServerEvent.SERVER_CHANGE | ServerEvent.STATE_CHANGE)) {
 			if (event.getServer().getServerState() == IServer.STATE_STARTED) {
 				install(event.getServer());
+				event.getServer().removeServerListener(this);
 			}
 		}
 	}
@@ -33,7 +40,7 @@
 		Trace.trace(Trace.INFO, "--> ConfigStoreInstaller.install()");
 		try {
 			
-			//temporary until custom repo is implemented inside workspace metadata
+			copyToRepository(server);
 			server.getRuntime().getLocation().append("eclipse-repository").toFile().mkdir();
 
 			JMXDeploymentManager dm = (JMXDeploymentManager) GeronimoConnectionFactory.getInstance().getDeploymentManager(server);
@@ -42,21 +49,38 @@
 			Target target = dm.getTargets()[0];
 			Trace.trace(Trace.INFO, "target name: " + target.getName());
 
-			File jar = new File(resolveFromBundle("/lib/config-store-service-1.0.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) {
+			GeronimoServerBehaviour gsb = (GeronimoServerBehaviour) server.loadAdapter(GeronimoServerBehaviour.class,
null);
+			Artifact artifact = Artifact.create(Activator.SERVICE_ID);
+			AbstractName name = Configuration.getConfigurationAbstractName(artifact);
+			
+			State state = null;
+			try {
+				state = State.fromInt(gsb.getKernel().getGBeanState(name));
+			} catch (GBeanNotFoundException e) {
+				Trace.trace(Trace.INFO, Activator.SERVICE_ID + " not installed");
+				//store not installed
+			} 
+			
+			if(state == null) {
+				File jar = new File(resolveFromBundle("/lib/config-store-service-1.0.jar").getFile());
+				File plan = new File(resolveFromBundle("/plan.xml").getFile());
+				Trace.trace(Trace.INFO, "installing " + Activator.SERVICE_ID);
+				ProgressObject po = dm.distribute(new Target[] { target }, jar, plan);
+				waitForCompletion(po);
+			}
+			
+			if(!gsb.getKernel().isRunning(name)) {
+				Trace.trace(Trace.INFO, "starting " + Activator.SERVICE_ID);
+				TargetModuleID id = new TargetModuleIDImpl(target, Activator.SERVICE_ID);
+				ProgressObject po = dm.start(new TargetModuleID[] { id });
+				waitForCompletion(po);
+			}
+			
+		} catch (Exception e) {
 			e.printStackTrace();
+		} finally {
+			Trace.trace(Trace.INFO, "<-- ConfigStoreInstaller.install()");
 		}
-		Trace.trace(Trace.INFO, "--> ConfigStoreInstaller.install()");
 	}
 
 	private URL resolveFromBundle(String path) {
@@ -76,5 +100,38 @@
 
 			}
 		}
+	}
+
+	private void copyToRepository(IServer server) {
+		IPath repo = server.getRuntime().getLocation().append("repository");
+
+		IPath path = repo.append("/hessian/hessian/3.0.8/hessian-3.0.8.jar");
+		copyFile(getFileFromBundle("lib/hessian-3.0.8.jar"), path.toFile());
+
+		path = repo.append("/mx4j/mx4j-tools/3.0.1/mx4j-tools-3.0.1.jar");
+		copyFile(getFileFromBundle("lib/mx4j-tools-3.0.1.jar"), path.toFile());
+	}
+	
+
+	private static void copyFile(File src, File dest) {
+		try {
+			if (!dest.exists()) {
+				Trace.trace(Trace.INFO, "adding " + dest);
+				IOUtil.copyFile(src, dest);
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+
+	private File getFileFromBundle(String path) {
+		try {
+			URL url = Platform.resolve(Activator.getDefault().getBundle().getEntry(path));
+			return new File(url.getFile());
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
 	}
 }

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/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoServerBehaviour.java?rev=409237&r1=409236&r2=409237&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
Wed May 24 13:07:10 2006
@@ -88,7 +88,7 @@
 		Trace.trace(Trace.INFO, "<-- stop()");
 	}
 
-	private Kernel getKernel() throws SecurityException {
+	protected Kernel getKernel() throws SecurityException {
 
 		if (kernel == null) {
 			Map map = new HashMap();



Mime
View raw message