Author: rob.stryker(a)jboss.com
Date: 2010-01-06 18:23:08 -0500 (Wed, 06 Jan 2010)
New Revision: 19668
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java
Log:
JBIDE-5597 - modifying the list of folders that are added automatically
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2010-01-06
22:08:00 UTC (rev 19667)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2010-01-06
23:23:08 UTC (rev 19668)
@@ -21,6 +21,7 @@
import org.eclipse.jst.server.core.IEnterpriseApplication;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerPort;
import org.eclipse.wst.server.core.model.ServerDelegate;
@@ -165,9 +166,13 @@
}
public IJBossServerRuntime getRuntime() {
+ return getRuntime(getServer());
+ }
+
+ public static IJBossServerRuntime getRuntime(IServer server) {
IJBossServerRuntime ajbsrt = null;
- if( getServer().getRuntime() != null ) {
- ajbsrt = (IJBossServerRuntime) getServer().getRuntime()
+ if( server.getRuntime() != null ) {
+ ajbsrt = (IJBossServerRuntime) server.getRuntime()
.loadAdapter(IJBossServerRuntime.class,
new NullProgressMonitor());
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2010-01-06
22:08:00 UTC (rev 19667)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2010-01-06
23:23:08 UTC (rev 19668)
@@ -29,6 +29,7 @@
import org.eclipse.jst.server.core.IWebModule;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.Server;
import org.eclipse.wst.server.core.model.IURLProvider;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
@@ -138,12 +139,16 @@
}
public String getDeployFolder() {
- IJBossServerRuntime jbsrt = getRuntime();
- String type = getDeployLocationType();
+ return getDeployFolder(this, getDeployLocationType());
+ }
+
+ public static String getDeployFolder(JBossServer jbs, String type) {
+ IServer server = jbs.getServer();
+ IJBossServerRuntime jbsrt = getRuntime(server);
if( type.equals(DEPLOY_CUSTOM))
- return ServerUtil.makeGlobal(jbsrt, new Path(getAttribute(DEPLOY_DIRECTORY,
""))).toString(); //$NON-NLS-1$
+ return ServerUtil.makeGlobal(jbsrt, new Path(jbs.getAttribute(DEPLOY_DIRECTORY,
""))).toString(); //$NON-NLS-1$
if( type.equals(DEPLOY_METADATA)) {
- return JBossServerCorePlugin.getServerStateLocation(getServer()).
+ return JBossServerCorePlugin.getServerStateLocation(server).
append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
} else if( type.equals(DEPLOY_SERVER)) {
String config = jbsrt.getJBossConfiguration();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java 2010-01-06
22:08:00 UTC (rev 19667)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java 2010-01-06
23:23:08 UTC (rev 19668)
@@ -74,58 +74,36 @@
// server change event
if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
if( event.getServer().getServerState() == IServer.STATE_STARTED ) {
- if( shouldAddDeployLocation(event.getServer())) {
- IJMXRunnable r = new IJMXRunnable() {
- public void run(MBeanServerConnection connection) throws Exception {
- ensureDeployLocationAdded(event.getServer(), connection);
- }
- };
- try {
- JBossServerConnectionProvider.run(event.getServer(), r);
- } catch( JMXException jmxe ) {
- IStatus s = jmxe.getStatus();
- IStatus newStatus = new Status(s.getSeverity(), s.getPlugin(),
IEventCodes.ADD_DEPLOYMENT_FOLDER_FAIL,
- Messages.AddingJMXDeploymentFailed, s.getException());
- ServerLogger.getDefault().log(event.getServer(), newStatus);
+ IJMXRunnable r = new IJMXRunnable() {
+ public void run(MBeanServerConnection connection) throws Exception {
+ ensureDeployLocationAdded(event.getServer(), connection);
}
+ };
+ try {
+ JBossServerConnectionProvider.run(event.getServer(), r);
+ } catch( JMXException jmxe ) {
+ IStatus s = jmxe.getStatus();
+ IStatus newStatus = new Status(s.getSeverity(), s.getPlugin(),
IEventCodes.ADD_DEPLOYMENT_FOLDER_FAIL,
+ Messages.AddingJMXDeploymentFailed, s.getException());
+ ServerLogger.getDefault().log(event.getServer(), newStatus);
}
}
}
}
}
-
- protected boolean shouldAddDeployLocation(IServer server) {
- IDeployableServer ds = ServerConverter.getDeployableServer(server);
- boolean shouldAdd = server.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 = server.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 = ServerUtil.makeGlobal(jbsrt, deploy);
- if( new Path(deployFolder).equals(deployGlobal))
- shouldAdd = false;
- }
- }
- return shouldAdd;
- }
protected void ensureDeployLocationAdded(IServer server, MBeanServerConnection
connection) throws Exception {
- IDeployableServer ds = ServerConverter.getDeployableServer(server);
-
+ JBossServer ds = ServerConverter.getJBossServer(server);
ArrayList<String> folders = new ArrayList<String>();
- folders.add(ds.getDeployFolder());
+ // add the server folder deploy loc. first
+ String insideServer = JBossServer.getDeployFolder(ds, JBossServer.DEPLOY_SERVER);
+ String metadata = JBossServer.getDeployFolder(ds, JBossServer.DEPLOY_METADATA);
+ String custom = JBossServer.getDeployFolder(ds, JBossServer.DEPLOY_CUSTOM);
+ folders.add(insideServer);
+ if( !folders.contains(metadata))
+ folders.add(metadata);
+ if( !folders.contains(custom))
+ folders.add(custom);
IModule[] modules2 =
org.eclipse.wst.server.core.ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes());
if (modules2 != null) {
@@ -140,7 +118,7 @@
}
}
}
-
+ folders.remove(insideServer); // doesn't need to be added to deployment scanner
String[] folders2 = (String[]) folders.toArray(new String[folders.size()]);
for( int i = 0; i < folders2.length; i++ ) {
String asURL = new File(folders2[i]).toURL().toString();
Show replies by date