Author: adietish
Date: 2011-07-04 12:58:32 -0400 (Mon, 04 Jul 2011)
New Revision: 32567
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractLaunchConfigurator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractStartupConfigurator.java
Log:
[JBIDE-9215] added configurator super class
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractLaunchConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractLaunchConfigurator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractLaunchConfigurator.java 2011-07-04
16:58:32 UTC (rev 32567)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.configuration;
+
+import java.util.List;
+
+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.util.ServerConverter;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractLaunchConfigurator implements ILaunchConfigConfigurator {
+
+ private static final String DEFAULTS_SET = "DEFAULTS_SET"; //$NON-NLS-1$
+
+ private JBossServer jbossServer;
+ private IJBossServerRuntime jbossRuntime;
+
+ public AbstractLaunchConfigurator(IServer server) throws CoreException {
+ this.jbossServer = ServerConverter.checkedGetJBossServer(server);
+ this.jbossRuntime = jbossServer.getRuntime();
+ }
+
+ @Override
+ public void configure(ILaunchConfigurationWorkingCopy launchConfig) throws CoreException
{
+ if (!areDefaultsSet(launchConfig)) {
+ doConfigure(launchConfig, jbossServer, jbossRuntime);
+ setDefaultsSet(launchConfig);
+ }
+ }
+
+ protected abstract void doConfigure(ILaunchConfigurationWorkingCopy launchConfig,
JBossServer jbossServer, IJBossServerRuntime jbossRuntime) throws CoreException;
+
+ protected abstract String getDefaultProgramArguments(JBossServer server,
IJBossServerRuntime runtime) 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 List<String> getClasspath(JBossServer server,
IJBossServerRuntime runtime, List<String> currentClasspath) throws CoreException;
+
+ protected boolean isUseDefaultClasspath() {
+ return false;
+ }
+
+ protected JBossServer getJbossServer() {
+ return jbossServer;
+ }
+
+ protected IJBossServerRuntime getJbossRuntime() {
+ return jbossRuntime;
+ }
+
+ 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/configuration/AbstractLaunchConfigurator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractStartupConfigurator.java
(from rev 32422,
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/configuration/AbstractStartupConfigurator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/configuration/AbstractStartupConfigurator.java 2011-07-04
16:58:32 UTC (rev 32567)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.configuration;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+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;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractStartupConfigurator extends AbstractLaunchConfigurator {
+
+ private static final String DEFAULT_CP_PROVIDER_ID =
"org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider";
///$NON-NLS-1$
+
+ public AbstractStartupConfigurator(IServer server) throws CoreException {
+ super(server);
+ }
+
+ @Override
+ protected void doConfigure(ILaunchConfigurationWorkingCopy launchConfig, JBossServer
jbossServer, IJBossServerRuntime jbossRuntime) throws CoreException {
+ JBossLaunchConfigProperties.setProgramArguments(getDefaultProgramArguments(jbossServer,
jbossRuntime), launchConfig);
+ JBossLaunchConfigProperties.setHost(getHost(jbossServer, jbossRuntime), launchConfig);
+ JBossLaunchConfigProperties.setConfig(getServerConfig(jbossRuntime), launchConfig);
+ JBossLaunchConfigProperties.setServerHome(getServerHome(jbossRuntime), jbossRuntime,
launchConfig);
+ JBossLaunchConfigProperties.setVmArguments(getDefaultVMArguments(jbossRuntime),
launchConfig);
+ JBossLaunchConfigProperties.setJreContainer(getJreContainerPath(jbossRuntime),
launchConfig);
+ JBossLaunchConfigProperties.setEndorsedDir(getEndorsedDir(jbossRuntime),
launchConfig);
+ JBossLaunchConfigProperties.setMainType(getMainType(), launchConfig);
+ JBossLaunchConfigProperties.setWorkingDirectory(getWorkingDirectory(jbossServer,
jbossRuntime), launchConfig);
+ JBossLaunchConfigProperties.setEnvironmentVariables(getEnvironmentVariables(jbossRuntime),
launchConfig);
+ JBossLaunchConfigProperties.setClasspathProvider(getClasspathProvider(),
launchConfig);
+ JBossLaunchConfigProperties.setClasspath(getClasspath(jbossServer, jbossRuntime,
JBossLaunchConfigProperties.getClasspath(launchConfig)), launchConfig);
+ JBossLaunchConfigProperties.setUseDefaultClassPath(isUseDefaultClasspath(),
launchConfig);
+ JBossLaunchConfigProperties.setServerId(getServerId(jbossServer), 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)) {
+ JBossLaunchConfigProperties.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 getDefaultVMArguments(IJBossServerRuntime runtime);
+
+
+ protected String getJreContainerPath(IJBossServerRuntime runtime) {
+ IVMInstall vmInstall = runtime.getVM();
+ if (vmInstall == null) {
+ return null;
+ }
+ return JavaRuntime.newJREContainerPath(vmInstall).toPortableString();
+ }
+
+ protected abstract String getHost(JBossServer server, IJBossServerRuntime runtime);
+}
\ 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/configuration/AbstractStartupConfigurator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain