Author: rob.stryker(a)jboss.com
Date: 2010-08-05 23:23:27 -0400 (Thu, 05 Aug 2010)
New Revision: 23959
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
Log:
Cleanup of ugly legacy code which was meant to respond to changes in the launch config.
However for the past year, the launch config has instead updated itself based on the
server attributes so the launch config no longer needs to be updated manually
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
---
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2010-08-06
02:52:49 UTC (rev 23958)
+++
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2010-08-06
03:23:27 UTC (rev 23959)
@@ -10,37 +10,23 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal;
-import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
-import java.util.Map;
-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.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
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;
-import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
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.util.ArgsUtil;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;
/**
@@ -59,85 +45,16 @@
setAttribute("auto-publish-time", 1); //$NON-NLS-1$
setAttribute("id", getAttribute("id", (String)"") + new
Date().getTime()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
- public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
- // here we update the launch configuration with any details that might have changed.
- try {
- Server s = (Server)getServer();
- ILaunchConfiguration lc = s.getLaunchConfiguration(false, new NullProgressMonitor());
- if( lc != null ) {
- String startArgs =
lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- String originalArgs = startArgs;
- if( !getServer().getHost().equals(getHost(true)))
- startArgs = ArgsUtil.setArg(startArgs,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG,
- getServer().getHost());
-
- IJBossServerRuntime runtime = (IJBossServerRuntime)
- getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
- String config = runtime.getJBossConfiguration();
- startArgs = ArgsUtil.setArg(startArgs,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG, config);
-
- if( startArgs != null && !startArgs.trim().equals(originalArgs)) {
- ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
startArgs);
- wc.doSave();
- }
- }
- } catch( CoreException ce ) {
- IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.CannotSaveServersStartArgs, getServer().getName()), ce);
- JBossServerCorePlugin.getDefault().getLog().log(s);
- }
- }
public String getHost() {
- String host = getHost(true);
- return host == null ? getServer().getHost() : host;
+ return getServer().getHost();
}
-
- public String getHost(boolean checkLaunchConfig) {
- String host = null;
- if( checkLaunchConfig ) {
- try {
- Server s = (Server)getServer();
- ILaunchConfiguration lc = s.getLaunchConfiguration(true, new NullProgressMonitor());
- if(lc!=null) {
- String startArgs =
lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- String val = ArgsUtil.getValue(startArgs,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG);
- if( val != null ) {
- host = val;
- }
- }
- } catch( CoreException ce ) {}
- }
- return host;
- }
-
+
public String getConfigDirectory() {
- return getConfigDirectory(true);
+ IJBossServerRuntime runtime =
(IJBossServerRuntime)getServer().getRuntime().loadAdapter(IJBossServerRuntime.class,
null);
+ return runtime.getConfigLocationFullPath().toOSString();
}
- public String getConfigDirectory(boolean checkLaunchConfig) {
- if( !checkLaunchConfig )
- return getRuntimeConfigDirectory();
-
- String configDir = getLaunchConfigConfigurationDirectory();
- if( configDir == null )
- return getRuntimeConfigDirectory();
-
- File f = new File(configDir);
- if( !f.exists() || !f.canRead() || !f.isDirectory())
- return getRuntimeConfigDirectory();
-
- return new Path(configDir).toOSString();
- }
-
public String getDeployFolder() {
return getDeployFolder(this, getDeployLocationType());
}
@@ -167,11 +84,6 @@
return null;
}
- protected String getDeployFolder(boolean checkLaunchConfig) {
- return new Path(getConfigDirectory(checkLaunchConfig) + Path.SEPARATOR +
DEPLOY).toOSString();
- }
-
-
public String getTempDeployFolder() {
IJBossServerRuntime jbsrt = getRuntime();
String type = getDeployLocationType();
@@ -190,41 +102,7 @@
}
return null;
}
-
- protected String getLaunchConfigConfigurationDirectory() {
- try {
- Server s = (Server)getServer();
- ILaunchConfiguration lc = s.getLaunchConfiguration(true, new NullProgressMonitor());
- String startArgs =
lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- Map map = ArgsUtil.getSystemProperties(startArgs);
-
- if( map.get(JBOSS_SERVER_HOME_DIR) != null )
- return (String)map.get(JBOSS_SERVER_HOME_DIR);
-
- if( map.get(JBOSS_SERVER_BASE_DIR) != null ) {
- String name = map.get(JBOSS_SERVER_NAME) != null ?
- (String)map.get(JBOSS_SERVER_NAME) : DEFAULT_CONFIGURATION;
- return (String)map.get(JBOSS_SERVER_BASE_DIR) + Path.SEPARATOR + name;
- }
-
- if( map.get(JBOSS_HOME_DIR) != null ) {
- return (String)map.get(JBOSS_HOME_DIR) + Path.SEPARATOR + SERVER
- + Path.SEPARATOR + DEFAULT_CONFIGURATION;
- }
- } catch( CoreException ce ) {
- }
- return null;
- }
-
- protected String getRuntimeConfigDirectory() {
- IJBossServerRuntime runtime = (IJBossServerRuntime)
- getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
- String p = getServer().getRuntime().getLocation().toOSString() + Path.SEPARATOR +
SERVER +
- Path.SEPARATOR + runtime.getJBossConfiguration();
- return new Path(p).toOSString();
- }
-
public int getJNDIPort() {
return findPort(JNDI_PORT, JNDI_PORT_DETECT, JNDI_PORT_DETECT_XPATH,
JNDI_PORT_DEFAULT_XPATH, JNDI_DEFAULT_PORT);
@@ -258,8 +136,6 @@
return defaultValue;
}
-
-
public URL getModuleRootURL(IModule module) {
if (module == null || module.loadAdapter(IWebModule.class,null)==null )
Show replies by date