Author: rob.stryker(a)jboss.com
Date: 2012-08-07 04:04:39 -0400 (Tue, 07 Aug 2012)
New Revision: 42870
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractStartLaunchConfigurator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/JBossLaunchConfigProperties.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java
Log:
JBIDE-12229 to trunk
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractStartLaunchConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractStartLaunchConfigurator.java 2012-08-07
07:04:02 UTC (rev 42869)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractStartLaunchConfigurator.java 2012-08-07
08:04:39 UTC (rev 42870)
@@ -16,10 +16,12 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jst.j2ee.project.facet.JavaUtilityProjectCreationDataModelProvider;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.JavaUtils;
/**
* @author André Dietisheim
@@ -49,6 +51,7 @@
getProperties().setHost(getHost(jbossServer, jbossRuntime), launchConfig);
getProperties().setConfig(getServerConfig(jbossRuntime), launchConfig);
getProperties().setServerHome(getServerHome(jbossRuntime), jbossRuntime,
launchConfig);
+ getProperties().setServerFlag(getSupportsServerFlag(jbossRuntime), jbossRuntime,
launchConfig);
getProperties().setVmArguments(getDefaultVMArguments(jbossRuntime), launchConfig);
getProperties().setJreContainer(getJreContainerPath(jbossRuntime), launchConfig);
getProperties().setEndorsedDir(getEndorsedDir(jbossRuntime), launchConfig);
@@ -66,6 +69,7 @@
getProperties().setHost(getHost(jbossServer, jbossRuntime), launchConfig);
getProperties().setConfig(getServerConfig(jbossRuntime), launchConfig);
getProperties().setServerHome(getServerHome(jbossRuntime), jbossRuntime,
launchConfig);
+ getProperties().setServerFlag(getSupportsServerFlag(jbossRuntime), jbossRuntime,
launchConfig);
getProperties().setJreContainer(getJreContainerPath(jbossRuntime), launchConfig);
getProperties().setEndorsedDir(getEndorsedDir(jbossRuntime), launchConfig);
getProperties().setJavaLibPath(getJavaLibraryPath(jbossRuntime), launchConfig);
@@ -76,6 +80,11 @@
getProperties().setServerId(getServerId(jbossServer), launchConfig);
}
+ protected boolean getSupportsServerFlag(IJBossServerRuntime runtime) {
+ IVMInstall install = runtime.getVM();
+ return JavaUtils.supportsServerMode(install);
+ }
+
protected abstract String getEndorsedDir(IJBossServerRuntime runtime);
protected abstract String getJavaLibraryPath(IJBossServerRuntime runtime);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/JBossLaunchConfigProperties.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/JBossLaunchConfigProperties.java 2012-08-07
07:04:02 UTC (rev 42869)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/JBossLaunchConfigProperties.java 2012-08-07
08:04:39 UTC (rev 42870)
@@ -178,6 +178,15 @@
}
}
+ public void setServerFlag(boolean useFlag, IJBossServerRuntime runtime,
+ ILaunchConfigurationWorkingCopy launchConfig) throws CoreException {
+ String programArguments = getProgramArguments(launchConfig);
+ String newArgs = useFlag ?
+ ArgsUtil.setFlag(programArguments, IJBossRuntimeConstants.SERVER_ARG) :
+ ArgsUtil.clearFlag(programArguments, IJBossRuntimeConstants.SERVER_ARG);
+ setProgramArguments(newArgs, launchConfig);
+ }
+
public boolean isServerHomeSet(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
String value = ArgsUtil.getValue(getProgramArguments(launchConfig),
null,
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java 2012-08-07
07:04:02 UTC (rev 42869)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java 2012-08-07
08:04:39 UTC (rev 42870)
@@ -233,4 +233,27 @@
}
return original;
}
+
+ public static String setFlag(String original, String flagName) {
+ if( original.startsWith(flagName + SPACE ) || original.contains(SPACE + flagName +
SPACE) || original.endsWith(flagName))
+ return original;
+ return original.trim() + SPACE + flagName;
+ }
+
+ public static String clearFlag(String original, String flagName) {
+ if( original.trim().startsWith(flagName + SPACE))
+ return original.trim().substring(flagName.length()).trim();
+
+ if( original.contains(SPACE + flagName + SPACE)) {
+ return original.replace(SPACE + flagName + SPACE, SPACE).trim();
+ }
+
+ if( original.trim().endsWith(SPACE + flagName)) {
+ return original.trim().substring(0, original.trim().length() -
flagName.length()).trim();
+ }
+ if( original.trim().equals(flagName)) {
+ return ""; //$NON-NLS-1$
+ }
+ return original.trim();
+ }
}
\ No newline at end of file
Modified:
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java
===================================================================
---
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java 2012-08-07
07:04:02 UTC (rev 42869)
+++
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java 2012-08-07
08:04:39 UTC (rev 42870)
@@ -143,4 +143,14 @@
public String[] split(String val) {
return val.split(" ");
}
+
+ public void testSettingFlag() {
+ String original = "-Dsome.name=yes -server -Darg2=no";
+ String[] asArray = ArgsUtil.parse(original);
+ assertEquals(3, asArray.length);
+ String cleared = ArgsUtil.clearFlag(original, "-server");
+ assertEquals("-Dsome.name=yes -Darg2=no", cleared);
+ String set = ArgsUtil.setFlag(cleared, "-ser3");
+ assertEquals("-Dsome.name=yes -Darg2=no -ser3", set);
+ }
}