geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r452561 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/ org.apache.geronimo.st.v1.core/src/org/apache/g...
Date Tue, 03 Oct 2006 16:14:27 GMT
Author: sppatel
Date: Tue Oct  3 09:14:26 2006
New Revision: 452561

URL: http://svn.apache.org/viewvc?view=rev&rev=452561
Log:
lookup targetmoduleId locally to avoid targetModuleId out of sync with project config and
failures when deployment models can't load plan

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/DeploymentUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoVersionHandler.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ModuleArtifactMapper.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/RedeployCommand.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/StopCommand.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/UndeployCommand.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoV1VersionHandler.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/DeploymentUtils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/DeploymentUtils.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/DeploymentUtils.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/DeploymentUtils.java
Tue Oct  3 09:14:26 2006
@@ -42,6 +42,7 @@
 import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
 import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
 import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.model.IModuleResource;
 import org.eclipse.wst.server.core.util.ProjectModule;
 
@@ -149,20 +150,26 @@
 		return null;
 	}
 
-	public static TargetModuleID getTargetModuleID(IModule module,
-			DeploymentManager dm) throws TargetModuleIdNotFoundException {
+	public static TargetModuleID getTargetModuleID(IModule module, DeploymentManager dm) throws
TargetModuleIdNotFoundException {
 		IGeronimoServer server = GeronimoConnectionFactory.getInstance().getGeronimoServer(dm);
-		ModuleType moduleType = GeronimoUtils.getJSR88ModuleType(module);
 		String configId = server.getVersionHandler().getConfigID(module);
-		return getTargetModuleID(moduleType, dm, configId);
+		return getTargetModuleID(dm, configId);
+	}
+	
+	public static TargetModuleID getTargetModuleID(IServer server, IModule module) throws TargetModuleIdNotFoundException
{
+		String configId = ModuleArtifactMapper.getInstance().resolve(server, module);
+		if(configId == null) {
+			throw new TargetModuleIdNotFoundException("Could not do a local TargetModuleID lookup
for module " + module.getName());
+		}
+		
+		IGeronimoServer gs = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+		return gs.getVersionHandler().createTargetModuleId(configId);
 	}
 
-	private static TargetModuleID getTargetModuleID(ModuleType moduleType,
-			DeploymentManager dm, String configId)
-			throws TargetModuleIdNotFoundException {
+	private static TargetModuleID getTargetModuleID(DeploymentManager dm, String configId) throws
TargetModuleIdNotFoundException {
 
 		try {
-			TargetModuleID ids[] = dm.getAvailableModules(moduleType, dm.getTargets());
+			TargetModuleID ids[] = dm.getAvailableModules(null, dm.getTargets());
 			if (ids != null) {
 				for (int i = 0; i < ids.length; i++) {
 					if (ids[i].getModuleID().equals(configId)) {
@@ -176,12 +183,10 @@
 			e.printStackTrace();
 		}
 
-		throw new TargetModuleIdNotFoundException("Could not find TargetModuleID for module with
configId "
-				+ configId);
+		throw new TargetModuleIdNotFoundException("Could not find TargetModuleID for module with
configId " + configId);
 	}
 
-	public static boolean configurationExists(IModule module,
-			DeploymentManager dm) {
+	public static boolean configurationExists(IModule module, DeploymentManager dm) {
 		try {
 			return getTargetModuleID(module, dm) != null;
 		} catch (TargetModuleIdNotFoundException e) {

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
Tue Oct  3 09:14:26 2006
@@ -195,15 +195,17 @@
 		Trace.trace(Trace.INFO, Arrays.asList(module).toString());
 		_monitor = monitor;
 
-		//NO_CHANGE need if app is associated but not started and no delta
-		if (module.length == 1 && (deltaKind == ADDED || deltaKind == REMOVED || deltaKind
== NO_CHANGE)) {
-			invokeCommand(deltaKind, module[0]);
-		} else if (deltaKind == CHANGED) {
-			// TODO This case is flawed due to WTP Bugzilla 123676
-			invokeCommand(deltaKind, module[0]);
-		} 
-
-		setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
+		try {
+			//NO_CHANGE need if app is associated but not started and no delta
+			if (module.length == 1 && (deltaKind == ADDED || deltaKind == REMOVED || deltaKind
== NO_CHANGE)) {
+				invokeCommand(deltaKind, module[0]);
+			} else if (deltaKind == CHANGED) {
+				// TODO This case is flawed due to WTP Bugzilla 123676
+				invokeCommand(deltaKind, module[0]);
+			} 
+		} finally {
+			setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
+		}
 
 		Trace.trace(Trace.INFO, "<< publishModule()");
 	}
@@ -456,20 +458,12 @@
 		
 		Trace.trace(Trace.INFO, ">> doNoChange() " + module.toString());
 		
-		boolean found = false;
-		try {
-			TargetModuleID id = DeploymentUtils.getTargetModuleID(module, DeploymentCommandFactory.getDeploymentManager(getServer()));
-			found = id != null;
-		} catch (TargetModuleIdNotFoundException e) {
-			Trace.trace(Trace.INFO, "TargetModuleId not found.");
-		}
-
-		if(found) {
+		if(DeploymentUtils.configurationExists(module, DeploymentCommandFactory.getDeploymentManager(getServer())))
{
 			start(module);
 		} else {
 			doDeploy(module);
 		}
-
+		
 		Trace.trace(Trace.INFO, "<< doNoChange()" + module.toString());
 	}
 
@@ -501,7 +495,7 @@
 	}
 
 	protected IStatus start(IModule module) throws Exception {
-		TargetModuleID id = DeploymentUtils.getTargetModuleID(module, DeploymentCommandFactory.getDeploymentManager(getServer()));
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getServer(), module);
 		IDeploymentCommand cmd = DeploymentCommandFactory.createStartCommand(new TargetModuleID[]
{ id }, module, getServer());
 		return cmd.execute(_monitor);
 	}

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoVersionHandler.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoVersionHandler.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoVersionHandler.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/IGeronimoVersionHandler.java
Tue Oct  3 09:14:26 2006
@@ -15,10 +15,14 @@
  */
 package org.apache.geronimo.st.core;
 
+import javax.enterprise.deploy.spi.TargetModuleID;
+
 import org.eclipse.wst.server.core.IModule;
 
 public interface IGeronimoVersionHandler {
 
 	public String getConfigID(IModule module);
+	
+	public TargetModuleID createTargetModuleId(String configId);
 
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ModuleArtifactMapper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ModuleArtifactMapper.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ModuleArtifactMapper.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/ModuleArtifactMapper.java
Tue Oct  3 09:14:26 2006
@@ -28,11 +28,13 @@
 import java.io.ObjectOutputStream;
 import java.io.OutputStream;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.util.SocketUtil;
 
@@ -86,6 +88,23 @@
 			String projectName = (String) artifactEntries.get(configId);
 			if (projectName != null)
 				return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+		}
+		return null;
+	}
+	
+	public String resolve(IServer server, IModule module) {
+		Map artifactEntries = (Map) serverEntries.get(server.getRuntime().getLocation().toFile());
+		if (artifactEntries != null) {
+			String projectName = module.getProject().getName();
+			if(artifactEntries.containsValue(projectName)) {
+				Iterator i = artifactEntries.keySet().iterator();
+				while(i.hasNext()) {
+					String configId = (String) i.next();
+					if(artifactEntries.get(configId).equals(projectName)) {
+						return configId;
+					}
+				}
+			}
 		}
 		return null;
 	}

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/RedeployCommand.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/RedeployCommand.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/RedeployCommand.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/RedeployCommand.java
Tue Oct  3 09:14:26 2006
@@ -43,7 +43,7 @@
 	public IStatus execute(IProgressMonitor monitor) throws TargetModuleIdNotFoundException,
CoreException {
 		DeploymentManager dm = getDeploymentManager();
 		File file = getTargetFile();
-		TargetModuleID id = DeploymentUtils.getTargetModuleID(getModule(), dm);
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getServer(), getModule());
 		return new DeploymentCmdStatus(Status.OK_STATUS, dm.redeploy(new TargetModuleID[] { id
}, file, null));
 	}
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/StopCommand.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/StopCommand.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/StopCommand.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/StopCommand.java
Tue Oct  3 09:14:26 2006
@@ -38,7 +38,7 @@
 	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
 	 */
 	public IStatus execute(IProgressMonitor monitor) throws TargetModuleIdNotFoundException,
CoreException {
-		TargetModuleID id = DeploymentUtils.getTargetModuleID(getModule(), getDeploymentManager());
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getServer(), getModule());
 		return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().stop(new TargetModuleID[]
{ id }));
 	}
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/UndeployCommand.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/UndeployCommand.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/UndeployCommand.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/org/apache/geronimo/st/core/commands/UndeployCommand.java
Tue Oct  3 09:14:26 2006
@@ -38,7 +38,7 @@
 	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
 	 */
 	public IStatus execute(IProgressMonitor monitor) throws TargetModuleIdNotFoundException,
CoreException {
-		TargetModuleID id = DeploymentUtils.getTargetModuleID(getModule(), getDeploymentManager());
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getServer(), getModule());
 		return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().undeploy(new TargetModuleID[]
{ id }));
 	}
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoV1VersionHandler.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoV1VersionHandler.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoV1VersionHandler.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoV1VersionHandler.java
Tue Oct  3 09:14:26 2006
@@ -15,6 +15,9 @@
  */
 package org.apache.geronimo.st.v1.core;
 
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
 import org.apache.geronimo.st.core.IGeronimoVersionHandler;
 import org.eclipse.wst.server.core.IModule;
 
@@ -27,5 +30,12 @@
 	 */
 	public String getConfigID(IModule module) {
 		return GeronimoV1Utils.getConfigId(module);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.st.core.IGeronimoVersionHandler#createTargetModuleId(java.lang.String)
+	 */
+	public TargetModuleID createTargetModuleId(String configId) {
+		return new TargetModuleIDImpl(null, configId);
 	}
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.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/GeronimoV11VersionHandler.java?view=diff&rev=452561&r1=452560&r2=452561
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11VersionHandler.java
Tue Oct  3 09:14:26 2006
@@ -15,6 +15,9 @@
  */
 package org.apache.geronimo.st.v11.core;
 
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
 import org.apache.geronimo.st.core.IGeronimoVersionHandler;
 import org.eclipse.wst.server.core.IModule;
 
@@ -27,5 +30,12 @@
 	 */
 	public String getConfigID(IModule module) {
 		return GeronimoV11Utils.getConfigId(module);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.st.core.IGeronimoVersionHandler#createTargetModuleId(java.lang.String)
+	 */
+	public TargetModuleID createTargetModuleId(String configId) {
+		return new TargetModuleIDImpl(null, configId);
 	}
 }



Mime
View raw message