You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by sp...@apache.org on 2006/10/04 23:43:44 UTC
svn commit: r453040 - 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...
Author: sppatel
Date: Wed Oct 4 14:43:43 2006
New Revision: 453040
URL: http://svn.apache.org/viewvc?view=rev&rev=453040
Log:
improve deploy logic to handle out of sync servers with associated projects
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/ModuleArtifactMapper.java
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.core/src/org/apache/geronimo/st/core/commands/RedeployCommand.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
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.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=453040&r1=453039&r2=453040
==============================================================================
--- 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 Wed Oct 4 14:43:43 2006
@@ -17,12 +17,13 @@
import java.io.File;
-import javax.enterprise.deploy.shared.ModuleType;
import javax.enterprise.deploy.spi.DeploymentManager;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.exceptions.TargetException;
+import org.apache.geronimo.st.core.commands.DeploymentCommandFactory;
import org.apache.geronimo.st.core.commands.TargetModuleIdNotFoundException;
+import org.apache.geronimo.st.core.internal.Trace;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -149,12 +150,6 @@
}
return null;
}
-
- public static TargetModuleID getTargetModuleID(IModule module, DeploymentManager dm) throws TargetModuleIdNotFoundException {
- IGeronimoServer server = GeronimoConnectionFactory.getInstance().getGeronimoServer(dm);
- String configId = server.getVersionHandler().getConfigID(module);
- return getTargetModuleID(dm, configId);
- }
public static TargetModuleID getTargetModuleID(IServer server, IModule module) throws TargetModuleIdNotFoundException {
String configId = ModuleArtifactMapper.getInstance().resolve(server, module);
@@ -166,7 +161,7 @@
return gs.getVersionHandler().createTargetModuleId(configId);
}
- private static TargetModuleID getTargetModuleID(DeploymentManager dm, String configId) throws TargetModuleIdNotFoundException {
+ public static TargetModuleID getTargetModuleID(DeploymentManager dm, String configId) throws TargetModuleIdNotFoundException {
try {
TargetModuleID ids[] = dm.getAvailableModules(null, dm.getTargets());
@@ -183,15 +178,47 @@
e.printStackTrace();
}
- throw new TargetModuleIdNotFoundException("Could not find TargetModuleID for module with configId " + configId);
+ throw new TargetModuleIdNotFoundException("Could not find TargetModuleID with configId " + configId);
}
- public static boolean configurationExists(IModule module, DeploymentManager dm) {
+ /**
+ * This method determines the last known config id for an IModule that has been deployed to the server. The
+ * configId from the plan cannot be used as the project may have been previously deployed with a different
+ * configId. In which case the lookup is done through the ModuleArtifactMapper first.
+ *
+ * @param module
+ * @param server
+ * @return For a given module associated with a given server, this method returns the last known configuration id.
+ * @throws CoreException
+ */
+ public static String getLastKnownConfigurationId(IModule module, IServer server) throws CoreException {
+
+ IGeronimoServer gs = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+ String currentId = gs.getVersionHandler().getConfigID(module);
+ String publishedId = ModuleArtifactMapper.getInstance().resolve(server, module);
+ String query = publishedId != null ? publishedId : currentId;
+
+ Trace.trace(Trace.INFO, "currentConfigId = " + currentId + " previousConfigId = " + publishedId);
+
+ DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(server);
+
try {
- return getTargetModuleID(module, dm) != null;
+ getTargetModuleID(dm, query);
+ return query;
} catch (TargetModuleIdNotFoundException e) {
- return false;
+ Trace.trace(Trace.INFO, e.getMessage());
+ }
+
+ if(query != currentId) {
+ try {
+ getTargetModuleID(dm, currentId);
+ return currentId;
+ } catch (TargetModuleIdNotFoundException e) {
+ Trace.trace(Trace.INFO, e.getMessage());
+ }
}
+
+ return null;
}
}
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=453040&r1=453039&r2=453040
==============================================================================
--- 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 Wed Oct 4 14:43:43 2006
@@ -27,7 +27,6 @@
import java.util.Map;
import java.util.Timer;
-import javax.enterprise.deploy.spi.DeploymentManager;
import javax.enterprise.deploy.spi.Target;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.management.MBeanServerConnection;
@@ -38,7 +37,6 @@
import org.apache.geronimo.st.core.commands.DeploymentCmdStatus;
import org.apache.geronimo.st.core.commands.DeploymentCommandFactory;
import org.apache.geronimo.st.core.commands.IDeploymentCommand;
-import org.apache.geronimo.st.core.commands.TargetModuleIdNotFoundException;
import org.apache.geronimo.st.core.internal.Messages;
import org.apache.geronimo.st.core.internal.Trace;
import org.apache.geronimo.xbeans.eclipse.deployment.ModuleDocument;
@@ -91,8 +89,6 @@
protected transient IDebugEventSetListener processListener;
- abstract public String getConfigId(IModule module);
-
abstract protected ClassLoader getContextClassLoader();
/*
@@ -303,15 +299,15 @@
Thread.currentThread().setContextClassLoader(cl);
switch (deltaKind) {
case ADDED: {
- doDeploy(module);
+ doAdded(module, null);
break;
}
case CHANGED: {
- doRedeploy(module);
+ doChanged(module, null);
break;
}
case REMOVED: {
- doUndeploy(module);
+ doRemoved(module);
break;
}
case NO_CHANGE: {
@@ -331,26 +327,24 @@
}
private void generateRunFromWorkspaceConfig(IModule module) {
- //if (getGeronimoServer().isRunFromWorkspace()) {
- IPath configDir = Activator.getDefault().getStateLocation().append(
- "looseconfig").append("server_" + getServer().getId());
- configDir.toFile().mkdirs();
-
- ModuleDocument doc = ModuleDocument.Factory.newInstance();
- Module deployable = doc.addNewModule();
- processModuleConfig(deployable, module);
-
- XmlOptions options = new XmlOptions();
- options.setSavePrettyPrint();
- File file = configDir.append(module.getName()).addFileExtension("xml")
- .toFile();
- System.out.println(doc.xmlText(options));
- try {
- doc.save(file, options);
- } catch (IOException e) {
- e.printStackTrace();
+ if (getGeronimoServer().isRunFromWorkspace()) {
+ IPath configDir = Activator.getDefault().getStateLocation().append("looseconfig").append("server_" + getServer().getId());
+ configDir.toFile().mkdirs();
+
+ ModuleDocument doc = ModuleDocument.Factory.newInstance();
+ Module deployable = doc.addNewModule();
+ processModuleConfig(deployable, module);
+
+ XmlOptions options = new XmlOptions();
+ options.setSavePrettyPrint();
+ File file = configDir.append(module.getName()).addFileExtension("xml").toFile();
+ Trace.trace(Trace.INFO,doc.xmlText(options));
+ try {
+ doc.save(file, options);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
- //}
}
private void processModuleConfig(Module deployable, IModule serverModule) {
@@ -397,12 +391,17 @@
}
}
- protected void doDeploy(IModule module) throws Exception {
- Trace.trace(Trace.INFO, ">> doDeploy() " + module.toString());
-
- DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(getServer());
-
- if (!DeploymentUtils.configurationExists(module, dm)) {
+ /**
+ * @param module
+ * @param configId the forced configId to process this method, passed in when this method is invoked from doChanged()
+ * @throws Exception
+ */
+ protected void doAdded(IModule module, String configId) throws Exception {
+ Trace.trace(Trace.INFO, ">> doAdded() " + module.toString());
+
+ //use the correct configId, second from the .metadata, then from the plan
+ configId = configId != null ? configId : DeploymentUtils.getLastKnownConfigurationId(module, getServer());
+ if (configId == null) {
IStatus status = distribute(module);
if (!status.isOK()) {
doFail(status, Messages.DISTRIBUTE_FAIL);
@@ -415,61 +414,65 @@
doFail(status, Messages.START_FAIL);
}
} else {
- String id = getConfigId(module);
- String message = id
- + "already exists. Existing configuration will be overwritten.";
- Activator.log(Status.ERROR, message, null);
- doRedeploy(module);
+ //either (1) a configuration with the same module id exists already on the server
+ //or (2) the module now has a different configId and the configuration on the server using
+ //the old id as specified in the project-configId map should be uninstalled.
+ doChanged(module, configId);
}
- Trace.trace(Trace.INFO, "<< doDeploy() " + module.toString());
- }
-
- private TargetModuleID[] updateServerModuleConfigIDMap(IModule module, IStatus status) {
- TargetModuleID[] ids = ((DeploymentCmdStatus) status).getResultTargetModuleIDs();
- ModuleArtifactMapper mapper = ModuleArtifactMapper.getInstance();
- mapper.addEntry(getServer(), module.getProject(), ids[0].getModuleID());
- return ids;
+ Trace.trace(Trace.INFO, "<< doAdded() " + module.toString());
}
- protected void doRedeploy(IModule module) throws Exception {
- Trace.trace(Trace.INFO, ">> doRedeploy() " + module.toString());
-
- try {
- IStatus status = reDeploy(module);
- if (!status.isOK()) {
- doFail(status, Messages.REDEPLOY_FAIL);
+ /**
+ * @param module
+ * @param configId the forced configId to process this method, passed in when invoked from doAdded()
+ * @throws Exception
+ */
+ protected void doChanged(IModule module, String configId) throws Exception {
+ Trace.trace(Trace.INFO, ">> doChanged() " + module.toString());
+
+ //use the correct configId, second from the .metadata, then from the plan
+ configId = configId != null ? configId : DeploymentUtils.getLastKnownConfigurationId(module, getServer());
+ if(configId != null) {
+ String moduleConfigId = getConfigId(module);
+ if(moduleConfigId.equals(configId)) {
+ IStatus status = reDeploy(module);
+ if (!status.isOK()) {
+ doFail(status, Messages.REDEPLOY_FAIL);
+ }
+ } else {
+ //different configIds from what needs to be undeployed to what will be deployed
+ doRemoved(module);
+ doAdded(module, null);
}
-
- updateServerModuleConfigIDMap(module, status);
-
- } catch (TargetModuleIdNotFoundException e) {
- Activator.log(Status.WARNING, "Module may have been uninstalled outside the workspace.", e);
- doDeploy(module);
+ } else {
+ //The checked configuration no longer exists on the server
+ doAdded(module, configId);
}
- Trace.trace(Trace.INFO, "<< doRedeploy() " + module.toString());
+ Trace.trace(Trace.INFO, "<< doChanged() " + module.toString());
}
- protected void doUndeploy(IModule module) throws Exception {
- Trace.trace(Trace.INFO, ">> doUndeploy() " + module.toString());
+ protected void doRemoved(IModule module) throws Exception {
+ Trace.trace(Trace.INFO, ">> doRemoved() " + module.toString());
IStatus status = unDeploy(module);
if (!status.isOK()) {
doFail(status, Messages.UNDEPLOY_FAIL);
}
+
+ ModuleArtifactMapper.getInstance().removeEntry(getServer(), module.getProject());
- Trace.trace(Trace.INFO, "<< doUndeploy()" + module.toString());
+ Trace.trace(Trace.INFO, "<< doRemoved()" + module.toString());
}
protected void doNoChange(IModule module) throws Exception {
-
Trace.trace(Trace.INFO, ">> doNoChange() " + module.toString());
- if(DeploymentUtils.configurationExists(module, DeploymentCommandFactory.getDeploymentManager(getServer()))) {
+ if(DeploymentUtils.getLastKnownConfigurationId(module, getServer()) != null) {
start(module);
} else {
- doDeploy(module);
+ doAdded(module, null);
}
Trace.trace(Trace.INFO, "<< doNoChange()" + module.toString());
@@ -490,6 +493,13 @@
Trace.trace(Trace.INFO, ">> doRestart() " + module.toString());
}
+
+ private TargetModuleID[] updateServerModuleConfigIDMap(IModule module, IStatus status) {
+ TargetModuleID[] ids = ((DeploymentCmdStatus) status).getResultTargetModuleIDs();
+ ModuleArtifactMapper mapper = ModuleArtifactMapper.getInstance();
+ mapper.addEntry(getServer(), module.getProject(), ids[0].getModuleID());
+ return ids;
+ }
protected void doFail(IStatus status, String message) throws CoreException {
MultiStatus ms = new MultiStatus(Activator.PLUGIN_ID, 0, message, null);
@@ -690,6 +700,10 @@
return "REMOVED";
}
return Integer.toString(kind);
+ }
+
+ public String getConfigId(IModule module) {
+ return getGeronimoServer().getVersionHandler().getConfigID(module);
}
}
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=453040&r1=453039&r2=453040
==============================================================================
--- 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 Wed Oct 4 14:43:43 2006
@@ -28,11 +28,9 @@
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;
@@ -75,6 +73,18 @@
}
artifactEntries.put(project.getName(), configId);
+ }
+
+ public void removeEntry(IServer server, IProject project) {
+
+ if (!SocketUtil.isLocalhost(server.getHost()))
+ return;
+
+ File runtimeLoc = server.getRuntime().getLocation().toFile();
+ Map artifactEntries = (Map) serverEntries.get(runtimeLoc);
+ if (artifactEntries != null) {
+ artifactEntries.remove(project.getName());
+ }
}
public String resolve(IServer server, IModule module) {
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?view=diff&rev=453040&r1=453039&r2=453040
==============================================================================
--- 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 Oct 4 14:43:43 2006
@@ -42,8 +42,7 @@
*/
public void run() {
synchronized (delegate) {
- Trace.trace(Trace.INFO, "--> UpdateServerStateTask.run() "
- + server.getName());
+ //Trace.trace(Trace.INFO, "--> UpdateServerStateTask.run() " + server.getName());
// Only start the task if the connection URL is unqiue for all
// g-servers or if other servers that are different instances but do
@@ -71,16 +70,14 @@
}
}
- Trace.trace(Trace.INFO, "allUnique = " + allUnique
- + ", allNonUniqueStopped = " + allNonUniqueStopped);
+ //Trace.trace(Trace.INFO, "allUnique = " + allUnique + ", allNonUniqueStopped = " + allNonUniqueStopped);
if (allUnique || allNonUniqueStopped) {
- Trace.trace(Trace.INFO, "updating state...");
+ //Trace.trace(Trace.INFO, "updating state...");
updateServerState();
}
- Trace.trace(Trace.INFO, "<-- UpdateServerStateTask.run() "
- + server.getName());
+ //Trace.trace(Trace.INFO, "<-- UpdateServerStateTask.run() " + server.getName());
}
}
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=453040&r1=453039&r2=453040
==============================================================================
--- 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 Wed Oct 4 14:43:43 2006
@@ -15,13 +15,11 @@
*/
package org.apache.geronimo.st.core.commands;
-import java.io.File;
-
import javax.enterprise.deploy.shared.CommandType;
-import javax.enterprise.deploy.spi.DeploymentManager;
import javax.enterprise.deploy.spi.TargetModuleID;
import org.apache.geronimo.st.core.DeploymentUtils;
+import org.apache.geronimo.st.core.ModuleArtifactMapper;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -41,10 +39,9 @@
* @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus execute(IProgressMonitor monitor) throws TargetModuleIdNotFoundException, CoreException {
- DeploymentManager dm = getDeploymentManager();
- File file = getTargetFile();
- TargetModuleID id = DeploymentUtils.getTargetModuleID(getServer(), getModule());
- return new DeploymentCmdStatus(Status.OK_STATUS, dm.redeploy(new TargetModuleID[] { id }, file, null));
+ String configId = ModuleArtifactMapper.getInstance().resolve(getServer(), getModule());
+ TargetModuleID id = DeploymentUtils.getTargetModuleID(getDeploymentManager(), configId);
+ return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().redeploy(new TargetModuleID[] { id }, getTargetFile(), null));
}
/*
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/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v1.core/src/org/apache/geronimo/st/v1/core/GeronimoServerBehaviour.java?view=diff&rev=453040&r1=453039&r2=453040
==============================================================================
--- 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 Wed Oct 4 14:43:43 2006
@@ -144,15 +144,6 @@
/*
* (non-Javadoc)
*
- * @see org.apache.geronimo.st.core.GenericGeronimoServerBehaviour#getConfigId(org.eclipse.wst.server.core.IModule)
- */
- public String getConfigId(IModule module) {
- return GeronimoV1Utils.getConfigId(module);
- }
-
- /*
- * (non-Javadoc)
- *
* @see org.eclipse.wst.server.core.internal.IModulePublishHelper#getPublishDirectory(org.eclipse.wst.server.core.IModule[])
*/
public IPath getPublishDirectory(IModule[] module) {
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?view=diff&rev=453040&r1=453039&r2=453040
==============================================================================
--- 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 Oct 4 14:43:43 2006
@@ -34,6 +34,7 @@
import org.apache.geronimo.st.core.Activator;
import org.apache.geronimo.st.core.GeronimoConnectionFactory;
import org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.core.IGeronimoServer;
import org.apache.geronimo.st.core.operations.ISharedLibEntryCreationDataModelProperties;
import org.apache.geronimo.st.core.operations.SharedLibEntryCreationOperation;
import org.apache.geronimo.st.core.operations.SharedLibEntryDataModelProvider;
@@ -154,15 +155,6 @@
return false;
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.core.GenericGeronimoServerBehaviour#getConfigId(org.eclipse.wst.server.core.IModule)
- */
- public String getConfigId(IModule module) {
- return GeronimoV11Utils.getConfigId(module);
- }
-
public IPath getPublishDirectory(IModule[] module) {
if (module == null || module.length == 0)
return null;
@@ -200,26 +192,21 @@
return Kernel.class.getClassLoader();
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate#doDeploy(org.eclipse.wst.server.core.IModule)
+ /* (non-Javadoc)
+ * @see org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate#doAdded(org.eclipse.wst.server.core.IModule, java.lang.String)
*/
- protected void doDeploy(IModule module) throws Exception {
+ protected void doAdded(IModule module, String configId) throws Exception {
updateSharedLib(module);
- super.doDeploy(module);
+ super.doAdded(module, configId);
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate#doRedeploy(org.eclipse.wst.server.core.IModule)
+ /* (non-Javadoc)
+ * @see org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate#doChanged(org.eclipse.wst.server.core.IModule, java.lang.String)
*/
- protected void doRedeploy(IModule module) throws Exception {
- super.unDeploy(module);
+ protected void doChanged(IModule module, String configId) throws Exception {
updateSharedLib(module);
- super.doDeploy((module));
+ super.doChanged(module, configId);
}
/*
@@ -227,8 +214,8 @@
*
* @see org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate#doUndeploy(org.eclipse.wst.server.core.IModule)
*/
- protected void doUndeploy(IModule module) throws Exception {
- super.doUndeploy(module);
+ protected void doRemoved(IModule module) throws Exception {
+ super.doRemoved(module);
updateSharedLib(module);
}
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.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/GeronimoV11Utils.java?view=diff&rev=453040&r1=453039&r2=453040
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/org/apache/geronimo/st/v11/core/GeronimoV11Utils.java Wed Oct 4 14:43:43 2006
@@ -15,7 +15,18 @@
*/
package org.apache.geronimo.st.v11.core;
+import java.io.IOException;
+
+import org.apache.geronimo.deployment.xbeans.EnvironmentDocument;
+import org.apache.geronimo.deployment.xbeans.ModuleDocument;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
import org.apache.geronimo.st.core.GeronimoUtils;
+import org.apache.geronimo.xbeans.j2ee.ApplicationDocument;
+import org.apache.geronimo.xbeans.j2ee.EjbJarDocument;
+import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
+import org.apache.geronimo.xbeans.j2ee.WebservicesDocument;
+import org.apache.geronimo.xbeans.j2ee.impl.ConnectorDocumentImpl;
import org.apache.geronimo.xml.ns.deployment.ArtifactType;
import org.apache.geronimo.xml.ns.deployment.DeploymentPackage;
import org.apache.geronimo.xml.ns.deployment.EnvironmentType;
@@ -29,11 +40,16 @@
import org.apache.geronimo.xml.ns.j2ee.web.WebAppType;
import org.apache.geronimo.xml.ns.j2ee.web.WebPackage;
import org.apache.geronimo.xml.ns.j2ee.web.util.WebResourceFactoryImpl;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.server.core.IModule;
import org.openejb.xml.ns.openejb.jar.JarPackage;
@@ -57,6 +73,42 @@
return null;
}
+
+ public static String getConfigId2(IModule module) {
+
+ IFile planFile = null;
+ IVirtualComponent comp = ComponentCore.createComponent(module.getProject());
+ if (isWebModule(module)) {
+ planFile = GeronimoUtils.getWebDeploymentPlanFile(comp);
+ } else if (isEjbJarModule(module)) {
+ planFile = GeronimoUtils.getOpenEjbDeploymentPlanFile(comp);
+ } else if (isEarModule(module)) {
+ planFile = GeronimoUtils.getApplicationDeploymentPlanFile(comp);
+ } else if (isRARModule(module)) {
+ planFile = GeronimoUtils.getConnectorDeploymentPlanFile(comp);
+ }
+
+ if(planFile != null) {
+ try {
+ XmlObject xmlObject = XmlBeansUtil.parse(planFile.getLocation().toFile());
+ XmlCursor cursor = xmlObject.newCursor();
+ cursor.toFirstChild();
+ xmlObject = cursor.getObject();
+ XmlObject result[] = xmlObject.selectChildren(QNameSet.singleton(EnvironmentDocument.type.getDocumentElementName()));
+ if(result != null && result.length > 0) {
+ org.apache.geronimo.deployment.xbeans.EnvironmentType env = (org.apache.geronimo.deployment.xbeans.EnvironmentType) result[0].changeType(org.apache.geronimo.deployment.xbeans.EnvironmentType.type);
+ org.apache.geronimo.deployment.xbeans.ArtifactType moduleId = env.getModuleId();
+ return getQualifiedConfigID(moduleId);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (XmlException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return null;
+ }
public static String getConfigId(IModule module) {
@@ -88,8 +140,15 @@
}
public static String getQualifiedConfigID(ArtifactType artifact) {
- return artifact.getGroupId() + "/" + artifact.getArtifactId() + "/"
- + artifact.getVersion() + "/" + artifact.getType();
+ return getQualifiedConfigID(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
+ }
+
+ public static String getQualifiedConfigID(org.apache.geronimo.deployment.xbeans.ArtifactType artifact) {
+ return getQualifiedConfigID(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
+ }
+
+ public static String getQualifiedConfigID(String groupId, String artifactId, String version, String type) {
+ return groupId + "/" + artifactId + "/" + version + "/" + type;
}
public static String getContextRoot(IModule module) {
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=453040&r1=453039&r2=453040
==============================================================================
--- 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 Wed Oct 4 14:43:43 2006
@@ -29,7 +29,7 @@
* @see org.apache.geronimo.st.core.IGeronimoVersionHandler#getConfigID(org.eclipse.wst.server.core.IModule)
*/
public String getConfigID(IModule module) {
- return GeronimoV11Utils.getConfigId(module);
+ return GeronimoV11Utils.getConfigId2(module);
}
/* (non-Javadoc)