Author: rob.stryker(a)jboss.com
Date: 2008-12-03 19:48:27 -0500 (Wed, 03 Dec 2008)
New Revision: 12266
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
Log:
JBIDE-3308, JBIDE-3323 Fixed deployment scanner additions. See issues for more
information.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-12-03
22:42:35 UTC (rev 12265)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-12-04
00:48:27 UTC (rev 12266)
@@ -21,12 +21,17 @@
*/
package org.jboss.ide.eclipse.as.core.server.internal;
+import java.io.File;
+
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
@@ -34,12 +39,16 @@
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.internal.launch.StopLaunchConfiguration;
@@ -192,29 +201,70 @@
protected void publishStart(IProgressMonitor monitor) throws CoreException {
super.publishStart(monitor);
- suspendDeployment();
- ensureDeployLocationAdded();
+ JMXClassLoaderRepository.getDefault().addConcerned(getServer(), this);
+ final boolean suspend = shouldSuspendScanner();
+ final boolean add = shouldAddDeployLocation();
+ if( suspend || add) {
+ IJMXRunnable r = new IJMXRunnable() {
+ public void run(MBeanServerConnection connection) throws Exception {
+ if( suspend )
+ suspendDeployment(connection);
+ if( add )
+ ensureDeployLocationAdded(connection);
+ }
+ };
+ JBossServerConnectionProvider.run(getServer(), r);
+ }
}
- protected void ensureDeployLocationAdded() {
- final IDeployableServer ds = ServerConverter.getDeployableServer(getServer());
- IJMXRunnable r = new IJMXRunnable() {
- public void run(MBeanServerConnection connection) throws Exception {
- ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
- connection.invoke(name, "addURL", new Object[] { "file:" +
ds.getDeployFolder() }, new String[] {String.class.getName()});
- }
- };
- try {
- if( getServer().getServerState() == IServer.STATE_STARTED)
- JBossServerConnectionProvider.run(getServer(), r);
- } catch( CoreException ce) {}
- }
-
protected void publishFinish(IProgressMonitor monitor) throws CoreException {
- resumeDeployment();
+ if( shouldSuspendScanner()) {
+ IJMXRunnable r = new IJMXRunnable() {
+ public void run(MBeanServerConnection connection) throws Exception {
+ resumeDeployment(connection);
+ }
+ };
+ JBossServerConnectionProvider.run(getServer(), r);
+ }
+ JMXClassLoaderRepository.getDefault().removeConcerned(getServer(), this);
super.publishFinish(monitor);
}
+
+ protected boolean shouldAddDeployLocation() {
+ IDeployableServer ds = ServerConverter.getDeployableServer(getServer());
+ boolean shouldAdd = getServer().getServerState() == IServer.STATE_STARTED;
+ String type = ds.getDeployLocationType();
+ String deployFolder = ds.getDeployFolder();
+ if( type.equals(IDeployableServer.DEPLOY_SERVER))
+ shouldAdd = false;
+ else if( type.equals(IDeployableServer.DEPLOY_METADATA))
+ shouldAdd = true;
+ else if( type.equals( IDeployableServer.DEPLOY_CUSTOM )) {
+ if( !new File(deployFolder).exists())
+ shouldAdd = false;
+ else {
+ IRuntime rt = getServer().getRuntime();
+ IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ String config = jbsrt.getJBossConfiguration();
+ IPath deploy = new Path(IJBossServerConstants.SERVER)
+ .append(config)
+ .append(IJBossServerConstants.DEPLOY).makeRelative();
+ IPath deployGlobal = DeployableServer.makeGlobal(jbsrt, deploy);
+ if( new Path(deployFolder).equals(deployGlobal))
+ shouldAdd = false;
+ }
+ }
+ return shouldAdd;
+ }
+
+ protected void ensureDeployLocationAdded(MBeanServerConnection connection) throws
Exception {
+ IDeployableServer ds = ServerConverter.getDeployableServer(getServer());
+ String deployFolder = ds.getDeployFolder();
+ ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
+ connection.invoke(name, "addURL", new Object[] { "file:" +
deployFolder }, new String[] {String.class.getName()});
+ }
+
protected boolean shouldSuspendScanner() {
if(
getServer().getServerType().getId().equals("org.jboss.ide.eclipse.as.50"))
return false;
@@ -223,30 +273,14 @@
return true;
}
- protected void suspendDeployment() {
- IJMXRunnable r = new IJMXRunnable() {
- public void run(MBeanServerConnection connection) throws Exception {
- ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
- connection.invoke(name, "stop", new Object[] { }, new String[] {});
- }
- };
- try {
- if( shouldSuspendScanner() )
- JBossServerConnectionProvider.run(getServer(), r);
- } catch( CoreException ce) {} // ignore
+ protected void suspendDeployment(MBeanServerConnection connection) throws Exception {
+ ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
+ connection.invoke(name, "stop", new Object[] { }, new String[] {});
}
- protected void resumeDeployment() {
- IJMXRunnable r = new IJMXRunnable() {
- public void run(MBeanServerConnection connection) throws Exception {
- ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
- connection.invoke(name, "start", new Object[] { }, new String[] {});
- }
- };
- try {
- if( shouldSuspendScanner() )
- JBossServerConnectionProvider.run(getServer(), r);
- } catch( CoreException ce) {} // ignore
+ protected void resumeDeployment(MBeanServerConnection connection) throws Exception {
+ ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
+ connection.invoke(name, "start", new Object[] { }, new String[] {});
}
Show replies by date