Author: adietish
Date: 2011-06-27 18:07:56 -0400 (Mon, 27 Jun 2011)
New Revision: 32379
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractStartupConfigurator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/ILaunchConfigConfigurator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossRuntimeLaunchConfigUtils.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossStartupConfigurator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartLaunchDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7StartupConfigurator.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/JBossLaunchConfigTests.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigConfiguratorFactory.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigTests.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/MockLaunchConfigWorkingCopy.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
Log:
[JBIDE-9215] moved startup launch config to own config builder for jboss as and as7
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2011-06-27
22:03:27 UTC (rev 32378)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -66,6 +66,7 @@
// override me
}
+ @Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
preLaunch(configuration, mode, launch, monitor);
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractStartupConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractStartupConfigurator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractStartupConfigurator.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.launch;
+
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setClasspath;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setClasspathProvider;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setConfig;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setEndorsedDir;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setEnvironmentVariables;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setHost;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setJreContainer;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setMainType;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setProgramArguments;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setServerId;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setUseDefaultClassPath;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setWorkingDirectory;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.setVmArguments;
+
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+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.ServerConverter;
+
+public abstract class AbstractStartupConfigurator implements ILaunchConfigConfigurator {
+
+ private static final String DEFAULT_CP_PROVIDER_ID =
"org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider";
///$NON-NLS-1$
+ private static final String DEFAULTS_SET = "DEFAULTS_SET"; //$NON-NLS-1$
+
+ private JBossServer jbossServer;
+ private IJBossServerRuntime jbossRuntime;
+
+ public AbstractStartupConfigurator(IServer server) throws CoreException {
+ this.jbossServer = ServerConverter.checkedGetJBossServer(server);
+ this.jbossRuntime = jbossServer.getRuntime();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.ide.eclipse.as.core.server.internal.launch.
+ * ILaunchConfigConfigurator
+ * #configure(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void configure(ILaunchConfigurationWorkingCopy launchConfig) throws CoreException
{
+ if (!areDefaultsSet(launchConfig)) {
+ doConfigure(launchConfig);
+ setDefaultsSet(launchConfig);
+ }
+ }
+
+ protected void doConfigure(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ setProgramArguments(getDefaultProgramArguments(jbossServer, jbossRuntime),
launchConfig);
+ setHost(getHost(jbossServer, jbossRuntime), launchConfig);
+ setConfig(getServerConfig(jbossRuntime), launchConfig);
+ setServerHome(getServerHome(jbossRuntime), jbossRuntime, launchConfig);
+ setVmArguments(getDefaultVMArguments(jbossRuntime), launchConfig);
+ setJreContainer(getJreContainerPath(jbossRuntime), launchConfig);
+ setEndorsedDir(getEndorsedDir(jbossRuntime), launchConfig);
+ setMainType(getMainType(), launchConfig);
+ setWorkingDirectory(getWorkingDirectory(jbossServer, jbossRuntime), launchConfig);
+ setEnvironmentVariables(getEnvironmentVariables(jbossRuntime), launchConfig);
+ setClasspathProvider(getClasspathProvider(), launchConfig);
+ setClasspath(getClasspath(jbossServer, jbossRuntime,
JBossRuntimeLaunchConfigUtils.getClasspath(launchConfig)), launchConfig);
+ setUseDefaultClassPath(false, launchConfig);
+ setServerId(getServerId(jbossServer), launchConfig);
+ setDefaultsSet(launchConfig);
+ }
+
+ protected abstract String getEndorsedDir(IJBossServerRuntime runtime);
+
+ protected abstract String getServerConfig(IJBossServerRuntime runtime);
+
+ protected abstract String getServerHome(IJBossServerRuntime runtime);
+
+ private void setServerHome(String serverHome, IJBossServerRuntime runtime,
+ ILaunchConfigurationWorkingCopy launchConfig) throws CoreException {
+ if (!isCustomConfigLocation(runtime)) {
+ JBossRuntimeLaunchConfigUtils.setServerHome(serverHome, runtime, launchConfig);
+ }
+ }
+
+ protected boolean isCustomConfigLocation(IJBossServerRuntime runtime) {
+ return runtime.getConfigLocation().equals(IJBossRuntimeResourceConstants.SERVER);
+ }
+
+ protected String getClasspathProvider() {
+ return DEFAULT_CP_PROVIDER_ID;
+ }
+
+ protected Map<String, String> getEnvironmentVariables(IJBossServerRuntime runtime)
{
+ return runtime.getDefaultRunEnvVars();
+ }
+
+ protected abstract String getDefaultProgramArguments(JBossServer server,
IJBossServerRuntime runtime);
+
+ protected abstract String getDefaultVMArguments(IJBossServerRuntime runtime);
+
+ protected String getJreContainerPath(IJBossServerRuntime runtime) {
+ IVMInstall vmInstall = runtime.getVM();
+ if (vmInstall == null) {
+ return null;
+ }
+ return JavaRuntime.newJREContainerPath(vmInstall).toPortableString();
+ }
+
+ protected abstract List<String> getClasspath(JBossServer server,
IJBossServerRuntime runtime, List<String> currentClasspath) throws CoreException;
+
+ protected abstract String getMainType();
+
+ protected abstract String getWorkingDirectory(JBossServer server, IJBossServerRuntime
jbossRuntime)
+ throws CoreException;
+
+ protected String getServerId(JBossServer server) {
+ return server.getServer().getId();
+ }
+
+ protected abstract String getHost(JBossServer server, IJBossServerRuntime runtime);
+
+ private boolean areDefaultsSet(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ return launchConfig.hasAttribute(DEFAULTS_SET);
+ }
+
+ private void setDefaultsSet(ILaunchConfigurationWorkingCopy launchConfig) {
+ launchConfig.setAttribute(DEFAULTS_SET, true);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractStartupConfigurator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/ILaunchConfigConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/ILaunchConfigConfigurator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/ILaunchConfigConfigurator.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,10 @@
+package org.jboss.ide.eclipse.as.core.server.internal.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+
+public interface ILaunchConfigConfigurator {
+
+ public abstract void configure(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException;
+
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/ILaunchConfigConfigurator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossRuntimeLaunchConfigUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossRuntimeLaunchConfigUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossRuntimeLaunchConfigUtils.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.launch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+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;
+
+/**
+ * @author André Dietisheim
+ */
+public class JBossRuntimeLaunchConfigUtils {
+
+ public static void setClasspath(List<String> entries,
ILaunchConfigurationWorkingCopy launchConfig) {
+ if (isSet(entries)) {
+ launchConfig.setAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, entries);
+ }
+ }
+
+ public static boolean isClasspathSet(ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
+ return launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH);
+ }
+
+ public static void setUseDefaultClassPath(boolean useDefaultClassPath,
ILaunchConfigurationWorkingCopy launchConfig) {
+ launchConfig.setAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, useDefaultClassPath);
+ }
+
+ public static boolean isDefaultClasspathSet(ILaunchConfigurationWorkingCopy
launchConfig) throws CoreException {
+ return
launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH);
+ }
+
+ public static void setMainType(String mainType, ILaunchConfigurationWorkingCopy
launchConfig) {
+ if (isSet(mainType)) {
+ launchConfig.setAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainType);
+ }
+ }
+
+ public static boolean isMainTypeSet(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ return
launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME);
+ }
+
+ public static void setWorkingDirectory(String directory, ILaunchConfigurationWorkingCopy
launchConfig) {
+ if (isSet(directory)) {
+ launchConfig.setAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, directory);
+ }
+ }
+
+ public static boolean isWorkingDirectorySet(ILaunchConfigurationWorkingCopy
launchConfig) throws CoreException {
+ return
launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY);
+ }
+
+ public static void setServerId(String serverId, ILaunchConfigurationWorkingCopy
launchConfig) {
+ if (isSet(serverId)) {
+ launchConfig.setAttribute(
+ AbstractJBossLaunchConfigType.SERVER_ID, serverId);
+ }
+ }
+
+ public static boolean isServerIdSet(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ return launchConfig.hasAttribute(AbstractJBossLaunchConfigType.SERVER_ID);
+ }
+
+ public static void setHost(String host, ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
+ if (isSet(host)) {
+ String currentHost = getHost(launchConfig);
+ if (currentHost == null
+ || !host.equals(currentHost)) {
+ String programArguments = getProgramArguments(launchConfig);
+ programArguments = ArgsUtil.setArg(programArguments,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG,
+ host);
+ setProgramArguments(programArguments, launchConfig);
+ }
+ }
+ }
+
+ public static boolean isHostSet(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ String value = ArgsUtil.getValue(getProgramArguments(launchConfig),
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG);
+ return value != null;
+ }
+
+ public static void setProgramArguments(String programArguments,
ILaunchConfigurationWorkingCopy launchConfig)
+ throws CoreException {
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
programArguments);
+ }
+
+ public static String getProgramArguments(ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
+ return
launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
""); //$NON-NLS-1$;
+ }
+
+ public static boolean areProgramArgumentsSet(ILaunchConfigurationWorkingCopy
launchConfig) throws CoreException {
+ return
launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS);
+ }
+
+ public static boolean isConfigSet(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ String value = ArgsUtil.getValue(getProgramArguments(launchConfig),
+ IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG);
+ return value != null;
+ }
+
+ public static String getHost(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ return ArgsUtil.getValue(getProgramArguments(launchConfig),
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG);
+ }
+
+ public static void setConfig(String config, ILaunchConfigurationWorkingCopy
launchConfig) throws CoreException {
+ if (isSet(config)) {
+ String programArguments = getProgramArguments(launchConfig);
+ programArguments = ArgsUtil.setArg(programArguments,
+ IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG, config);
+ setProgramArguments(programArguments, launchConfig);
+ }
+ }
+
+ public static void setJreContainer(String vmContainerPath,
ILaunchConfigurationWorkingCopy launchConfig) {
+ if (isSet(vmContainerPath)) {
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,
vmContainerPath);
+ }
+ }
+
+ public static boolean isJreContainerSet(ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
+ return
launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH);
+ }
+
+ public static void setServerHome(String serverHome, IJBossServerRuntime runtime,
+ ILaunchConfigurationWorkingCopy launchConfig) throws CoreException {
+ if (isSet(serverHome)) {
+ String programArguments = getProgramArguments(launchConfig);
+ String arguments = ArgsUtil.setArg(programArguments,
+ null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JBOSS_SERVER_HOME_URL,
+ serverHome);
+ setProgramArguments(arguments, launchConfig);
+ }
+ }
+
+ public static boolean isServerHomeSet(ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
+ String value = ArgsUtil.getValue(getProgramArguments(launchConfig),
+ null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JBOSS_SERVER_HOME_URL);
+ return value != null;
+ }
+
+ public static void setClasspathProvider(String classpathProvider,
ILaunchConfigurationWorkingCopy launchConfig) {
+ if (isSet(classpathProvider)) {
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
classpathProvider);
+ }
+ }
+
+ public static boolean isClasspathProviderSet(ILaunchConfigurationWorkingCopy
launchConfig) throws CoreException {
+ return
launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER);
+ }
+
+ public static void setEndorsedDir(String endorsedDir, ILaunchConfigurationWorkingCopy
launchConfig)
+ throws CoreException {
+ if (isSet(endorsedDir)) {
+ String vmArguments = getVMArguments(launchConfig);
+ vmArguments = ArgsUtil.setArg(vmArguments,
+ null, IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
endorsedDir);
+ setVmArguments(vmArguments, launchConfig);
+ }
+ }
+
+ public static boolean isEndorsedDirSet(ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
+ String value = ArgsUtil.getValue(getVMArguments(launchConfig),
+ null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS);
+ return value != null;
+ }
+
+ public static void setVmArguments(String vmArguments, ILaunchConfigurationWorkingCopy
launchConfig) {
+ if (isSet(vmArguments)) {
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
vmArguments);
+ }
+ }
+
+ public static String getVMArguments(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ return launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
""); //$NON-NLS-1$
+ }
+
+ public static boolean areVMArgumentsSet(ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
+ return launchConfig.hasAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS);
+ }
+
+ public static void setEnvironmentVariables(Map<String, String>
environmentVariables,
+ ILaunchConfigurationWorkingCopy launchConfig) {
+ if (isSet(environmentVariables)) {
+ launchConfig.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,
environmentVariables);
+ }
+ }
+
+ public static boolean areEnvironmentVariablesSet(ILaunchConfigurationWorkingCopy
launchConfig) throws CoreException {
+ return launchConfig.hasAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static List<String> getClasspath(ILaunchConfigurationWorkingCopy
launchConfig) throws CoreException {
+ return (List<String>) launchConfig.getAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, new ArrayList<String>());
+ }
+
+ private static boolean isSet(String value) {
+ return value != null && value.length() > 0;
+ }
+
+ private static boolean isSet(List<String> list) {
+ return list != null;
+ }
+
+ private static boolean isSet(Map<String, String> map) {
+ return map != null;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossRuntimeLaunchConfigUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossStartupConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossStartupConfigurator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossStartupConfigurator.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.launch;
+
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+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.IJBossRuntimeConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
+
+public class JBossStartupConfigurator extends AbstractStartupConfigurator {
+
+ public JBossStartupConfigurator(IServer server) throws CoreException {
+ super(server);
+ }
+
+ @Override
+ protected String getMainType() {
+ return IJBossRuntimeConstants.START_MAIN_TYPE;
+ }
+
+ @Override
+ protected String getWorkingDirectory(JBossServer server, IJBossServerRuntime runtime)
throws CoreException {
+ return ServerUtil.checkedGetServerHome(server)
+ + Path.SEPARATOR
+ + IJBossRuntimeResourceConstants.BIN;
+ }
+
+ @Override
+ protected List<String> getClasspath(JBossServer server, IJBossServerRuntime
runtime, List<String> currentClasspath) throws CoreException {
+ try {
+ boolean replaced = replaceRunJarContainer(server, currentClasspath);
+ if (!replaced) {
+ String runJarEntry =
LaunchConfigUtils.getRunJarRuntimeCPEntry(server.getServer()).getMemento();
+ currentClasspath.add(runJarEntry);
+ }
+ return currentClasspath;
+ } catch (CoreException ce) {
+ return currentClasspath;
+ }
+ }
+
+ private boolean replaceRunJarContainer(JBossServer server, List<String>
classpath)
+ throws CoreException {
+ boolean replaced = false;
+ for (int i = 0; i < classpath.size(); i++) {
+ String classPathEntry = classpath.get(0);
+ if (classPathEntry.contains(RunJarContainerWrapper.ID)) {
+ replaced = true;
+ classpath.set(i,
LaunchConfigUtils.getRunJarRuntimeCPEntry(server.getServer()).getMemento());
+ }
+ }
+ return replaced;
+ }
+
+ @Override
+ protected String getHost(JBossServer server, IJBossServerRuntime runtime) {
+ return server.getServer().getHost();
+ }
+
+ @Override
+ protected String getServerHome(IJBossServerRuntime runtime) {
+ String serverHome = null;
+ try {
+ serverHome = runtime.getConfigLocationFullPath().toFile().toURL().toString();
+ } catch (MalformedURLException murle) {
+ }
+ return serverHome;
+ }
+
+ @Override
+ protected String getServerConfig(IJBossServerRuntime runtime) {
+ return runtime.getJBossConfiguration();
+ }
+
+ @Override
+ protected String getEndorsedDir(IJBossServerRuntime runtime) {
+ return runtime.getRuntime().getLocation().append(
+ IJBossRuntimeResourceConstants.LIB).append(
+ IJBossRuntimeResourceConstants.ENDORSED).toOSString();
+ }
+
+ @Override
+ protected String getDefaultProgramArguments(JBossServer server, IJBossServerRuntime
runtime) {
+ return runtime.getDefaultRunArgs() +
+ IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT +
+ IJBossRuntimeConstants.SPACE + server.getServer().getHost();
+ }
+
+ @Override
+ protected String getDefaultVMArguments(IJBossServerRuntime runtime) {
+ // not needed
+ return null;
+ }
+
+
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossStartupConfigurator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartLaunchDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartLaunchDelegate.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartLaunchDelegate.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.launch;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.StandardClasspathProvider;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.extensions.polling.WebPortPoller;
+import org.jboss.ide.eclipse.as.core.server.internal.AbstractLocalJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
+import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossBehaviorDelegate;
+import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.IStartLaunchSetupParticipant;
+import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.StartLaunchDelegate;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.JBossServerBehaviorUtils;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+
+/**
+ * @author Rob Stryker
+ * @author André Dietisheim
+ */
+public class LocalJBossServerStartLaunchDelegate implements StartLaunchDelegate,
IStartLaunchSetupParticipant {
+
+ public void setupLaunchConfiguration(
+ ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
+ new JBossStartupConfigurator(server).configure(workingCopy);
+ }
+
+ /*
+ * Actual instance methods
+ */
+ public void actualLaunch(
+ JBossServerStartupLaunchConfiguration launchConfig,
+ ILaunchConfiguration configuration, String mode, ILaunch launch,
+ IProgressMonitor monitor) throws CoreException {
+ launchConfig.superActualLaunch(configuration, mode, launch, monitor);
+ }
+
+ public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode,
IProgressMonitor monitor)
+ throws CoreException {
+ JBossServerBehavior jbsBehavior =
JBossServerBehaviorUtils.getServerBehavior(configuration);
+ if (!jbsBehavior.canStart(mode).isOK())
+ throw new CoreException(jbsBehavior.canStart(mode));
+ String ignore =
jbsBehavior.getServer().getAttribute(IJBossToolingConstants.IGNORE_LAUNCH_COMMANDS,
+ (String) null);
+ Boolean ignoreB = ignore == null ? new Boolean(false) : new Boolean(ignore);
+ if (ignoreB.booleanValue()) {
+ jbsBehavior.setServerStarting();
+ jbsBehavior.setServerStarted();
+ return false;
+ }
+ boolean started = WebPortPoller.onePing(jbsBehavior.getServer());
+ if (started) {
+ jbsBehavior.setServerStarting();
+ jbsBehavior.setServerStarted();
+ return false;
+ }
+
+ return true;
+ }
+
+ public void preLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ try {
+ JBossServerBehavior jbsBehavior =
JBossServerBehaviorUtils.getServerBehavior(configuration);
+ jbsBehavior.setRunMode(mode);
+ jbsBehavior.serverStarting();
+ } catch (CoreException ce) {
+ // report it
+ }
+ }
+
+ public void postLaunch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ try {
+ IProcess[] processes = launch.getProcesses();
+ JBossServerBehavior jbsBehavior =
JBossServerBehaviorUtils.getServerBehavior(configuration);
+ ((LocalJBossBehaviorDelegate) (jbsBehavior.getDelegate())).setProcess(processes[0]);
+ } catch (CoreException ce) {
+ // report
+ }
+ }
+
+ public static class JBossServerDefaultClasspathProvider extends
StandardClasspathProvider {
+ public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration
configuration)
+ throws CoreException {
+ boolean useDefault =
configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
+ true);
+ if (useDefault) {
+ return defaultEntries(configuration);
+ }
+ return super.computeUnresolvedClasspath(configuration);
+ }
+
+ protected IRuntimeClasspathEntry[] defaultEntries(ILaunchConfiguration config) {
+ try {
+ String server = config.getAttribute(AbstractJBossLaunchConfigType.SERVER_ID, (String)
null);
+ IServer s = ServerCore.findServer(server);
+ AbstractLocalJBossServerRuntime ibjsrt = (AbstractLocalJBossServerRuntime)
+ s.getRuntime().loadAdapter(AbstractLocalJBossServerRuntime.class, new
NullProgressMonitor());
+ JBossServer jbs = (JBossServer) s.loadAdapter(JBossServer.class, new
NullProgressMonitor());
+ IVMInstall install = ibjsrt.getVM();
+ ArrayList<IRuntimeClasspathEntry> list = new
ArrayList<IRuntimeClasspathEntry>();
+ LaunchConfigUtils.addJREEntry(install, list);
+ list.add(LaunchConfigUtils.getRunJarRuntimeCPEntry(s));
+ return (IRuntimeClasspathEntry[]) list
+ .toArray(new IRuntimeClasspathEntry[list.size()]);
+ } catch (CoreException ce) {
+ // ignore
+ }
+
+ try {
+ return super.computeUnresolvedClasspath(config);
+ } catch (CoreException ce) {
+ // ignore
+ }
+ return new IRuntimeClasspathEntry[] {};
+ }
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartLaunchDelegate.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java 2011-06-27
22:03:27 UTC (rev 32378)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -10,51 +10,34 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal.launch;
-import java.net.MalformedURLException;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import org.eclipse.core.runtime.CoreException;
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.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.StandardClasspathProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.polling.WebPortPoller;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.AbstractLocalJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossBehaviorDelegate;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.IStartLaunchSetupParticipant;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.StartLaunchDelegate;
-import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
-import org.jboss.ide.eclipse.as.core.util.IConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.JBossServerBehaviorUtils;
import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
-import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.core.util.ServerUtil;
/**
* @author Rob Stryker
@@ -69,180 +52,9 @@
public void setupLaunchConfiguration(
ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
- JBossServer jbs = ServerConverter.checkedGetJBossServer(server);
- if (!workingCopy.getAttributes().containsKey(DEFAULTS_SET)) {
- forceDefaultsSet(workingCopy, jbs);
- }
-
- upgradeOldLaunchConfig(workingCopy, jbs);
-
- // Force the launch to get certain fields from the runtime
- updateMandatedFields(workingCopy, jbs);
+ new JBossStartupConfigurator(server).configure(workingCopy);
}
- private void upgradeOldLaunchConfig(ILaunchConfigurationWorkingCopy workingCopy,
JBossServer jbs)
- throws CoreException {
- String cpProvider = workingCopy.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String) null);
- if (!DEFAULT_CP_PROVIDER_ID.equals(cpProvider)) {
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
DEFAULT_CP_PROVIDER_ID);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
getClasspath(jbs));
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
false);
- }
- }
-
- /*
- * Ensures that the working directory and classpath are 100% accurate.
- * Merges proper required params into args and vm args
- */
- protected void updateMandatedFields(ILaunchConfigurationWorkingCopy wc, JBossServer
jbs)
- throws CoreException {
- String serverHome = ServerUtil.checkedGetServerHome(jbs);
- IJBossServerRuntime runtime =
RuntimeUtils.checkedGetJBossServerRuntime(jbs.getServer());
-
- updateVMPath(runtime, wc);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- serverHome + Path.SEPARATOR + IJBossRuntimeResourceConstants.BIN);
- updateProgramArguments(wc, jbs, runtime);
- updateVMArgs(wc, runtime);
- updateClassPath(wc, jbs);
- wc.setAttribute(AbstractJBossLaunchConfigType.SERVER_ID, jbs.getServer().getId());
- }
-
- private void updateVMPath(IJBossServerRuntime runtime, ILaunchConfigurationWorkingCopy
wc) {
- IVMInstall vmInstall = runtime.getVM();
- if (vmInstall != null)
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,
- JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
- }
-
- private void updateClassPath(ILaunchConfigurationWorkingCopy wc, JBossServer jbs) throws
CoreException {
- List<String> newCP = updateRunJarEntry(wc, jbs);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, newCP);
- }
-
- private void updateVMArgs(ILaunchConfigurationWorkingCopy wc, IJBossServerRuntime
runtime) throws CoreException {
- String vmArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
""); //$NON-NLS-1$
- vmArgs = updateEndorsedDir(vmArgs, runtime);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.trim());
- }
-
- private void updateProgramArguments(ILaunchConfigurationWorkingCopy wc, JBossServer jbs,
IJBossServerRuntime runtime)
- throws CoreException {
- String args = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
""); //$NON-NLS-1$
- String host = jbs.getServer().getHost();
- args = updateHostArgument(host, args);
- args = updateConfigArgument(args, runtime);
- args = updateServerHomeArgument(args, runtime);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
args.trim());
- }
-
- private String updateEndorsedDir(String vmArgs, IJBossServerRuntime runtime) {
- return ArgsUtil.setArg(vmArgs, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
- runtime.getRuntime().getLocation().append(
- IJBossRuntimeResourceConstants.LIB).append(
- IJBossRuntimeResourceConstants.ENDORSED).toOSString(), true);
- }
-
- private String updateConfigArgument(String args, IJBossServerRuntime runtime) {
- String config = runtime.getJBossConfiguration();
- args = ArgsUtil.setArg(args,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG, config);
- return args;
- }
-
- private String updateServerHomeArgument(String args, IJBossServerRuntime runtime) {
-
- try {
- if (!runtime.getConfigLocation().equals(IConstants.SERVER)) {
- args = ArgsUtil.setArg(args, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JBOSS_SERVER_HOME_URL,
- runtime.getConfigLocationFullPath().toFile().toURL().toString());
- }
- } catch (MalformedURLException murle) {
- }
- return args;
- }
-
- private String updateHostArgument(String host, String args) {
- String argsHost = ArgsUtil.getValue(args,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG);
-
- if (!host.equals(argsHost))
- args = ArgsUtil.setArg(args,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG, host);
- return args;
- }
-
- protected List<String> updateRunJarEntry(ILaunchConfigurationWorkingCopy wc,
JBossServer jbs) throws CoreException {
- List<String> cp =
wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, new
ArrayList<String>());
- try {
- boolean found = false;
- String[] asString = (String[]) cp.toArray(new String[cp.size()]);
- for (int i = 0; i < asString.length; i++) {
- if (asString[i].contains(RunJarContainerWrapper.ID)) {
- found = true;
- asString[i] =
LaunchConfigUtils.getRunJarRuntimeCPEntry(jbs.getServer()).getMemento();
- }
- }
- List<String> result = new ArrayList<String>();
- result.addAll(Arrays.asList(asString));
- if (!found)
- result.add(LaunchConfigUtils.getRunJarRuntimeCPEntry(jbs.getServer()).getMemento());
- return result;
- } catch (CoreException ce) {
- return cp;
- }
- }
-
- protected void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, JBossServer jbs)
throws CoreException {
- String serverHome = ServerUtil.checkedGetServerHome(jbs);
- IJBossServerRuntime jbrt = RuntimeUtils.checkedGetJBossServerRuntime(jbs.getServer());
- updateVMPath(jbrt, wc);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
getDefaultArgs(jbs));
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
jbrt.getDefaultRunVMArgs());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
START_MAIN_TYPE);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR
- + IJBossRuntimeResourceConstants.BIN);
- wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,
jbrt.getDefaultRunEnvVars());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClasspath(jbs));
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
DEFAULT_CP_PROVIDER_ID);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
-
- wc.setAttribute(DEFAULTS_SET, true);
- }
-
- private List<String> getClasspath(JBossServer jbs) throws CoreException {
- IJBossServerRuntime jbrt = RuntimeUtils.checkedGetJBossServerRuntime(jbs.getServer());
- ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- classpath.add(LaunchConfigUtils.getRunJarRuntimeCPEntry(jbs.getServer()));
- LaunchConfigUtils.addJREEntry(jbrt.getVM(), classpath);
-
- String version = jbs.getServer().getRuntime().getRuntimeType().getVersion();
- if (version.equals(IJBossToolingConstants.AS_40))
- LaunchConfigUtils.addToolsJar(jbrt.getVM(), classpath);
-
- List<String> runtimeClassPaths = LaunchConfigUtils.toStrings(classpath);
- return runtimeClassPaths;
- }
-
- protected String getDefaultArgs(JBossServer jbs) throws CoreException {
- IJBossServerRuntime rt = RuntimeUtils.checkedGetJBossServerRuntime(jbs.getServer());
- if (rt != null) {
- return rt.getDefaultRunArgs() +
- IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT +
- IJBossRuntimeConstants.SPACE + jbs.getServer().getHost();
- }
- return null;
- }
-
- /* For "restore defaults" functionality */
- private static final String DEFAULT_CP_PROVIDER_ID =
"org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider";
//$NON-NLS-1$
-
public static class JBossServerDefaultClasspathProvider extends
StandardClasspathProvider {
public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration
configuration)
throws CoreException {
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java 2011-06-27
22:03:27 UTC (rev 32378)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.ide.eclipse.as.core.server.internal.v7;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IRuntime;
-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.launch.AbstractJBossLaunchConfigType;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
-import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
-import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
-
-public class JBoss7RuntimeLaunchConfigurator {
-
- private static final String DEFAULTS_SET = "DEFAULTS_SET"; //$NON-NLS-1$
- private ILaunchConfigurationWorkingCopy launchConfig;
-
- public JBoss7RuntimeLaunchConfigurator(ILaunchConfigurationWorkingCopy launchConfig) {
- this.launchConfig = launchConfig;
- }
-
- public void apply(IServer server) throws CoreException {
- if (!areDefaultsSet()) {
- IRuntime runtime = server.getRuntime();
- IJBossServerRuntime jbossRuntime = RuntimeUtils.checkedGetJBossServerRuntime(server);
- setVmContainer(jbossRuntime)
- .setClassPath(server, jbossRuntime)
- .setDefaultArguments(jbossRuntime)
- .setMainType(IJBossRuntimeConstants.START7_MAIN_TYPE)
- .setWorkingDirectory(runtime)
- .setServerId(server)
- .setDefaultsSet();
- }
- }
-
- private JBoss7RuntimeLaunchConfigurator setVmContainer(IJBossServerRuntime jbossRuntime)
{
- IVMInstall vmInstall = jbossRuntime.getVM();
- if (vmInstall != null) {
- setVmContainer(JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
- }
- return this;
- }
-
- private JBoss7RuntimeLaunchConfigurator setVmContainer(String vmPath) {
- launchConfig.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmPath);
- return this;
- }
-
- private JBoss7RuntimeLaunchConfigurator setDefaultArguments(IJBossServerRuntime
jbossRuntime) {
- launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
- jbossRuntime.getDefaultRunArgs());
- launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- jbossRuntime.getDefaultRunVMArgs());
- return this;
- }
-
- private JBoss7RuntimeLaunchConfigurator setClassPath(IServer server, IJBossServerRuntime
jbossRuntime)
- throws CoreException {
- return setClassPath(getClasspath(server, jbossRuntime.getVM()));
- }
-
- private List<String> getClasspath(IServer server, IVMInstall vmInstall) throws
CoreException {
- List<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- classpath.add(LaunchConfigUtils.getModulesClasspathEntry(server));
- LaunchConfigUtils.addJREEntry(vmInstall, classpath);
- List<String> runtimeClassPaths = LaunchConfigUtils.toStrings(classpath);
- return runtimeClassPaths;
- }
-
- private JBoss7RuntimeLaunchConfigurator setClassPath(List<String> entries) throws
CoreException {
- launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
- JBoss7ServerBehavior.DEFAULT_CP_PROVIDER_ID);
- launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, entries);
- launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
false);
- return this;
- }
-
- private JBoss7RuntimeLaunchConfigurator setMainType(String mainType) {
- launchConfig.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainType);
- return this;
- }
-
- private JBoss7RuntimeLaunchConfigurator setWorkingDirectory(IRuntime runtime) {
- setWorkingDirectory(runtime.getLocation().append(IJBossRuntimeResourceConstants.BIN).toString());
- return this;
- }
-
- private JBoss7RuntimeLaunchConfigurator setWorkingDirectory(String directory) {
- launchConfig.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, directory);
- return this;
- }
-
- private JBoss7RuntimeLaunchConfigurator setServerId(IServer server) {
- launchConfig.setAttribute(AbstractJBossLaunchConfigType.SERVER_ID, server.getId());
- return this;
- }
-
- private boolean areDefaultsSet() throws CoreException {
- return launchConfig.hasAttribute(DEFAULTS_SET);
- }
-
- private void setDefaultsSet() {
- launchConfig.setAttribute(DEFAULTS_SET, true);
- }
-}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-06-27
22:03:27 UTC (rev 32378)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -29,8 +29,6 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.wst.server.core.IModule;
-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.Messages;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
@@ -76,9 +74,7 @@
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy launchConfig,
IProgressMonitor monitor)
throws CoreException {
- IServer server = getServer();
- IRuntime runtime = server.getRuntime();
- new JBoss7RuntimeLaunchConfigurator(launchConfig).apply(server);
+ new JBoss7StartupConfigurator(getServer()).configure(launchConfig);
}
public void setProcess(IProcess process) {
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7StartupConfigurator.java
(from rev 32343,
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7StartupConfigurator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7StartupConfigurator.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.internal.v7;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+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.server.internal.launch.AbstractStartupConfigurator;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+
+public class JBoss7StartupConfigurator extends AbstractStartupConfigurator {
+
+ public JBoss7StartupConfigurator(IServer server) throws CoreException {
+ super(server);
+ }
+
+ @Override
+ protected String getMainType() {
+ return IJBossRuntimeConstants.START7_MAIN_TYPE;
+ }
+
+ @Override
+ protected String getWorkingDirectory(JBossServer server, IJBossServerRuntime runtime)
throws CoreException {
+ return runtime.getRuntime().getLocation()
+ .append(IJBossRuntimeResourceConstants.BIN)
+ .toString();
+ }
+
+ @Override
+ protected List<String> getClasspath(JBossServer server, IJBossServerRuntime
runtime, List<String> currentClasspath) throws CoreException {
+ IVMInstall vmInstall = runtime.getVM();
+ List<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
+ classpath.add(LaunchConfigUtils.getModulesClasspathEntry(server));
+ LaunchConfigUtils.addJREEntry(vmInstall, classpath);
+ List<String> runtimeClassPaths = LaunchConfigUtils.toStrings(classpath);
+ return runtimeClassPaths;
+ }
+
+ @Override
+ protected String getHost(JBossServer server, IJBossServerRuntime runtime) {
+ // not needed
+ return null;
+ }
+
+ @Override
+ protected String getDefaultProgramArguments(JBossServer server, IJBossServerRuntime
runtime) {
+ return runtime.getDefaultRunArgs();
+ }
+
+ @Override
+ protected String getServerHome(IJBossServerRuntime runtime) {
+ // not needed
+ return null;
+ }
+
+ @Override
+ protected String getServerConfig(IJBossServerRuntime runtime) {
+ // not needed
+ return null;
+ }
+
+ @Override
+ protected String getEndorsedDir(IJBossServerRuntime runtime) {
+ // not needed
+ return null;
+ }
+
+ @Override
+ protected String getDefaultVMArguments(IJBossServerRuntime runtime) {
+ return runtime.getDefaultRunVMArgs();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7StartupConfigurator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/JBossLaunchConfigTests.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/JBossLaunchConfigTests.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/JBossLaunchConfigTests.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.test.launch;
+
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.areEnvironmentVariablesSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.areProgramArgumentsSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.areVMArgumentsSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isClasspathProviderSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isClasspathSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isConfigSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isDefaultClasspathSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isEndorsedDirSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isHostSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isJreContainerSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isMainTypeSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isServerHomeSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isServerIdSet;
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isWorkingDirectorySet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class JBossLaunchConfigTests extends LaunchConfigTests {
+
+ private IServer mockServer;
+
+ @Override
+ protected void setUp() throws Exception {
+ this.mockServer = ServerRuntimeUtils.createMockJBoss7Server();
+ }
+
+ public void testConfiguration() throws CoreException {
+ ILaunchConfigurationWorkingCopy launchConfig =
LaunchConfigConfiguratorFactory.createCustomConfigLocationLaunchConfig(mockServer);
+
+ assertTrue(areProgramArgumentsSet(launchConfig));
+ assertTrue(areVMArgumentsSet(launchConfig));
+ assertTrue(isHostSet(launchConfig));
+ assertTrue(isMainTypeSet(launchConfig));
+ assertTrue(isWorkingDirectorySet(launchConfig));
+ assertTrue(areEnvironmentVariablesSet(launchConfig));
+ assertTrue(isClasspathSet(launchConfig));
+ assertTrue(isClasspathProviderSet(launchConfig));
+ assertTrue(isDefaultClasspathSet(launchConfig));
+ assertTrue(isJreContainerSet(launchConfig));
+ assertTrue(isConfigSet(launchConfig));
+ assertTrue(isServerHomeSet(launchConfig));
+ assertTrue(isEndorsedDirSet(launchConfig));
+ assertTrue(isServerIdSet(launchConfig));
+ }
+
+
+}
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/JBossLaunchConfigTests.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigConfiguratorFactory.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigConfiguratorFactory.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigConfiguratorFactory.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.test.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+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.launch.JBossStartupConfigurator;
+
+/**
+ * @author André Dietisheim
+ */
+public class LaunchConfigConfiguratorFactory {
+
+ public static ILaunchConfigurationWorkingCopy
createCustomConfigLocationLaunchConfig(IServer mockServer) throws CoreException {
+ MockLaunchConfigWorkingCopy launchConfig = new MockLaunchConfigWorkingCopy();
+ JBossStartupConfigurator configurator = new JBossStartupConfigurator(mockServer) {
+ @Override
+ protected boolean isCustomConfigLocation(IJBossServerRuntime runtime) {
+ return false;
+ }
+ };
+ configurator.configure(launchConfig);
+ return launchConfig;
+ }
+
+ public static MockLaunchConfigWorkingCopy
createNonCustomConfigLocationLaunchConfig(IServer server) throws CoreException {
+ MockLaunchConfigWorkingCopy launchConfig = new MockLaunchConfigWorkingCopy();
+ new JBossStartupConfigurator(server).configure(launchConfig);
+ return launchConfig;
+ }
+}
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigConfiguratorFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigTests.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigTests.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigTests.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.test.launch;
+
+import static
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossRuntimeLaunchConfigUtils.isServerHomeSet;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+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.server.internal.launch.AbstractStartupConfigurator;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.ILaunchConfigConfigurator;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class LaunchConfigTests extends TestCase {
+
+ private IServer mockServer;
+
+ @Override
+ protected void setUp() throws Exception {
+ this.mockServer = ServerRuntimeUtils.createMockJBoss7Server();
+ }
+
+ public void testDoesNotConfigureTwice() throws CoreException {
+ ILaunchConfigurationWorkingCopy launchConfig = new MockLaunchConfigWorkingCopy();
+
+ final String attributeKey = "configurationKey";
+ final String attributeValue = "configurationValue";
+
+ ILaunchConfigConfigurator mockConfigurator = new MockConfigurator(mockServer) {
+
+ @Override
+ protected void doConfigure(ILaunchConfigurationWorkingCopy launchConfig) throws
CoreException {
+ /**
+ * should only be called once
+ */
+ launchConfig.setAttribute(attributeKey, attributeValue);
+ }
+ };
+
+ assertEquals("defaultValue", launchConfig.getAttribute(attributeKey,
"defaultValue"));
+ launchConfig.setAttribute(attributeKey, "dummyValue");
+ // overrides "dummyValue" by "configurationValue"
+ mockConfigurator.configure(launchConfig);
+ assertEquals(attributeValue, launchConfig.getAttribute(attributeKey,
"defaultValue"));
+ launchConfig.setAttribute(attributeKey, "dummyValue");
+ // configure 2nd time: should not override existing value
+ mockConfigurator.configure(launchConfig);
+ assertEquals("dummyValue", launchConfig.getAttribute(attributeKey,
"defaultValue"));
+ }
+
+ private class MockConfigurator extends AbstractStartupConfigurator {
+
+ private MockConfigurator(IServer server) throws CoreException {
+ super(server);
+ }
+
+ @Override
+ protected String getWorkingDirectory(JBossServer server, IJBossServerRuntime
jbossRuntime) throws CoreException {
+ return null;
+ }
+
+ @Override
+ protected String getServerHome(IJBossServerRuntime runtime) {
+ return null;
+ }
+
+ @Override
+ protected String getMainType() {
+ return null;
+ }
+
+ @Override
+ protected String getDefaultProgramArguments(JBossServer server, IJBossServerRuntime
runtime) {
+ return null;
+ }
+
+ @Override
+ protected String getHost(JBossServer server, IJBossServerRuntime runtime) {
+ return null;
+ }
+
+ @Override
+ protected List<String> getClasspath(JBossServer server, IJBossServerRuntime
runtime,
+ List<String> currentClasspath)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ protected String getServerConfig(IJBossServerRuntime runtime) {
+ return null;
+ }
+
+ @Override
+ protected String getEndorsedDir(IJBossServerRuntime runtime) {
+ return null;
+ }
+
+ @Override
+ protected String getDefaultVMArguments(IJBossServerRuntime runtime) {
+ return null;
+ }
+ };
+
+ public void testServerHomeIsNotSetIfNotCustomConfigLocation() throws CoreException {
+ ILaunchConfigurationWorkingCopy launchConfig =
LaunchConfigConfiguratorFactory.createNonCustomConfigLocationLaunchConfig(mockServer);
+
+ assertFalse(isServerHomeSet(launchConfig));
+ }
+
+ public void testServerHomeIsSetIfCustomConfigLocation() throws CoreException {
+ ILaunchConfigurationWorkingCopy launchConfig =
LaunchConfigConfiguratorFactory.createCustomConfigLocationLaunchConfig(mockServer);
+
+ assertTrue(isServerHomeSet(launchConfig));
+ }
+}
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/LaunchConfigTests.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/MockLaunchConfigWorkingCopy.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/MockLaunchConfigWorkingCopy.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/MockLaunchConfigWorkingCopy.java 2011-06-27
22:07:56 UTC (rev 32379)
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.test.launch;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchDelegate;
+
+/**
+ * @author André Dietisheim
+ */
+public class MockLaunchConfigWorkingCopy implements ILaunchConfigurationWorkingCopy {
+
+ protected final Map<String, Object> attributeMap;
+
+ public MockLaunchConfigWorkingCopy() throws CoreException {
+ this.attributeMap = new HashMap<String, Object>();
+ }
+
+ public String getAttribute(String attributeName, String defaultValue) throws
CoreException {
+ String value = (String) attributeMap.get(attributeName);
+ if (value == null) {
+ value = defaultValue;
+ }
+ return value;
+ }
+
+ public boolean attributeEquals(String attributeName, Object expectedValue) throws
CoreException {
+ String attributeValue = getAttribute(attributeName, (String) null);
+ return (expectedValue == null && attributeValue == null)
+ || expectedValue != null && expectedValue.equals(attributeValue);
+ }
+
+ public boolean getAttribute(String key, boolean defaultValue) throws CoreException {
+ Boolean value = (Boolean) attributeMap.get(key);
+ if (value == null) {
+ value = defaultValue;
+ }
+ return value;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List getAttribute(String key, List defaultValue) throws CoreException {
+ List value = (List) attributeMap.get(key);
+ if (value == null) {
+ value = defaultValue;
+ }
+ return value;
+ }
+
+ public boolean hasAttribute(String key) throws CoreException {
+ return attributeMap.containsKey(key);
+ }
+
+ public void setAttribute(String key, String value) {
+ attributeMap.put(key, value);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void setAttribute(String key, List value) {
+ attributeMap.put(key, value);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void setAttribute(String key, Map map) {
+ attributeMap.put(key, map);
+ }
+
+ public void setAttribute(String key, boolean value) {
+ attributeMap.put(key, value);
+ }
+
+ public boolean contentsEqual(ILaunchConfiguration arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ILaunchConfigurationWorkingCopy copy(String arg0) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void delete() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean exists() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public int getAttribute(String arg0, int arg1) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Set getAttribute(String arg0, Set arg1) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Map getAttribute(String arg0, Map arg1) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Map getAttributes() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getCategory() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public IFile getFile() {
+ throw new UnsupportedOperationException();
+ }
+
+ public IPath getLocation() {
+ throw new UnsupportedOperationException();
+ }
+
+ public IResource[] getMappedResources() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getMemento() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Set getModes() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getName() {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public ILaunchDelegate getPreferredDelegate(Set arg0) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ILaunchConfigurationType getType() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLocal() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isMigrationCandidate() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isReadOnly() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isWorkingCopy() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public ILaunch launch(String arg0, IProgressMonitor arg1) throws CoreException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public ILaunch launch(String arg0, IProgressMonitor arg1, boolean arg2) throws
CoreException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public ILaunch launch(String arg0, IProgressMonitor arg1, boolean arg2, boolean arg3)
throws CoreException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void migrate() throws CoreException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public boolean supportsMode(String arg0) throws CoreException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter) {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void addModes(Set arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ILaunchConfiguration doSave() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ILaunchConfiguration getOriginal() {
+ throw new UnsupportedOperationException();
+ }
+
+ public ILaunchConfigurationWorkingCopy getParent() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDirty() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object removeAttribute(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void removeModes(Set arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void rename(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setAttribute(String arg0, int arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @SuppressWarnings("rawtypes")
+ public void setAttribute(String arg0, Set arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void setAttributes(Map arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContainer(IContainer arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setMappedResources(IResource[] arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void setModes(Set arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void setPreferredLaunchDelegate(Set arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/launch/MockLaunchConfigWorkingCopy.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain