diff --git a/.travis.yml b/.travis.yml index f5c99a7..5d80df0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,12 @@ -language: java \ No newline at end of file +sudo: required + +language: java + +jdk: + - oraclejdk8 + +addons: + apt: + packages: + - oracle-java8-installer + - oracle-java8-set-default \ No newline at end of file diff --git a/plugins/eclipse-jetty-launcher/pom.xml b/plugins/eclipse-jetty-launcher/pom.xml index acbeed1..f1a25af 100644 --- a/plugins/eclipse-jetty-launcher/pom.xml +++ b/plugins/eclipse-jetty-launcher/pom.xml @@ -59,6 +59,13 @@ provided true + + + net.sourceforge.eclipsejetty + eclipse-jetty-optimized-webappclassloader + ${project.version} + provided + junit @@ -80,8 +87,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.5 - 1.5 + 1.8 + 1.8 @@ -103,7 +110,8 @@ eclipse-jetty-starters-jetty8, eclipse-jetty-starters-jetty9, eclipse-jetty-starters-console, - eclipse-jetty-starters-util + eclipse-jetty-starters-util, + eclipse-jetty-optimized-webappclassloader ${project.build.directory}/../lib true diff --git a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/Messages.java b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/Messages.java index b59ca12..7bfd326 100644 --- a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/Messages.java +++ b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/Messages.java @@ -1,213 +1,218 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package net.sourceforge.eclipsejetty; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS -{ - private static final String BUNDLE_NAME = "net.sourceforge.eclipsejetty.messages"; //$NON-NLS-1$ - public static String adapter_configurationOnlyReadable; - public static String adapter_defaultConfigName; - public static String adapter_noDefaultScope; - public static String adapter_noHasAttribute; - public static String advConfigTab_acceptorLimitCountSpinnerTip; - public static String advConfigTab_acceptorLimitCountUnit; - public static String advConfigTab_acceptorLimitEnabledButton; - public static String advConfigTab_acceptorLimitEnabledButtonTip; - public static String advConfigTab_ajpPortSpinnerTip; - public static String advConfigTab_ajpSupportButton; - public static String advConfigTab_ajpSupportButtonTip; - public static String advConfigTab_clientCacheDisabledButton; - public static String advConfigTab_clientCacheDisabledButtonTip; - public static String advConfigTab_consoleEnabledButton; - public static String advConfigTab_consoleEnabledButtonTip; - public static String advConfigTab_contextAddButton; - public static String advConfigTab_contextAddButtonTip; - public static String advConfigTab_contextAddExternalButton; - public static String advConfigTab_contextAddExternalButtonTip; - public static String advConfigTab_contextAddExternalTitle; - public static String advConfigTab_contextAddMessage; - public static String advConfigTab_contextAddTitle; - public static String advConfigTab_contextCreateFailed; - public static String advConfigTab_contextDownButton; - public static String advConfigTab_contextDownButtonTip; - public static String advConfigTab_contextEditButton; - public static String advConfigTab_contextEditButtonTip; - public static String advConfigTab_contextGroupTitle; - public static String advConfigTab_contextInvalid; - public static String advConfigTab_contextOpenButton; - public static String advConfigTab_contextOpenButtonTip; - public static String advConfigTab_contextOpenFailed; - public static String advConfigTab_contextRemoveButton; - public static String advConfigTab_contextRemoveButtonTip; - public static String advConfigTab_contextTableFile; - public static String advConfigTab_contextTableInclude; - public static String advConfigTab_contextUpButton; - public static String advConfigTab_contextUpButtonTip; - public static String advConfigTab_customWebDefaultsEnabledButton; - public static String advConfigTab_customWebDefaultsEnabledButtonTip; - public static String advConfigTab_customWebDefaultsFileSystemButton; - public static String advConfigTab_customWebDefaultsFileSystemButtonTip; - public static String advConfigTab_customWebDefaultsFileSystemTitle; - public static String advConfigTab_customWebDefaultsInvalid; - public static String advConfigTab_customWebDefaultsMissing; - public static String advConfigTab_customWebDefaultsResourceTextTip; - public static String advConfigTab_customWebDefaultsVariablesButton; - public static String advConfigTab_customWebDefaultsVariablesButtonTip; - public static String advConfigTab_customWebDefaultsWorkspaceButton; - public static String advConfigTab_customWebDefaultsWorkspaceButtonTip; - public static String advConfigTab_customWebDefaultsWorkspaceMessage; - public static String advConfigTab_customWebDefaultsWorkspaceTitle; - public static String advConfigTab_embeddedButton; - public static String advConfigTab_embeddedButtonTip; - public static String advConfigTab_externalButton; - public static String advConfigTab_externalButtonTip; - public static String advConfigTab_externalMessage; - public static String advConfigTab_externalTitle; - public static String advConfigTab_externButton; - public static String advConfigTab_externButtonTip; - public static String advConfigTab_gracefulShutdownTimeoutEnabledButton; - public static String advConfigTab_gracefulShutdownTimeoutEnabledTip; - public static String advConfigTab_gracefulShutdownTimeoutLabel; - public static String advConfigTab_gracefulShutdownTimeoutTip; - public static String advConfigTab_gracefulShutdownTimeoutUnit; - public static String advConfigTab_homepageLink; - public static String advConfigTab_initializeFailed; - public static String advConfigTab_jettyConfigurationGroupTitle; - public static String advConfigTab_jettyFeaturesGroupTitle; - public static String advConfigTab_jettyGroupTitle; - public static String advConfigTab_jmxSupportButton; - public static String advConfigTab_jmxSupportButtonTip; - public static String advConfigTab_websocketSupportButton; - public static String advConfigTab_websocketSupportButtonTip; - public static String advConfigTab_jndiSupportButton; - public static String advConfigTab_jndiSupportButtonTip; - public static String advConfigTab_jspSupportButton; - public static String advConfigTab_jspSupportButtonTip; - public static String advConfigTab_message; - public static String advConfigTab_pathInvalid; - public static String advConfigTab_pathMissing; - public static String advConfigTab_pathTextTip; - public static String advConfigTab_pathVariablesButton; - public static String advConfigTab_pathVariablesButtonTip; - public static String advConfigTab_performApplyFailed; - public static String advConfigTab_pluginFeaturesGroupTitle; - public static String advConfigTab_serverCacheDisabledButton; - public static String advConfigTab_serverCacheDisabledButtonTip; - public static String advConfigTab_showLauncherInfoButton; - public static String advConfigTab_showLauncherInfoButtonTip; - public static String advConfigTab_threadPoolLimitCountSpinnerTip; - public static String advConfigTab_threadPoolLimitCountUnit; - public static String advConfigTab_threadPoolLimitEnabledButton; - public static String advConfigTab_threadPoolLimitEnabledButtonTip; - public static String advConfigTab_title; - public static String advConfigTab_updateTableFailed; - public static String advConfigTab_versionDetectionFailed; - public static String configEntry_default; - public static String configTab_contextPathLabel; - public static String configTab_contextPathTextTip; - public static String configTab_defaultsFailed; - public static String configTab_homepageLink; - public static String configTab_httpProtSpinnerTip; - public static String configTab_httpsEnableButton; - public static String configTab_httpsEnableButtonTip; - public static String configTab_initializeFailed; - public static String configTab_message; - public static String configTab_name; - public static String configTab_noProjectSelected; - public static String configTab_performApplyFailed; - public static String configTab_portLabel; - public static String configTab_portSpinnerTip; - public static String configTab_projectBrowseButton; - public static String configTab_projectBrowseButtonTip; - public static String configTab_projectBrowseFailed; - public static String configTab_projectBrowseMessage; - public static String configTab_projectBrowseTitle; - public static String configTab_projectClosed; - public static String configTab_projectGroupTitle; - public static String configTab_projectNameInvalid; - public static String configTab_projectNotExisting; - public static String configTab_projectTextTip; - public static String configTab_serverHTTPLink; - public static String configTab_serverHTTPsLink; - public static String configTab_webAppBrowseButton; - public static String configTab_webAppBrowseButtonTip; - public static String configTab_webAppBrowseMessage; - public static String configTab_webAppBrowseTitle; - public static String configTab_webAppInvalid; - public static String configTab_webAppLabel; - public static String configTab_webAppNotExisting; - public static String configTab_webAppScanButton; - public static String configTab_webAppScanButtonTip; - public static String configTab_webAppScanFailedMessage; - public static String configTab_webAppScanFailedTitle; - public static String configTab_webAppTextTip; - public static String delegate_keystoreFailed; - public static String delegate_launchConfigurationFailed; - public static String delegate_webDefaultsFailed; - public static String depConfigTab_dependencyFilterDefault; - public static String depConfigTab_dependencyFilterTip; - public static String depConfigTab_dependencyTableGlobal; - public static String depConfigTab_dependencyTableInclude; - public static String depConfigTab_dependencyTableName; - public static String depConfigTab_dependencyTablePath; - public static String depConfigTab_dependencyTableResetButton; - public static String depConfigTab_dependencyTableResetButtonTip; - public static String depConfigTab_dependencyTableScope; - public static String depConfigTab_dependencyTableUpdateFailed; - public static String depConfigTab_homepageLink; - public static String depConfigTab_initializeFailed; - public static String depConfigTab_m2eNotAvailable; - public static String depConfigTab_mavenGroupTitle; - public static String depConfigTab_mavenIncludeCompileButton; - public static String depConfigTab_mavenIncludeCompileButtonTip; - public static String depConfigTab_mavenIncludeImportButton; - public static String depConfigTab_mavenIncludeImportButtonTip; - public static String depConfigTab_mavenIncludeNoneButton; - public static String depConfigTab_mavenIncludeNoneButtonTip; - public static String depConfigTab_mavenIncludeProvidedButton; - public static String depConfigTab_mavenIncludeProvidedButtonTip; - public static String depConfigTab_mavenIncludeRuntimeButton; - public static String depConfigTab_mavenIncludeRuntimeButtonTip; - public static String depConfigTab_mavenIncludeSystemButton; - public static String depConfigTab_mavenIncludeSystemButtonTip; - public static String depConfigTab_mavenIncludeTestButton; - public static String depConfigTab_mavenIncludeTestButtonTip; - public static String depConfigTab_message; - public static String depConfigTab_noM2ENature; - public static String depConfigTab_otherGroupTitle; - public static String depConfigTab_performApplyFailed; - public static String depConfigTab_title; - public static String dependencyMap_fixedScope; - public static String mavenScope_unknown; - public static String shortcut_createFailed; - public static String shortcut_invalidEditorInput; - public static String shortcut_invalidEditorInputFile; - public static String shortcut_unsupportedLaunchSelection; - public static String shortcut_unsupportedLaunchSelectionElement; - public static String shortcut_webAppDirNotFoundMessage; - public static String shortcut_webAppDirNotFoundTitle; - public static String shortcut_webAppNotFound; - public static String shortcut_webAppSelectMessage; - public static String shortcut_webAppSelectTitle; - public static String utils_scanFailed; - static - { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() - { - } -} +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package net.sourceforge.eclipsejetty; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS +{ + private static final String BUNDLE_NAME = "net.sourceforge.eclipsejetty.messages"; //$NON-NLS-1$ + public static String adapter_configurationOnlyReadable; + public static String adapter_defaultConfigName; + public static String adapter_noDefaultScope; + public static String adapter_noHasAttribute; + public static String advConfigTab_acceptorLimitCountSpinnerTip; + public static String advConfigTab_acceptorLimitCountUnit; + public static String advConfigTab_acceptorLimitEnabledButton; + public static String advConfigTab_acceptorLimitEnabledButtonTip; + public static String advConfigTab_ajpPortSpinnerTip; + public static String advConfigTab_ajpSupportButton; + public static String advConfigTab_ajpSupportButtonTip; + public static String advConfigTab_clientCacheDisabledButton; + public static String advConfigTab_clientCacheDisabledButtonTip; + public static String advConfigTab_consoleEnabledButton; + public static String advConfigTab_consoleEnabledButtonTip; + public static String advConfigTab_contextAddButton; + public static String advConfigTab_contextAddButtonTip; + public static String advConfigTab_contextAddExternalButton; + public static String advConfigTab_contextAddExternalButtonTip; + public static String advConfigTab_contextAddExternalTitle; + public static String advConfigTab_contextAddMessage; + public static String advConfigTab_contextAddTitle; + public static String advConfigTab_contextCreateFailed; + public static String advConfigTab_contextDownButton; + public static String advConfigTab_contextDownButtonTip; + public static String advConfigTab_contextEditButton; + public static String advConfigTab_contextEditButtonTip; + public static String advConfigTab_contextGroupTitle; + public static String advConfigTab_contextInvalid; + public static String advConfigTab_contextOpenButton; + public static String advConfigTab_contextOpenButtonTip; + public static String advConfigTab_contextOpenFailed; + public static String advConfigTab_contextRemoveButton; + public static String advConfigTab_contextRemoveButtonTip; + public static String advConfigTab_contextTableFile; + public static String advConfigTab_contextTableInclude; + public static String advConfigTab_contextUpButton; + public static String advConfigTab_contextUpButtonTip; + public static String advConfigTab_customWebDefaultsEnabledButton; + public static String advConfigTab_customWebDefaultsEnabledButtonTip; + public static String advConfigTab_customWebDefaultsFileSystemButton; + public static String advConfigTab_customWebDefaultsFileSystemButtonTip; + public static String advConfigTab_customWebDefaultsFileSystemTitle; + public static String advConfigTab_customWebDefaultsInvalid; + public static String advConfigTab_customWebDefaultsMissing; + public static String advConfigTab_customWebDefaultsResourceTextTip; + public static String advConfigTab_customWebDefaultsVariablesButton; + public static String advConfigTab_customWebDefaultsVariablesButtonTip; + public static String advConfigTab_customWebDefaultsWorkspaceButton; + public static String advConfigTab_customWebDefaultsWorkspaceButtonTip; + public static String advConfigTab_customWebDefaultsWorkspaceMessage; + public static String advConfigTab_customWebDefaultsWorkspaceTitle; + public static String advConfigTab_embeddedButton; + public static String advConfigTab_embeddedButtonTip; + public static String advConfigTab_externalButton; + public static String advConfigTab_externalButtonTip; + public static String advConfigTab_externalMessage; + public static String advConfigTab_externalTitle; + public static String advConfigTab_externButton; + public static String advConfigTab_externButtonTip; + public static String advConfigTab_gracefulShutdownTimeoutEnabledButton; + public static String advConfigTab_gracefulShutdownTimeoutEnabledTip; + public static String advConfigTab_gracefulShutdownTimeoutLabel; + public static String advConfigTab_gracefulShutdownTimeoutTip; + public static String advConfigTab_gracefulShutdownTimeoutUnit; + public static String advConfigTab_homepageLink; + public static String advConfigTab_initializeFailed; + public static String advConfigTab_jettyConfigurationGroupTitle; + public static String advConfigTab_jettyFeaturesGroupTitle; + public static String advConfigTab_jettyGroupTitle; + public static String advConfigTab_jmxSupportButton; + public static String advConfigTab_jmxSupportButtonTip; + public static String advConfigTab_websocketSupportButton; + public static String advConfigTab_websocketSupportButtonTip; + public static String advConfigTab_jndiSupportButton; + public static String advConfigTab_jndiSupportButtonTip; + public static String advConfigTab_jspSupportButton; + public static String advConfigTab_jspSupportButtonTip; + public static String advConfigTab_message; + public static String advConfigTab_pathInvalid; + public static String advConfigTab_pathMissing; + public static String advConfigTab_pathTextTip; + public static String advConfigTab_pathVariablesButton; + public static String advConfigTab_pathVariablesButtonTip; + public static String advConfigTab_performApplyFailed; + public static String advConfigTab_pluginFeaturesGroupTitle; + public static String advConfigTab_serverCacheDisabledButton; + public static String advConfigTab_serverCacheDisabledButtonTip; + public static String advConfigTab_showLauncherInfoButton; + public static String advConfigTab_showLauncherInfoButtonTip; + public static String advConfigTab_threadPoolLimitCountSpinnerTip; + public static String advConfigTab_threadPoolLimitCountUnit; + public static String advConfigTab_threadPoolLimitEnabledButton; + public static String advConfigTab_threadPoolLimitEnabledButtonTip; + public static String advConfigTab_title; + public static String advConfigTab_updateTableFailed; + public static String advConfigTab_versionDetectionFailed; + public static String configEntry_default; + public static String configTab_contextPathLabel; + public static String configTab_contextPathTextTip; + public static String configTab_defaultsFailed; + public static String configTab_homepageLink; + public static String configTab_httpProtSpinnerTip; + public static String configTab_httpsEnableButton; + public static String configTab_httpsEnableButtonTip; + public static String configTab_initializeFailed; + public static String configTab_message; + public static String configTab_name; + public static String configTab_noProjectSelected; + public static String configTab_performApplyFailed; + public static String configTab_portLabel; + public static String configTab_portSpinnerTip; + public static String configTab_projectBrowseButton; + public static String configTab_projectBrowseButtonTip; + public static String configTab_projectBrowseFailed; + public static String configTab_projectBrowseMessage; + public static String configTab_projectBrowseTitle; + public static String configTab_projectClosed; + public static String configTab_projectGroupTitle; + public static String configTab_projectNameInvalid; + public static String configTab_projectNotExisting; + public static String configTab_projectTextTip; + public static String configTab_serverHTTPLink; + public static String configTab_serverHTTPsLink; + public static String configTab_webAppBrowseButton; + public static String configTab_webAppBrowseButtonTip; + public static String configTab_webAppBrowseMessage; + public static String configTab_webAppBrowseTitle; + public static String configTab_webAppInvalid; + public static String configTab_webAppLabel; + public static String configTab_webAppNotExisting; + public static String configTab_webAppScanButton; + public static String configTab_webAppScanButtonTip; + public static String configTab_webAppScanFailedMessage; + public static String configTab_webAppScanFailedTitle; + public static String configTab_webAppTextTip; + public static String delegate_keystoreFailed; + public static String delegate_launchConfigurationFailed; + public static String delegate_webDefaultsFailed; + public static String depConfigTab_dependencyFilterDefault; + public static String depConfigTab_dependencyFilterTip; + public static String depConfigTab_dependencyTableGlobal; + public static String depConfigTab_dependencyTableInclude; + public static String depConfigTab_dependencyTableName; + public static String depConfigTab_dependencyTablePath; + public static String depConfigTab_dependencyTableResetButton; + public static String depConfigTab_dependencyTableResetButtonTip; + public static String depConfigTab_dependencyTableScope; + public static String depConfigTab_dependencyTableUpdateFailed; + public static String depConfigTab_homepageLink; + public static String depConfigTab_initializeFailed; + public static String depConfigTab_m2eNotAvailable; + public static String depConfigTab_mavenGroupTitle; + public static String depConfigTab_mavenIncludeCompileButton; + public static String depConfigTab_mavenIncludeCompileButtonTip; + public static String depConfigTab_mavenIncludeImportButton; + public static String depConfigTab_mavenIncludeImportButtonTip; + public static String depConfigTab_mavenIncludeNoneButton; + public static String depConfigTab_mavenIncludeNoneButtonTip; + public static String depConfigTab_mavenIncludeProvidedButton; + public static String depConfigTab_mavenIncludeProvidedButtonTip; + public static String depConfigTab_mavenIncludeRuntimeButton; + public static String depConfigTab_mavenIncludeRuntimeButtonTip; + public static String depConfigTab_mavenIncludeSystemButton; + public static String depConfigTab_mavenIncludeSystemButtonTip; + public static String depConfigTab_mavenIncludeTestButton; + public static String depConfigTab_mavenIncludeTestButtonTip; + public static String depConfigTab_message; + public static String depConfigTab_noM2ENature; + public static String depConfigTab_otherGroupTitle; + public static String depConfigTab_performApplyFailed; + public static String depConfigTab_title; + public static String dependencyMap_fixedScope; + public static String mavenScope_unknown; + public static String shortcut_createFailed; + public static String shortcut_invalidEditorInput; + public static String shortcut_invalidEditorInputFile; + public static String shortcut_unsupportedLaunchSelection; + public static String shortcut_unsupportedLaunchSelectionElement; + public static String shortcut_webAppDirNotFoundMessage; + public static String shortcut_webAppDirNotFoundTitle; + public static String shortcut_webAppNotFound; + public static String shortcut_webAppSelectMessage; + public static String shortcut_webAppSelectTitle; + public static String utils_scanFailed; + public static String advConfigTab_jettyWebappClassLoaderFeatureGroupTitle; + public static String advConfigTab_enableOptimizedWebAppClassLoaderButtonButton; + public static String advConfigTab_enableOptimizedWebAppClassLoaderButtonButtonTip; + public static String advConfigTab_advancedClassLoaderExclusionTitle; + public static String advConfigTab_advancedClassLoaderExclusionPatternTip; + static + { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() + { + } +} diff --git a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty/AbstractServerConfiguration.java b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty/AbstractServerConfiguration.java index 7980eff..5dc1adf 100644 --- a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty/AbstractServerConfiguration.java +++ b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty/AbstractServerConfiguration.java @@ -1,570 +1,606 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package net.sourceforge.eclipsejetty.jetty; - -import java.io.File; -import java.util.Collection; -import java.util.LinkedHashSet; - -/** - * Abstract builder for a Jetty configuration - * - * @author Manfred Hantschel - */ -public abstract class AbstractServerConfiguration extends AbstractConfiguration -{ - - private final Collection defaultClasspath; - - private Integer majorVersion; - private Integer minorVersion; - private Integer microVersion; - - private boolean annotationsEnabled = false; - private boolean jndiEnabled = false; - private boolean jmxEnabled = false; - private boolean websocketEnabled = false; - - private Integer port; - private Integer sslPort; - private Integer gracefulShutdown; - private Integer threadPoolLimit; - private Integer acceptorLimit; - - private String keyStorePath; - private String keyStorePassword; - private String keyManagerPassword; - - private File defaultWar; - private String defaultContextPath; - private File customWebDefaultsFile; - - public AbstractServerConfiguration() - { - super(); - - defaultClasspath = new LinkedHashSet(); - } - - public Integer getMajorVersion() - { - return majorVersion; - } - - public void setMajorVersion(Integer majorVersion) - { - this.majorVersion = majorVersion; - } - - public Integer getMinorVersion() - { - return minorVersion; - } - - public void setMinorVersion(Integer minorVersion) - { - this.minorVersion = minorVersion; - } - - public Integer getMicroVersion() - { - return microVersion; - } - - public void setMicroVersion(Integer microVersion) - { - this.microVersion = microVersion; - } - - /** - * Returns true if Annotations support is enabled. - * - * @return true if Annotations support is enabled - */ - public boolean isAnnotationsEnabled() - { - return annotationsEnabled || jndiEnabled; - } - - /** - * Set to true if Annotations support is enabled. - * - * @param annotationsEnabled true if Annotations support is enabled - */ - public void setAnnotationsEnabled(boolean annotationsEnabled) - { - this.annotationsEnabled = annotationsEnabled; - } - - /** - * Returns true if JNDI support is enabled. - * - * @return true if JNDI support is enabled - */ - public boolean isJndiEnabled() - { - return jndiEnabled; - } - - /** - * Toggles the JNDI support. - * - * @param jndiEnabled true to enable JNDI - */ - public void setJndiEnabled(boolean jndiEnabled) - { - this.jndiEnabled = jndiEnabled; - } - - /** - * Returns true if JMX support is enabled. - * - * @return true if JMX support is enabled - */ - public boolean isJmxEnabled() - { - return jmxEnabled; - } - - /** - * Toggles the JMX support. - * - * @param jmxEnabled true to enable JMX - */ - public void setJmxEnabled(boolean jmxEnabled) - { - this.jmxEnabled = jmxEnabled; - } - - public boolean isWebsocketEnabled() - { - return websocketEnabled; - } - - public void setWebsocketEnabled(boolean websocketEnabled) - { - this.websocketEnabled = websocketEnabled; - } - - /** - * Returns the (HTTP) port. - * - * @return the port - */ - public Integer getPort() - { - return port; - } - - /** - * Sets the (HTTP) port, null to disable. - * - * @param port the port - */ - public void setPort(Integer port) - { - this.port = port; - } - - /** - * Returns the HTTPs port. - * - * @return the HTTPs port - */ - public Integer getSslPort() - { - return sslPort; - } - - /** - * Sets the HTTPs port, null to disable. The keystore stuff must also be set: {@link #setKeyStorePath(String)}, - * {@link #setKeyStorePassword(String)}, {@link #setKeyManagerPassword(String)}. - * - * @param sslPort the HTTPs port - */ - public void setSslPort(Integer sslPort) - { - this.sslPort = sslPort; - } - - /** - * Return the graceful shutdown timeout (in milliseconds). - * - * @return the graceful shutdown timeout (in milliseconds) - */ - public Integer getGracefulShutdown() - { - return gracefulShutdown; - } - - /** - * Sets the graceful shutdown timeout (in milliseconds). - * - * @param gracefulShutdown the graceful shutdown timeout (in milliseconds) - */ - public void setGracefulShutdown(Integer gracefulShutdown) - { - this.gracefulShutdown = gracefulShutdown; - } - - /** - * Returns the thread pool limit. - * - * @return the thread pool limit - */ - public Integer getThreadPoolLimit() - { - return threadPoolLimit; - } - - /** - * Sets the thread pool limit, null to disable. - * - * @param threadPoolLimit the thread pool limit - */ - public void setThreadPoolLimit(Integer threadPoolLimit) - { - this.threadPoolLimit = threadPoolLimit; - } - - /** - * Returns the acceptor limit. - * - * @return the acceptor limit - */ - public Integer getAcceptorLimit() - { - return acceptorLimit; - } - - /** - * Sets the acceptor limit, null to disable. - * - * @param acceptorLimit the acceptor limit - */ - public void setAcceptorLimit(Integer acceptorLimit) - { - this.acceptorLimit = acceptorLimit; - } - - /** - * Returns the key store path. - * - * @return the key store path - */ - public String getKeyStorePath() - { - return keyStorePath; - } - - /** - * Sets the key store path. - * - * @param keyStorePath the key store path - */ - public void setKeyStorePath(String keyStorePath) - { - this.keyStorePath = keyStorePath; - } - - /** - * Returns the key store password. - * - * @return the key store password - */ - public String getKeyStorePassword() - { - return keyStorePassword; - } - - /** - * Sets the key store password. - * - * @param keyStorePassword the key store password - */ - public void setKeyStorePassword(String keyStorePassword) - { - this.keyStorePassword = keyStorePassword; - } - - /** - * Returns the key manager password. - * - * @return the key manager password - */ - public String getKeyManagerPassword() - { - return keyManagerPassword; - } - - /** - * Set the key manager password. - * - * @param keyManagerPassword the key manager password - */ - public void setKeyManagerPassword(String keyManagerPassword) - { - this.keyManagerPassword = keyManagerPassword; - } - - /** - * Returns the path to the webapp directory. - * - * @return the path to the webapp directory - */ - public File getDefaultWar() - { - return defaultWar; - } - - /** - * Sets the path to the webapp directory. - * - * @param defaultWar the path to the webapp directory - */ - public void setDefaultWar(File defaultWar) - { - this.defaultWar = defaultWar; - } - - /** - * Returns the context path. - * - * @return the context path - */ - public String getDefaultContextPath() - { - return defaultContextPath; - } - - /** - * Sets the context path. - * - * @param defaultContextPath the context path - */ - public void setDefaultContextPath(String defaultContextPath) - { - this.defaultContextPath = defaultContextPath; - } - - /** - * Returns the path to the custom web defaults file. - * - * @return the path to the custom web defaults file - */ - public File getCustomWebDefaultsFile() - { - return customWebDefaultsFile; - } - - /** - * Sets the path to the custom web defaults file. - * - * @param customWebDefaultsFile the path to the custom web defaults file - */ - public void setCustomWebDefaultsFile(File customWebDefaultsFile) - { - this.customWebDefaultsFile = customWebDefaultsFile; - } - - /** - * Returns the classpath of the web application. - * - * @return the classpath of the web application - */ - public Collection getDefaultClasspath() - { - return defaultClasspath; - } - - /** - * Sets the classpath of the web application. - * - * @param classpaths the classpath of the web application - */ - public void addDefaultClasspath(String... classpaths) - { - for (String classpath : classpaths) - { - defaultClasspath.add(classpath); - } - } - - /** - * {@inheritDoc} - * - * @see net.sourceforge.eclipsejetty.jetty.AbstractConfiguration#getIdToConfigure() - */ - @Override - protected String getIdToConfigure() - { - return "Server"; - } - - /** - * {@inheritDoc} - * - * @see net.sourceforge.eclipsejetty.jetty.AbstractConfiguration#buildContent(net.sourceforge.eclipsejetty.util.DOMBuilder) - */ - @Override - protected void buildContent(JettyConfigBuilder builder) - { - buildThreadPool(builder); - buildHttpConfig(builder); - buildHttpConnector(builder); - buildHttpsConfig(builder); - buildHttpsConnector(builder); - buildHandler(builder); - buildAnnotations(builder); - buildJNDI(builder); - buildJMX(builder); - buildExtraOptions(builder); - - } - - /** - * Builds the thread pool part. - * - * @param builder the builder - */ - protected abstract void buildThreadPool(JettyConfigBuilder builder); - - /** - * Builds the HTTP config part. - * - * @param builder the builder - */ - protected abstract void buildHttpConfig(JettyConfigBuilder builder); - - /** - * Builds the HTTP connector part. - * - * @param builder the builder - */ - protected abstract void buildHttpConnector(JettyConfigBuilder builder); - - /** - * Builds the HTTPS config part. - * - * @param builder the builder - */ - protected abstract void buildHttpsConfig(JettyConfigBuilder builder); - - /** - * Builds the HTTPs connector part, if enabled. - * - * @param builder the builder - */ - protected abstract void buildHttpsConnector(JettyConfigBuilder builder); - - /** - * Builds the handler part. - * - * @param builder the builder - */ - protected void buildHandler(JettyConfigBuilder builder) - { - buildDefaultHandler(builder); - } - - /** - * Builds the default handler. - * - * @param builder the builder - */ - protected void buildDefaultHandler(JettyConfigBuilder builder) - { - builder.comment("Handler"); - - builder.beginSet("handler"); - { - builder.beginNew(getDefaultHandlerClass()); - { - File defaultWar = getDefaultWar(); - - builder.arg((defaultWar != null) ? defaultWar.getAbsolutePath() : "/"); - builder.arg(getDefaultContextPath()); - - if (getCustomWebDefaultsFile() != null) - { - builder.set("defaultsDescriptor", getCustomWebDefaultsFile().getAbsolutePath()); - } - - Collection configurations = new LinkedHashSet(); - - collectDefaultHandlerConfigurations(configurations); - - if (configurations.size() > 0) - { - builder.setArray("configurationClasses", configurations.toArray()); - } - - buildDefaultHandlerSetters(builder); - } - builder.end(); - } - builder.end(); - } - - /** - * Returns the default handler class for the Jetty version. - * - * @return the default handler class - */ - protected abstract String getDefaultHandlerClass(); - - /** - * Builds additional handler setters. - * - * @param builder the builder - */ - protected void buildDefaultHandlerSetters(JettyConfigBuilder builder) - { - builder.set("extraClasspath", link(defaultClasspath)); - } - - /** - * Collect all configurations for the handler - * - * @param configurations the configurations - */ - protected abstract void collectDefaultHandlerConfigurations(Collection configurations); - - /** - * Builds the Annotations part, if needed. - * - * @param builder the builder - */ - protected abstract void buildAnnotations(JettyConfigBuilder builder); - - /** - * Builds the JNDI part, if enabled. - * - * @param builder the builder - */ - protected abstract void buildJNDI(JettyConfigBuilder builder); - - /** - * Builds the JMX part, if enabled. - * - * @param builder the builder - */ - protected abstract void buildJMX(JettyConfigBuilder builder); - - /** - * Builds extra options. - * - * @param builder the builder - */ - protected abstract void buildExtraOptions(JettyConfigBuilder builder); - -} +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package net.sourceforge.eclipsejetty.jetty; + +import java.io.File; +import java.util.Collection; +import java.util.LinkedHashSet; + +/** + * Abstract builder for a Jetty configuration + * + * @author Manfred Hantschel + */ +public abstract class AbstractServerConfiguration extends AbstractConfiguration +{ + + private final Collection defaultClasspath; + + private Integer majorVersion; + private Integer minorVersion; + private Integer microVersion; + + private boolean annotationsEnabled = false; + private boolean jndiEnabled = false; + private boolean jmxEnabled = false; + private boolean websocketEnabled = false; + + private Integer port; + private Integer sslPort; + private Integer gracefulShutdown; + private Integer threadPoolLimit; + private Integer acceptorLimit; + + private String keyStorePath; + private String keyStorePassword; + private String keyManagerPassword; + + private File defaultWar; + private String defaultContextPath; + private File customWebDefaultsFile; + + private boolean enabledOptimizedClassloader = false; + private String optimizedClassloaderExclusionPattern = ".*assembly.*"; + + public AbstractServerConfiguration() + { + super(); + + defaultClasspath = new LinkedHashSet(); + } + + public Integer getMajorVersion() + { + return majorVersion; + } + + public void setMajorVersion(Integer majorVersion) + { + this.majorVersion = majorVersion; + } + + public Integer getMinorVersion() + { + return minorVersion; + } + + public void setMinorVersion(Integer minorVersion) + { + this.minorVersion = minorVersion; + } + + public Integer getMicroVersion() + { + return microVersion; + } + + public void setMicroVersion(Integer microVersion) + { + this.microVersion = microVersion; + } + + /** + * Returns true if Annotations support is enabled. + * + * @return true if Annotations support is enabled + */ + public boolean isAnnotationsEnabled() + { + return annotationsEnabled || jndiEnabled; + } + + /** + * Set to true if Annotations support is enabled. + * + * @param annotationsEnabled true if Annotations support is enabled + */ + public void setAnnotationsEnabled(boolean annotationsEnabled) + { + this.annotationsEnabled = annotationsEnabled; + } + + /** + * Returns true if JNDI support is enabled. + * + * @return true if JNDI support is enabled + */ + public boolean isJndiEnabled() + { + return jndiEnabled; + } + + /** + * Toggles the JNDI support. + * + * @param jndiEnabled true to enable JNDI + */ + public void setJndiEnabled(boolean jndiEnabled) + { + this.jndiEnabled = jndiEnabled; + } + + /** + * Returns true if JMX support is enabled. + * + * @return true if JMX support is enabled + */ + public boolean isJmxEnabled() + { + return jmxEnabled; + } + + /** + * Toggles the JMX support. + * + * @param jmxEnabled true to enable JMX + */ + public void setJmxEnabled(boolean jmxEnabled) + { + this.jmxEnabled = jmxEnabled; + } + + public boolean isWebsocketEnabled() + { + return websocketEnabled; + } + + public void setWebsocketEnabled(boolean websocketEnabled) + { + this.websocketEnabled = websocketEnabled; + } + + public void setEnabledOptimizedClassloader(boolean enabledOptimizedClassloader) { + this.enabledOptimizedClassloader = enabledOptimizedClassloader; + } + + public boolean isEnabledOptimizedClassloader() { + return enabledOptimizedClassloader; + } + + public void setOptimizedClassloaderExclusionPattern(String optimizedClassloaderExclusionPattern) { + this.optimizedClassloaderExclusionPattern = optimizedClassloaderExclusionPattern; + } + + public String getOptimizedClassloaderExclusionPattern() { + return optimizedClassloaderExclusionPattern; + } + + /** + * Returns the (HTTP) port. + * + * @return the port + */ + public Integer getPort() + { + return port; + } + + /** + * Sets the (HTTP) port, null to disable. + * + * @param port the port + */ + public void setPort(Integer port) + { + this.port = port; + } + + /** + * Returns the HTTPs port. + * + * @return the HTTPs port + */ + public Integer getSslPort() + { + return sslPort; + } + + /** + * Sets the HTTPs port, null to disable. The keystore stuff must also be set: {@link #setKeyStorePath(String)}, + * {@link #setKeyStorePassword(String)}, {@link #setKeyManagerPassword(String)}. + * + * @param sslPort the HTTPs port + */ + public void setSslPort(Integer sslPort) + { + this.sslPort = sslPort; + } + + /** + * Return the graceful shutdown timeout (in milliseconds). + * + * @return the graceful shutdown timeout (in milliseconds) + */ + public Integer getGracefulShutdown() + { + return gracefulShutdown; + } + + /** + * Sets the graceful shutdown timeout (in milliseconds). + * + * @param gracefulShutdown the graceful shutdown timeout (in milliseconds) + */ + public void setGracefulShutdown(Integer gracefulShutdown) + { + this.gracefulShutdown = gracefulShutdown; + } + + /** + * Returns the thread pool limit. + * + * @return the thread pool limit + */ + public Integer getThreadPoolLimit() + { + return threadPoolLimit; + } + + /** + * Sets the thread pool limit, null to disable. + * + * @param threadPoolLimit the thread pool limit + */ + public void setThreadPoolLimit(Integer threadPoolLimit) + { + this.threadPoolLimit = threadPoolLimit; + } + + /** + * Returns the acceptor limit. + * + * @return the acceptor limit + */ + public Integer getAcceptorLimit() + { + return acceptorLimit; + } + + /** + * Sets the acceptor limit, null to disable. + * + * @param acceptorLimit the acceptor limit + */ + public void setAcceptorLimit(Integer acceptorLimit) + { + this.acceptorLimit = acceptorLimit; + } + + /** + * Returns the key store path. + * + * @return the key store path + */ + public String getKeyStorePath() + { + return keyStorePath; + } + + /** + * Sets the key store path. + * + * @param keyStorePath the key store path + */ + public void setKeyStorePath(String keyStorePath) + { + this.keyStorePath = keyStorePath; + } + + /** + * Returns the key store password. + * + * @return the key store password + */ + public String getKeyStorePassword() + { + return keyStorePassword; + } + + /** + * Sets the key store password. + * + * @param keyStorePassword the key store password + */ + public void setKeyStorePassword(String keyStorePassword) + { + this.keyStorePassword = keyStorePassword; + } + + /** + * Returns the key manager password. + * + * @return the key manager password + */ + public String getKeyManagerPassword() + { + return keyManagerPassword; + } + + /** + * Set the key manager password. + * + * @param keyManagerPassword the key manager password + */ + public void setKeyManagerPassword(String keyManagerPassword) + { + this.keyManagerPassword = keyManagerPassword; + } + + /** + * Returns the path to the webapp directory. + * + * @return the path to the webapp directory + */ + public File getDefaultWar() + { + return defaultWar; + } + + /** + * Sets the path to the webapp directory. + * + * @param defaultWar the path to the webapp directory + */ + public void setDefaultWar(File defaultWar) + { + this.defaultWar = defaultWar; + } + + /** + * Returns the context path. + * + * @return the context path + */ + public String getDefaultContextPath() + { + return defaultContextPath; + } + + /** + * Sets the context path. + * + * @param defaultContextPath the context path + */ + public void setDefaultContextPath(String defaultContextPath) + { + this.defaultContextPath = defaultContextPath; + } + + /** + * Returns the path to the custom web defaults file. + * + * @return the path to the custom web defaults file + */ + public File getCustomWebDefaultsFile() + { + return customWebDefaultsFile; + } + + /** + * Sets the path to the custom web defaults file. + * + * @param customWebDefaultsFile the path to the custom web defaults file + */ + public void setCustomWebDefaultsFile(File customWebDefaultsFile) + { + this.customWebDefaultsFile = customWebDefaultsFile; + } + + /** + * Returns the classpath of the web application. + * + * @return the classpath of the web application + */ + public Collection getDefaultClasspath() + { + return defaultClasspath; + } + + /** + * Sets the classpath of the web application. + * + * @param classpaths the classpath of the web application + */ + public void addDefaultClasspath(String... classpaths) + { + for (String classpath : classpaths) + { + defaultClasspath.add(classpath); + } + } + + /** + * {@inheritDoc} + * + * @see net.sourceforge.eclipsejetty.jetty.AbstractConfiguration#getIdToConfigure() + */ + @Override + protected String getIdToConfigure() + { + return "Server"; + } + + /** + * {@inheritDoc} + * + * @see net.sourceforge.eclipsejetty.jetty.AbstractConfiguration#buildContent(net.sourceforge.eclipsejetty.util.DOMBuilder) + */ + @Override + protected void buildContent(JettyConfigBuilder builder) + { + buildThreadPool(builder); + buildHttpConfig(builder); + buildHttpConnector(builder); + buildHttpsConfig(builder); + buildHttpsConnector(builder); + buildHandler(builder); + //[TODO] Do not know yet why they do not work together. Analyze. + if (!enabledOptimizedClassloader) { + buildAnnotations(builder); + } + buildJNDI(builder); + buildJMX(builder); + //[TODO] Do not know yet why they do not work together. Analyze. + if (!enabledOptimizedClassloader) { + buildExtraOptions(builder); + } + + } + + /** + * Builds the thread pool part. + * + * @param builder the builder + */ + protected abstract void buildThreadPool(JettyConfigBuilder builder); + + /** + * Builds the HTTP config part. + * + * @param builder the builder + */ + protected abstract void buildHttpConfig(JettyConfigBuilder builder); + + /** + * Builds the HTTP connector part. + * + * @param builder the builder + */ + protected abstract void buildHttpConnector(JettyConfigBuilder builder); + + /** + * Builds the HTTPS config part. + * + * @param builder the builder + */ + protected abstract void buildHttpsConfig(JettyConfigBuilder builder); + + /** + * Builds the HTTPs connector part, if enabled. + * + * @param builder the builder + */ + protected abstract void buildHttpsConnector(JettyConfigBuilder builder); + + /** + * Builds the handler part. + * + * @param builder the builder + */ + protected void buildHandler(JettyConfigBuilder builder) + { + buildDefaultHandler(builder); + } + + /** + * Builds the default handler. + * + * @param builder the builder + */ + protected void buildDefaultHandler(JettyConfigBuilder builder) + { + builder.comment("Handler"); + + builder.beginSet("handler"); + { + builder.beginNew("webContext", getDefaultHandlerClass()); + { + File defaultWar = getDefaultWar(); + + builder.arg((defaultWar != null) ? defaultWar.getAbsolutePath() : "/"); + builder.arg(getDefaultContextPath()); + + if (getCustomWebDefaultsFile() != null) + { + builder.set("defaultsDescriptor", getCustomWebDefaultsFile().getAbsolutePath()); + } + + Collection configurations = new LinkedHashSet(); + + collectDefaultHandlerConfigurations(configurations); + + if (configurations.size() > 0) + { + builder.setArray("configurationClasses", configurations.toArray()); + } + + buildDefaultHandlerSetters(builder); + + if (enabledOptimizedClassloader) { + builder.beginSet("classLoader"); + builder.beginNew("optimizedClassLoader", "jetty.classloader.OptimizedWebAppClassLoader"); + builder.beginArg(); + builder.ref("webContext"); + builder.end(); + builder.comment("Pattern of diretories that need to be excluded from being optimized (packaged) by the classloader"); + builder.arg(optimizedClassloaderExclusionPattern); + builder.end(); + } + } + builder.end(); + } + builder.end(); + } + + /** + * Returns the default handler class for the Jetty version. + * + * @return the default handler class + */ + protected abstract String getDefaultHandlerClass(); + + /** + * Builds additional handler setters. + * + * @param builder the builder + */ + protected void buildDefaultHandlerSetters(JettyConfigBuilder builder) + { + builder.set("extraClasspath", link(defaultClasspath)); + } + + /** + * Collect all configurations for the handler + * + * @param configurations the configurations + */ + protected abstract void collectDefaultHandlerConfigurations(Collection configurations); + + /** + * Builds the Annotations part, if needed. + * + * @param builder the builder + */ + protected abstract void buildAnnotations(JettyConfigBuilder builder); + + /** + * Builds the JNDI part, if enabled. + * + * @param builder the builder + */ + protected abstract void buildJNDI(JettyConfigBuilder builder); + + /** + * Builds the JMX part, if enabled. + * + * @param builder the builder + */ + protected abstract void buildJMX(JettyConfigBuilder builder); + + /** + * Builds extra options. + * + * @param builder the builder + */ + protected abstract void buildExtraOptions(JettyConfigBuilder builder); + +} diff --git a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/configuration/JettyLaunchAdvancedConfigurationTab.java b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/configuration/JettyLaunchAdvancedConfigurationTab.java index 7a7266f..a6fe8e5 100644 --- a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/configuration/JettyLaunchAdvancedConfigurationTab.java +++ b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/configuration/JettyLaunchAdvancedConfigurationTab.java @@ -1,1073 +1,1105 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package net.sourceforge.eclipsejetty.launch.configuration; - -import static net.sourceforge.eclipsejetty.launch.util.JettyLaunchUI.*; - -import java.io.File; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; - -import net.sourceforge.eclipsejetty.JettyPlugin; -import net.sourceforge.eclipsejetty.JettyPluginUtils; -import net.sourceforge.eclipsejetty.Messages; -import net.sourceforge.eclipsejetty.jetty.JettyConfig; -import net.sourceforge.eclipsejetty.jetty.JettyConfigType; -import net.sourceforge.eclipsejetty.jetty.JettyVersion; -import net.sourceforge.eclipsejetty.launch.util.JettyLaunchConfigurationAdapter; -import net.sourceforge.eclipsejetty.launch.util.JettyLaunchConfigurationDelegate; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.ILaunchDelegate; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.program.Program; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Spinner; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.FileStoreEditorInput; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; - -/** - * UI - * - * @author Christian Köberl - * @author Manfred Hantschel - */ -public class JettyLaunchAdvancedConfigurationTab extends AbstractJettyLaunchConfigurationTab -{ - private final ModifyDialogListener modifyDialogListener; - private final JettyLaunchConfigEntryList configEntryList; - - private Button embeddedButton; - private Button externButton; - private Text pathText; - private Button pathVariablesButton; - private Button pathBrowseButton; - private Label versionHint; - - private Button jspSupportButton; - private Button jmxSupportButton; - private Button jndiSupportButton; - private Button annotationsSupportButton; - private Button websocketSupportButton; - private Button ajpSupportButton; - private Spinner ajpPortSpinner; - - private Button gracefulShutdownOverrideEnabledButton; - private Spinner gracefulShutdownOverrideTimeoutSpinner; - private Button threadPoolLimitEnabledButton; - private Spinner threadPoolLimitCountSpinner; - private Button acceptorLimitEnabledButton; - private Spinner acceptorLimitCountSpinner; - - private Button customWebDefaultsEnabledButton; - private Text customWebDefaultsResourceText; - private Button customWebDefaultsWorkspaceButton; - private Button customWebDefaultsFileSystemButton; - private Button customWebDefaultsVariablesButton; - - private Button serverCacheDisabledButton; - private Button clientCacheDisabledButton; - - private Table configTable; - private boolean configTableFormatted = false; - private Button openConfigButton; - private Button editConfigButton; - private Button removeConfigButton; - private Button moveUpConfigButton; - private Button moveDownConfigButton; - - private Button showLauncherInfoButton; - private Button consoleEnabledButton; - - public JettyLaunchAdvancedConfigurationTab() - { - modifyDialogListener = new ModifyDialogListener(); - configEntryList = new JettyLaunchConfigEntryList(modifyDialogListener); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) - * @wbp.parser.entryPoint - */ - public void createControl(final Composite parent) - { - Composite tabComposite = createTabComposite(parent, 2, true); - - createJettyGroup(tabComposite); - createJettyFeatureGroup(tabComposite); - createPluginFeatureGroup(tabComposite); - createConfigGroup(tabComposite); - createContextGroup(tabComposite); - createHelpGroup(tabComposite); - - setControl(tabComposite); - } - - private void createJettyGroup(Composite tabComposite) - { - Composite composite = createComposite(tabComposite, SWT.NONE, 2, -1, false, 2, 1); - - final Composite jettyGroup = createGroup(composite, Messages.advConfigTab_jettyGroupTitle, 2, -1, false, 1, 1); - - embeddedButton = - createButton(jettyGroup, SWT.RADIO, Messages.advConfigTab_embeddedButton, - Messages.advConfigTab_embeddedButtonTip, -1, 2, 1, modifyDialogListener); - - externButton = - createButton(jettyGroup, SWT.RADIO, Messages.advConfigTab_externButton, - Messages.advConfigTab_externButtonTip, 128, 1, 1, modifyDialogListener); - pathText = - createText(jettyGroup, SWT.BORDER, Messages.advConfigTab_pathTextTip, -1, -1, 1, 1, modifyDialogListener); - - Composite buttonComposite = createComposite(jettyGroup, SWT.NONE, 3, -1, false, 2, 1); - - createLabel(buttonComposite, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); - pathVariablesButton = - createButton(buttonComposite, SWT.NONE, Messages.advConfigTab_pathVariablesButton, - Messages.advConfigTab_pathVariablesButtonTip, 96, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - chooseVariable(getShell(), pathText); - } - }); - pathBrowseButton = - createButton(buttonComposite, SWT.NONE, Messages.advConfigTab_externalButton, - Messages.advConfigTab_externalButtonTip, 96, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(final SelectionEvent e) - { - String path = - chooseExternalDirectory(getShell(), Messages.advConfigTab_externalTitle, - Messages.advConfigTab_externalMessage, pathText.getText()); - - if (path != null) - { - pathText.setText(path); - } - } - }); - - versionHint = createHint(jettyGroup, String.format("Detected Jetty Version: %s", "none"), -1, 2, 1); - versionHint.setAlignment(SWT.LEFT); - - createImage(composite, JettyPlugin.getIcon(JettyPlugin.JETTY_PLUGIN_ADVANCED_LOGO), 96, SWT.CENTER, SWT.TOP, 1, - 3); - } - - private void createJettyFeatureGroup(Composite tabComposite) - { - final Group jettyFeatureGroup = new Group(tabComposite, SWT.NONE); - jettyFeatureGroup.setLayout(new GridLayout(1, false)); - jettyFeatureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); - jettyFeatureGroup.setText(Messages.advConfigTab_jettyFeaturesGroupTitle); - - jspSupportButton = - createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_jspSupportButton, - Messages.advConfigTab_jspSupportButtonTip, -1, 1, 1, modifyDialogListener); - jndiSupportButton = - createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_jndiSupportButton, - Messages.advConfigTab_jndiSupportButtonTip, -1, 1, 1, modifyDialogListener); - annotationsSupportButton = - createButton(jettyFeatureGroup, SWT.CHECK, "Enable Annotations Support", - "Enables support for annotations as specified in the Servlet 2.5 Specification", -1, 1, 1, - modifyDialogListener); - jmxSupportButton = - createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_jmxSupportButton, - Messages.advConfigTab_jmxSupportButtonTip, -1, 1, 1, modifyDialogListener); - websocketSupportButton = - createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_websocketSupportButton, - Messages.advConfigTab_websocketSupportButtonTip, -1, 1, 1, modifyDialogListener); - - } - - private void createPluginFeatureGroup(Composite tabComposite) - { - final Group pluginFeatureGroup = new Group(tabComposite, SWT.NONE); - pluginFeatureGroup.setLayout(new GridLayout(1, false)); - pluginFeatureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); - pluginFeatureGroup.setText(Messages.advConfigTab_pluginFeaturesGroupTitle); - - showLauncherInfoButton = - createButton(pluginFeatureGroup, SWT.CHECK, Messages.advConfigTab_showLauncherInfoButton, - Messages.advConfigTab_showLauncherInfoButtonTip, 224, 1, 1, modifyDialogListener); - consoleEnabledButton = - createButton(pluginFeatureGroup, SWT.CHECK, Messages.advConfigTab_consoleEnabledButton, - Messages.advConfigTab_consoleEnabledButtonTip, 224, 1, 1, modifyDialogListener); - } - - private void createConfigGroup(Composite tabComposite) - { - final Composite configGroup = - createGroup(tabComposite, Messages.advConfigTab_jettyConfigurationGroupTitle, 3, -1, false, 2, 1); - - gracefulShutdownOverrideEnabledButton = - createButton(configGroup, SWT.CHECK, Messages.advConfigTab_gracefulShutdownTimeoutEnabledButton, - Messages.advConfigTab_gracefulShutdownTimeoutEnabledTip, 224, 1, 1, modifyDialogListener); - gracefulShutdownOverrideTimeoutSpinner = - createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_gracefulShutdownTimeoutTip, 32, -1, 1, 1, - modifyDialogListener); - gracefulShutdownOverrideTimeoutSpinner.setDigits(1); - gracefulShutdownOverrideTimeoutSpinner.setMinimum(1); - gracefulShutdownOverrideTimeoutSpinner.setMaximum(3000); - gracefulShutdownOverrideTimeoutSpinner.setIncrement(1); - gracefulShutdownOverrideTimeoutSpinner.setPageIncrement(10); - createLabel(configGroup, Messages.advConfigTab_gracefulShutdownTimeoutUnit, -1, SWT.LEFT, 1, 1); - - threadPoolLimitEnabledButton = - createButton(configGroup, SWT.CHECK, Messages.advConfigTab_threadPoolLimitEnabledButton, - Messages.advConfigTab_threadPoolLimitEnabledButtonTip, 224, 1, 1, modifyDialogListener); - threadPoolLimitCountSpinner = - createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_threadPoolLimitCountSpinnerTip, 32, -1, 1, 1, - modifyDialogListener); - threadPoolLimitCountSpinner.setMinimum(8); - threadPoolLimitCountSpinner.setMaximum(128); - threadPoolLimitCountSpinner.setIncrement(1); - threadPoolLimitCountSpinner.setPageIncrement(8); - createLabel(configGroup, Messages.advConfigTab_threadPoolLimitCountUnit, -1, SWT.LEFT, 1, 1); - - acceptorLimitEnabledButton = - createButton(configGroup, SWT.CHECK, Messages.advConfigTab_acceptorLimitEnabledButton, - Messages.advConfigTab_acceptorLimitEnabledButtonTip, 224, 1, 1, modifyDialogListener); - acceptorLimitCountSpinner = - createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_acceptorLimitCountSpinnerTip, 32, -1, 1, 1, - modifyDialogListener); - acceptorLimitCountSpinner.setMinimum(2); - acceptorLimitCountSpinner.setMaximum(64); - acceptorLimitCountSpinner.setIncrement(1); - acceptorLimitCountSpinner.setPageIncrement(8); - createLabel(configGroup, Messages.advConfigTab_acceptorLimitCountUnit, -1, SWT.LEFT, 1, 1); - - ajpSupportButton = - createButton(configGroup, SWT.CHECK, Messages.advConfigTab_ajpSupportButton, - Messages.advConfigTab_ajpSupportButtonTip, 224, 1, 1, modifyDialogListener); - // TODO enable when implemented - ajpSupportButton.setEnabled(false); - ajpPortSpinner = - createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_ajpPortSpinnerTip, 32, -1, 2, 1, - modifyDialogListener); - ajpPortSpinner.setMinimum(0); - ajpPortSpinner.setMaximum(65535); - ajpPortSpinner.setIncrement(1); - ajpPortSpinner.setPageIncrement(1000); - // TODO enable when implemented - ajpPortSpinner.setEnabled(false); - - customWebDefaultsEnabledButton = - createButton(configGroup, SWT.CHECK, Messages.advConfigTab_customWebDefaultsEnabledButton, - Messages.advConfigTab_customWebDefaultsEnabledButtonTip, 224, 1, 1, modifyDialogListener); - customWebDefaultsResourceText = - createText(configGroup, SWT.BORDER, Messages.advConfigTab_customWebDefaultsResourceTextTip, -1, -1, 2, 1, - modifyDialogListener); - - Composite customWebDefaultsButtons = createComposite(configGroup, SWT.NONE, 4, -1, false, 3, 1); - createLabel(customWebDefaultsButtons, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); - customWebDefaultsWorkspaceButton = - createButton(customWebDefaultsButtons, SWT.NONE, Messages.advConfigTab_customWebDefaultsWorkspaceButton, - Messages.advConfigTab_customWebDefaultsWorkspaceButtonTip, 96, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(final SelectionEvent e) - { - JettyLaunchConfigurationAdapter adapter = - JettyLaunchConfigurationAdapter.getInstance(getCurrentLaunchConfiguration()); - - String path = - chooseWorkspaceFile(getShell(), adapter.getProject(), - Messages.advConfigTab_customWebDefaultsWorkspaceTitle, - Messages.advConfigTab_customWebDefaultsWorkspaceMessage, - customWebDefaultsResourceText.getText()); - - if (path != null) - { - customWebDefaultsResourceText.setText(path); - } - } - }); - customWebDefaultsFileSystemButton = - createButton(customWebDefaultsButtons, SWT.NONE, Messages.advConfigTab_customWebDefaultsFileSystemButton, - Messages.advConfigTab_customWebDefaultsFileSystemButtonTip, 96, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(final SelectionEvent e) - { - String path = - chooseExternalFile(getShell(), customWebDefaultsResourceText.getText(), - Messages.advConfigTab_customWebDefaultsFileSystemTitle, "*.xml", "*.*"); //$NON-NLS-1$//$NON-NLS-2$ - - if (path != null) - { - customWebDefaultsResourceText.setText(path); - } - } - }); - customWebDefaultsVariablesButton = - createButton(customWebDefaultsButtons, SWT.NONE, Messages.advConfigTab_customWebDefaultsVariablesButton, - Messages.advConfigTab_customWebDefaultsVariablesButtonTip, 96, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - chooseVariable(getShell(), customWebDefaultsResourceText); - } - }); - - serverCacheDisabledButton = - createButton(configGroup, SWT.CHECK, Messages.advConfigTab_serverCacheDisabledButton, - Messages.advConfigTab_serverCacheDisabledButtonTip, 224, 3, 1, modifyDialogListener); - - clientCacheDisabledButton = - createButton(configGroup, SWT.CHECK, Messages.advConfigTab_clientCacheDisabledButton, - Messages.advConfigTab_clientCacheDisabledButtonTip, 224, 3, 1, modifyDialogListener); - } - - private void createContextGroup(Composite tabComposite) - { - Group contextGroup = createGroup(tabComposite, Messages.advConfigTab_contextGroupTitle, 6, -1, true, 2, 1); - - configTable = - createTable(contextGroup, SWT.BORDER | SWT.FULL_SELECTION, 320, 96, 5, 3, - Messages.advConfigTab_contextTableInclude, Messages.advConfigTab_contextTableFile); - configTable.addSelectionListener(new SelectionAdapter() - { - - @Override - public void widgetSelected(SelectionEvent e) - { - updateConfigButtonState(); - } - - }); - - moveUpConfigButton = - createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextUpButton, - Messages.advConfigTab_contextUpButtonTip, 128, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - moveUpConfig(); - } - }); - moveDownConfigButton = - createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextDownButton, - Messages.advConfigTab_contextDownButtonTip, 128, 1, 2, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - moveDownConfig(); - } - }); - - openConfigButton = - createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextOpenButton, - Messages.advConfigTab_contextOpenButtonTip, 128, 1, 1, new SelectionAdapter() - { - - @Override - public void widgetSelected(SelectionEvent e) - { - openConfig(); - } - - }); - - createLabel(contextGroup, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); - createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextAddButton, - Messages.advConfigTab_contextAddButtonTip, 128, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - addConig(); - } - }); - createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextAddExternalButton, - Messages.advConfigTab_contextAddExternalButtonTip, 128, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - addExternalConfig(); - } - }); - - editConfigButton = - createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextEditButton, - Messages.advConfigTab_contextEditButtonTip, 128, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - editConfig(); - } - }); - - removeConfigButton = - createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextRemoveButton, - Messages.advConfigTab_contextRemoveButtonTip, 128, 1, 1, new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - removeConfig(); - } - }); - } - - private void createHelpGroup(Composite tabComposite) - { - Composite helpGroup = createTopComposite(tabComposite, SWT.NONE, 3, -1, false, 2, 1); - - createLabel(helpGroup, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); - createImage(helpGroup, JettyPlugin.getJettyIcon(), 16, SWT.CENTER, SWT.BOTTOM, 1, 1); - createLink(helpGroup, SWT.NONE, Messages.advConfigTab_homepageLink, SWT.RIGHT, 1, 1, new Listener() - { - public void handleEvent(Event event) - { - Program.launch("http://eclipse-jetty.github.io/"); //$NON-NLS-1$ - } - }); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() - */ - public String getName() - { - return Messages.advConfigTab_title; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getImage() - */ - @Override - public Image getImage() - { - return JettyPlugin.getJettyAdvancedIcon(); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getMessage() - */ - @Override - public String getMessage() - { - return Messages.advConfigTab_message; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public void initializeFrom(final ILaunchConfiguration configuration) - { - super.initializeFrom(configuration); - - try - { - JettyLaunchConfigurationAdapter adapter = JettyLaunchConfigurationAdapter.getInstance(configuration); - - embeddedButton.setSelection(adapter.isEmbedded()); - externButton.setSelection(!adapter.isEmbedded()); - pathText.setText(adapter.getPathString()); - - jspSupportButton.setSelection(adapter.isJspSupport()); - jmxSupportButton.setSelection(adapter.isJmxSupport()); - jndiSupportButton.setSelection(adapter.isJndiSupport()); - annotationsSupportButton.setSelection(adapter.isAnnotationsSupport()); - websocketSupportButton.setSelection(adapter.isWebsocketSupport()); - ajpSupportButton.setSelection(adapter.isAjpSupport()); - gracefulShutdownOverrideEnabledButton.setSelection(adapter.isGracefulShutdownOverrideEnabled()); - gracefulShutdownOverrideTimeoutSpinner.setSelection(adapter.getGracefulShutdownOverrideTimeout() / 100); - - threadPoolLimitEnabledButton.setSelection(adapter.isThreadPoolLimitEnabled()); - threadPoolLimitCountSpinner.setSelection(adapter.getThreadPoolLimitCount()); - acceptorLimitEnabledButton.setSelection(adapter.isAcceptorLimitEnabled()); - acceptorLimitCountSpinner.setSelection(adapter.getAcceptorLimitCount()); - - customWebDefaultsEnabledButton.setSelection(adapter.isCustomWebDefaultsEnabled()); - customWebDefaultsResourceText.setText(adapter.getCustomWebDefaultsResource()); - - serverCacheDisabledButton.setSelection(!adapter.isServerCacheEnabled()); - clientCacheDisabledButton.setSelection(!adapter.isClientCacheEnabled()); - - updateTable(adapter, true); - updateConfigButtonState(); - - showLauncherInfoButton.setSelection(adapter.isShowLauncherInfo()); - consoleEnabledButton.setSelection(adapter.isConsoleEnabled()); - } - catch (final CoreException e) - { - JettyPlugin.error(Messages.advConfigTab_initializeFailed, e); - } - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) - { - // intentionally left blank - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - public void performApply(final ILaunchConfigurationWorkingCopy configuration) - { - JettyLaunchConfigurationAdapter adapter = JettyLaunchConfigurationAdapter.getInstance(configuration); - - try - { - adapter.updateConfigVersion(); - - boolean embedded = embeddedButton.getSelection(); - - adapter.setEmbedded(embedded); - - String jettyPath = pathText.getText().trim(); - - adapter.setPathString(jettyPath); - - try - { - JettyVersion jettyVersion = JettyVersion.detect(JettyPluginUtils.resolveVariables(jettyPath), embedded); - - adapter.setMainTypeName(jettyVersion); - adapter.setVersion(jettyVersion); - adapter.setMinorVersion(jettyVersion); - adapter.setMicroVersion(jettyVersion); - } - catch (IllegalArgumentException e) - { - // failed to detect - } - - adapter.setJspSupport(jspSupportButton.getSelection()); - adapter.setJmxSupport(jmxSupportButton.getSelection()); - adapter.setJndiSupport(jndiSupportButton.getSelection()); - adapter.setAnnotationsSupport(annotationsSupportButton.getSelection()); - adapter.setWebsocketSupport(websocketSupportButton.getSelection()); - adapter.setAjpSupport(ajpSupportButton.getSelection()); - adapter.setGracefulShutdownOverrideEnabled(gracefulShutdownOverrideEnabledButton.getSelection()); - adapter.setGracefulShutdownOverrideTimeout(gracefulShutdownOverrideTimeoutSpinner.getSelection() * 100); - - adapter.setThreadPoolLimitEnabled(threadPoolLimitEnabledButton.getSelection()); - adapter.setThreadPoolLimitCount(threadPoolLimitCountSpinner.getSelection()); - adapter.setAcceptorLimitEnabled(acceptorLimitEnabledButton.getSelection()); - adapter.setAcceptorLimitCount(acceptorLimitCountSpinner.getSelection()); - - adapter.setShowLauncherInfo(showLauncherInfoButton.getSelection()); - adapter.setConsoleEnabled(consoleEnabledButton.getSelection()); - - adapter.setCustomWebDefaultsEnabled(customWebDefaultsEnabledButton.getSelection()); - adapter.setCustomWebDefaultsResource(customWebDefaultsResourceText.getText()); - - adapter.setServerCacheEnabled(!serverCacheDisabledButton.getSelection()); - adapter.setClientCacheEnabled(!clientCacheDisabledButton.getSelection()); - - adapter.setConfigs(configEntryList.getConfigs()); - - adapter.setClasspathProvider(JettyLaunchConfigurationAdapter.CLASSPATH_PROVIDER_JETTY); - - updateTable(adapter, false); - updateConfigButtonState(); - } - catch (CoreException e) - { - JettyPlugin.error(Messages.advConfigTab_performApplyFailed, e); - } - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public boolean isValid(final ILaunchConfiguration configuration) - { - setErrorMessage(null); - setMessage(null); - - boolean jndi = jndiSupportButton.getSelection(); - - if (jndi) - { - annotationsSupportButton.setEnabled(false); - annotationsSupportButton.setSelection(true); - } - else - { - annotationsSupportButton.setEnabled(true); - } - - boolean embedded = embeddedButton.getSelection(); - - pathText.setEnabled(!embedded); - pathVariablesButton.setEnabled(!embedded); - pathBrowseButton.setEnabled(!embedded); - - boolean threadPoolLimitEnabled = threadPoolLimitEnabledButton.getSelection(); - - threadPoolLimitCountSpinner.setEnabled(threadPoolLimitEnabled); - - boolean acceptorLimitEnabled = acceptorLimitEnabledButton.getSelection(); - - acceptorLimitCountSpinner.setEnabled(acceptorLimitEnabled); - - if (acceptorLimitEnabled) - { - int minimum = Math.max(8, acceptorLimitCountSpinner.getSelection() * 2); - - threadPoolLimitCountSpinner.setMinimum(minimum); - - if (threadPoolLimitCountSpinner.getSelection() < minimum) - { - threadPoolLimitCountSpinner.setSelection(minimum); - } - } - - gracefulShutdownOverrideTimeoutSpinner.setEnabled(gracefulShutdownOverrideEnabledButton.getSelection()); - - boolean customWebDefaultsEnabled = customWebDefaultsEnabledButton.getSelection(); - - customWebDefaultsResourceText.setEnabled(customWebDefaultsEnabled); - customWebDefaultsVariablesButton.setEnabled(customWebDefaultsEnabled); - customWebDefaultsFileSystemButton.setEnabled(customWebDefaultsEnabled); - customWebDefaultsWorkspaceButton.setEnabled(customWebDefaultsEnabled); - serverCacheDisabledButton.setEnabled(!customWebDefaultsEnabled); - clientCacheDisabledButton.setEnabled(!customWebDefaultsEnabled); - - String jettyPath = null; - - if (!embedded) - { - jettyPath = JettyPluginUtils.resolveVariables(pathText.getText()).trim(); - - if (jettyPath.length() > 0) - { - File f = new File(jettyPath); - if (!f.exists() || !f.isDirectory()) - { - setErrorMessage(String.format(Messages.advConfigTab_pathInvalid, jettyPath)); - return false; - } - } - else - { - setErrorMessage(Messages.advConfigTab_pathMissing); - return false; - } - } - - try - { - JettyVersion version = JettyVersion.detect(JettyPluginUtils.resolveVariables(jettyPath), embedded); - - versionHint.setText(String.format("Detected Jetty Version: %s", version.getVersion())); - } - catch (final IllegalArgumentException e) - { - versionHint.setText(String.format("Detected Jetty Version: %s", "unknown")); - setErrorMessage(String.format(Messages.advConfigTab_versionDetectionFailed, jettyPath)); - return false; - } - - if (customWebDefaultsEnabled) - { - String customWebDefaultsPath = - JettyPluginUtils.resolveVariables(customWebDefaultsResourceText.getText()).trim(); - - if (customWebDefaultsPath.length() > 0) - { - JettyLaunchConfigurationAdapter adapter = JettyLaunchConfigurationAdapter.getInstance(configuration); - - File file = JettyPluginUtils.resolveFile(adapter.getProject(), customWebDefaultsPath); - - if ((file == null) || (!file.exists())) - { - setErrorMessage(String - .format(Messages.advConfigTab_customWebDefaultsInvalid, customWebDefaultsPath)); - - return false; - } - } - else - { - setErrorMessage(String.format(Messages.advConfigTab_customWebDefaultsMissing)); - } - } - - List contexts = configEntryList.getConfigs(); - - for (JettyConfig context : contexts) - { - if ((context.isActive()) && (!context.isValid(ResourcesPlugin.getWorkspace()))) - { - setErrorMessage(String.format(Messages.advConfigTab_contextInvalid, context.getPath())); - } - } - - setDirty(true); - - return true; - } - - /** - * Update the table with the Jetty configuration XML files - * - * @param adapter the adapter - * @param updateType true to update all types - */ - private void updateTable(JettyLaunchConfigurationAdapter adapter, boolean updateType) - { - try - { - List contexts = adapter.getConfigs(); - - if (configEntryList.update(adapter.getConfiguration(), configTable, contexts)) - { - if (!configTableFormatted) - { - for (int i = 0; i < configTable.getColumnCount(); i += 1) - { - configTable.getColumn(i).pack(); - } - } - - if (configTable.getItemCount() > 0) - { - configTableFormatted = true; - } - } - } - catch (CoreException e) - { - JettyPlugin.error(Messages.advConfigTab_updateTableFailed, e); - } - } - - /** - * Choose one Jetty configuration XML file from the workspace - * - * @param path the inital path - * @return the selected file, null if none was selected - */ - protected String chooseConfig(String path) - { - JettyLaunchConfigurationAdapter adapter = - JettyLaunchConfigurationAdapter.getInstance(getCurrentLaunchConfiguration()); - - return chooseWorkspaceFile(getShell(), adapter.getProject(), Messages.advConfigTab_contextAddTitle, - Messages.advConfigTab_contextAddMessage, path); - } - - /** - * Choose one Jetty configuration XML file from the file system - * - * @param path the initial path - * @return the selected file, null if none was selected - */ - protected String chooseConfigFromFileSystem(String path) - { - return chooseExternalFile(getShell(), path, Messages.advConfigTab_contextAddExternalTitle, "*.xml", "*.*"); //$NON-NLS-1$//$NON-NLS-2$ - } - - /** - * Update the state of the buttons for the Jetty configuration XML files - */ - public void updateConfigButtonState() - { - int index = configTable.getSelectionIndex(); - JettyLaunchConfigEntry entry = (index >= 0) ? configEntryList.get(index) : null; - JettyConfigType type = (entry != null) ? entry.getType() : null; - - openConfigButton.setEnabled(configTable.getSelectionIndex() >= 0); - editConfigButton.setEnabled((type == JettyConfigType.PATH) || (type == JettyConfigType.WORKSPACE)); - moveUpConfigButton.setEnabled(index > 0); - moveDownConfigButton.setEnabled((index >= 0) && (index < (configTable.getItemCount() - 1))); - removeConfigButton.setEnabled((type == JettyConfigType.PATH) || (type == JettyConfigType.WORKSPACE)); - } - - /** - * Move the Jetty configuration XML file one step up - */ - private void moveUpConfig() - { - int index = configTable.getSelectionIndex(); - - if (index > 0) - { - configEntryList.exchange(configTable, index - 1); - configTable.setSelection(index - 1); - updateLaunchConfigurationDialog(); - } - } - - /** - * Move the selected Jetty configuration XML file one step down - */ - private void moveDownConfig() - { - int index = configTable.getSelectionIndex(); - - if ((index >= 0) && (index < (configTable.getItemCount() - 1))) - { - configEntryList.exchange(configTable, index); - configTable.setSelection(index + 1); - updateLaunchConfigurationDialog(); - } - } - - /** - * Adds an Jetty configuration XML file from the workspace. - */ - private void addConig() - { - String path = chooseConfig(null); - - if (path != null) - { - configEntryList.add(configTable, new JettyLaunchConfigEntry(new JettyConfig(path, - JettyConfigType.WORKSPACE, true))); - updateLaunchConfigurationDialog(); - } - } - - /** - * Adds an Jetty configuration XML file from the file system. - */ - private void addExternalConfig() - { - String path = chooseConfigFromFileSystem(null); - - if (path != null) - { - configEntryList.add(configTable, new JettyLaunchConfigEntry(new JettyConfig(path, JettyConfigType.PATH, - true))); - updateLaunchConfigurationDialog(); - } - } - - /** - * Opens the Jetty configuration XML file. - */ - private void openConfig() - { - int index = configTable.getSelectionIndex(); - - if (index >= 0) - { - JettyLaunchConfigEntry entry = configEntryList.get(index); - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - IWorkbenchPage page = window.getActivePage(); - IEditorInput input = null; - IEditorDescriptor descriptor = null; - - switch (entry.getType()) - { - case DEFAULT: - try - { - JettyLaunchConfigurationAdapter adapter = - JettyLaunchConfigurationAdapter.getInstance(getCurrentLaunchConfiguration()); - ILaunchDelegate[] delegates = - adapter.getConfiguration().getType() - .getDelegates(new HashSet(Arrays.asList("run"))); //$NON-NLS-1$ - - if (delegates.length == 1) - { - JettyLaunchConfigurationDelegate delegate = - (JettyLaunchConfigurationDelegate) delegates[0].getDelegate(); - - File file = delegate.createJettyConfigurationFile(adapter, true); - descriptor = workbench.getEditorRegistry().getDefaultEditor(file.getName()); - input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile(file)); - } - } - catch (CoreException ex) - { - JettyPlugin.error(Messages.advConfigTab_contextCreateFailed, ex); - } - - break; - - case PATH: - { - File file = new File(entry.getPath()); - descriptor = workbench.getEditorRegistry().getDefaultEditor(file.getName()); - input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile(file)); - } - break; - - case WORKSPACE: - { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(entry.getPath())); - descriptor = workbench.getEditorRegistry().getDefaultEditor(file.getName()); - input = new FileEditorInput(file); - } - break; - } - - if (descriptor != null) - { - try - { - IDE.openEditor(page, input, descriptor.getId()); - } - catch (PartInitException ex) - { - JettyPlugin.error(Messages.advConfigTab_contextOpenFailed, ex); - } - } - } - } - - /** - * Edits the table entry of the Jetty configuration XML file - */ - private void editConfig() - { - int index = configTable.getSelectionIndex(); - - if (index > 0) - { - String path = null; - JettyLaunchConfigEntry entry = configEntryList.get(index); - - switch (entry.getType()) - { - case PATH: - path = chooseConfigFromFileSystem(entry.getPath()); - break; - - case WORKSPACE: - path = chooseConfig(entry.getPath()); - break; - - default: - break; - } - - if (path != null) - { - entry.setPath(path); - updateLaunchConfigurationDialog(); - } - } - } - - /** - * Removes the Jetty configuration XML file from the table - */ - private void removeConfig() - { - int index = configTable.getSelectionIndex(); - - if (index >= 0) - { - JettyLaunchConfigEntry entry = configEntryList.get(index); - - if ((entry.getType() == JettyConfigType.PATH) || (entry.getType() == JettyConfigType.WORKSPACE)) - { - configEntryList.remove(configTable, index); - updateLaunchConfigurationDialog(); - } - } - } - - public final class ModifyDialogListener implements ModifyListener, SelectionListener - { - /** - * {@inheritDoc} - * - * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) - */ - @SuppressWarnings("synthetic-access") - public void modifyText(final ModifyEvent e) - { - updateLaunchConfigurationDialog(); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetDefaultSelected(final SelectionEvent arg0) - { - // intentionally left blank - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @SuppressWarnings("synthetic-access") - public void widgetSelected(final SelectionEvent arg0) - { - updateLaunchConfigurationDialog(); - } - } -} +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package net.sourceforge.eclipsejetty.launch.configuration; + +import static net.sourceforge.eclipsejetty.launch.util.JettyLaunchUI.*; + +import java.io.File; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import net.sourceforge.eclipsejetty.JettyPlugin; +import net.sourceforge.eclipsejetty.JettyPluginUtils; +import net.sourceforge.eclipsejetty.Messages; +import net.sourceforge.eclipsejetty.jetty.JettyConfig; +import net.sourceforge.eclipsejetty.jetty.JettyConfigType; +import net.sourceforge.eclipsejetty.jetty.JettyVersion; +import net.sourceforge.eclipsejetty.launch.util.JettyLaunchConfigurationAdapter; +import net.sourceforge.eclipsejetty.launch.util.JettyLaunchConfigurationDelegate; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchDelegate; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Spinner; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.FileStoreEditorInput; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.part.FileEditorInput; + +/** + * UI + * + * @author Christian Köberl + * @author Manfred Hantschel + */ +public class JettyLaunchAdvancedConfigurationTab extends AbstractJettyLaunchConfigurationTab +{ + private final ModifyDialogListener modifyDialogListener; + private final JettyLaunchConfigEntryList configEntryList; + + private Button embeddedButton; + private Button externButton; + private Text pathText; + private Button pathVariablesButton; + private Button pathBrowseButton; + private Label versionHint; + + private Button enableOptimizedWebAppClassLoaderButton; + private Text optimizedClassLoaderExclusionPatternText; + + private Button jspSupportButton; + private Button jmxSupportButton; + private Button jndiSupportButton; + private Button annotationsSupportButton; + private Button websocketSupportButton; + private Button ajpSupportButton; + private Spinner ajpPortSpinner; + + private Button gracefulShutdownOverrideEnabledButton; + private Spinner gracefulShutdownOverrideTimeoutSpinner; + private Button threadPoolLimitEnabledButton; + private Spinner threadPoolLimitCountSpinner; + private Button acceptorLimitEnabledButton; + private Spinner acceptorLimitCountSpinner; + + private Button customWebDefaultsEnabledButton; + private Text customWebDefaultsResourceText; + private Button customWebDefaultsWorkspaceButton; + private Button customWebDefaultsFileSystemButton; + private Button customWebDefaultsVariablesButton; + + private Button serverCacheDisabledButton; + private Button clientCacheDisabledButton; + + private Table configTable; + private boolean configTableFormatted = false; + private Button openConfigButton; + private Button editConfigButton; + private Button removeConfigButton; + private Button moveUpConfigButton; + private Button moveDownConfigButton; + + private Button showLauncherInfoButton; + private Button consoleEnabledButton; + + public JettyLaunchAdvancedConfigurationTab() + { + modifyDialogListener = new ModifyDialogListener(); + configEntryList = new JettyLaunchConfigEntryList(modifyDialogListener); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) + * @wbp.parser.entryPoint + */ + public void createControl(final Composite parent) + { + Composite tabComposite = createTabComposite(parent, 2, true); + + createJettyGroup(tabComposite); + createJettyWebAppClassLoaderGroup(tabComposite); + createJettyFeatureGroup(tabComposite); + createPluginFeatureGroup(tabComposite); + createConfigGroup(tabComposite); + createContextGroup(tabComposite); + createHelpGroup(tabComposite); + + setControl(tabComposite); + } + + private void createJettyGroup(Composite tabComposite) + { + Composite composite = createComposite(tabComposite, SWT.NONE, 2, -1, false, 2, 1); + + final Composite jettyGroup = createGroup(composite, Messages.advConfigTab_jettyGroupTitle, 2, -1, false, 1, 1); + + embeddedButton = + createButton(jettyGroup, SWT.RADIO, Messages.advConfigTab_embeddedButton, + Messages.advConfigTab_embeddedButtonTip, -1, 2, 1, modifyDialogListener); + + externButton = + createButton(jettyGroup, SWT.RADIO, Messages.advConfigTab_externButton, + Messages.advConfigTab_externButtonTip, 128, 1, 1, modifyDialogListener); + pathText = + createText(jettyGroup, SWT.BORDER, Messages.advConfigTab_pathTextTip, -1, -1, 1, 1, modifyDialogListener); + + Composite buttonComposite = createComposite(jettyGroup, SWT.NONE, 3, -1, false, 2, 1); + + createLabel(buttonComposite, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); + pathVariablesButton = + createButton(buttonComposite, SWT.NONE, Messages.advConfigTab_pathVariablesButton, + Messages.advConfigTab_pathVariablesButtonTip, 96, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + chooseVariable(getShell(), pathText); + } + }); + pathBrowseButton = + createButton(buttonComposite, SWT.NONE, Messages.advConfigTab_externalButton, + Messages.advConfigTab_externalButtonTip, 96, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(final SelectionEvent e) + { + String path = + chooseExternalDirectory(getShell(), Messages.advConfigTab_externalTitle, + Messages.advConfigTab_externalMessage, pathText.getText()); + + if (path != null) + { + pathText.setText(path); + } + } + }); + + versionHint = createHint(jettyGroup, String.format("Detected Jetty Version: %s", "none"), -1, 2, 1); + versionHint.setAlignment(SWT.LEFT); + + createImage(composite, JettyPlugin.getIcon(JettyPlugin.JETTY_PLUGIN_ADVANCED_LOGO), 96, SWT.CENTER, SWT.TOP, 1, + 3); + } + + private void createJettyWebAppClassLoaderGroup(Composite tabComposite) + { + final Group jettyWebAppClassLoaderFeatureGroup = new Group(tabComposite, SWT.NONE); + jettyWebAppClassLoaderFeatureGroup.setLayout(new GridLayout(1, false)); + jettyWebAppClassLoaderFeatureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + jettyWebAppClassLoaderFeatureGroup.setText(Messages.advConfigTab_jettyWebappClassLoaderFeatureGroupTitle); + + enableOptimizedWebAppClassLoaderButton = + createButton(jettyWebAppClassLoaderFeatureGroup, SWT.CHECK, Messages.advConfigTab_enableOptimizedWebAppClassLoaderButtonButton, + Messages.advConfigTab_enableOptimizedWebAppClassLoaderButtonButtonTip, -1, 1, 1, modifyDialogListener); + + final Group jettyWebAppClassLoaderExclusionFeatureGroup = new Group(jettyWebAppClassLoaderFeatureGroup, SWT.NONE); + jettyWebAppClassLoaderExclusionFeatureGroup.setLayout(new GridLayout(1, false)); + jettyWebAppClassLoaderExclusionFeatureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + jettyWebAppClassLoaderExclusionFeatureGroup.setText(Messages.advConfigTab_advancedClassLoaderExclusionTitle); + + optimizedClassLoaderExclusionPatternText = + createText(jettyWebAppClassLoaderExclusionFeatureGroup, SWT.BORDER, Messages.advConfigTab_advancedClassLoaderExclusionPatternTip, -1, -1, 1, 1, modifyDialogListener); + } + + private void createJettyFeatureGroup(Composite tabComposite) + { + final Group jettyFeatureGroup = new Group(tabComposite, SWT.NONE); + jettyFeatureGroup.setLayout(new GridLayout(1, false)); + jettyFeatureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + jettyFeatureGroup.setText(Messages.advConfigTab_jettyFeaturesGroupTitle); + + jspSupportButton = + createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_jspSupportButton, + Messages.advConfigTab_jspSupportButtonTip, -1, 1, 1, modifyDialogListener); + jndiSupportButton = + createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_jndiSupportButton, + Messages.advConfigTab_jndiSupportButtonTip, -1, 1, 1, modifyDialogListener); + annotationsSupportButton = + createButton(jettyFeatureGroup, SWT.CHECK, "Enable Annotations Support", + "Enables support for annotations as specified in the Servlet 2.5 Specification", -1, 1, 1, + modifyDialogListener); + jmxSupportButton = + createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_jmxSupportButton, + Messages.advConfigTab_jmxSupportButtonTip, -1, 1, 1, modifyDialogListener); + websocketSupportButton = + createButton(jettyFeatureGroup, SWT.CHECK, Messages.advConfigTab_websocketSupportButton, + Messages.advConfigTab_websocketSupportButtonTip, -1, 1, 1, modifyDialogListener); + + } + + private void createPluginFeatureGroup(Composite tabComposite) + { + final Group pluginFeatureGroup = new Group(tabComposite, SWT.NONE); + pluginFeatureGroup.setLayout(new GridLayout(1, false)); + pluginFeatureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + pluginFeatureGroup.setText(Messages.advConfigTab_pluginFeaturesGroupTitle); + + showLauncherInfoButton = + createButton(pluginFeatureGroup, SWT.CHECK, Messages.advConfigTab_showLauncherInfoButton, + Messages.advConfigTab_showLauncherInfoButtonTip, 224, 1, 1, modifyDialogListener); + consoleEnabledButton = + createButton(pluginFeatureGroup, SWT.CHECK, Messages.advConfigTab_consoleEnabledButton, + Messages.advConfigTab_consoleEnabledButtonTip, 224, 1, 1, modifyDialogListener); + } + + private void createConfigGroup(Composite tabComposite) + { + final Composite configGroup = + createGroup(tabComposite, Messages.advConfigTab_jettyConfigurationGroupTitle, 3, -1, false, 2, 1); + + gracefulShutdownOverrideEnabledButton = + createButton(configGroup, SWT.CHECK, Messages.advConfigTab_gracefulShutdownTimeoutEnabledButton, + Messages.advConfigTab_gracefulShutdownTimeoutEnabledTip, 224, 1, 1, modifyDialogListener); + gracefulShutdownOverrideTimeoutSpinner = + createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_gracefulShutdownTimeoutTip, 32, -1, 1, 1, + modifyDialogListener); + gracefulShutdownOverrideTimeoutSpinner.setDigits(1); + gracefulShutdownOverrideTimeoutSpinner.setMinimum(1); + gracefulShutdownOverrideTimeoutSpinner.setMaximum(3000); + gracefulShutdownOverrideTimeoutSpinner.setIncrement(1); + gracefulShutdownOverrideTimeoutSpinner.setPageIncrement(10); + createLabel(configGroup, Messages.advConfigTab_gracefulShutdownTimeoutUnit, -1, SWT.LEFT, 1, 1); + + threadPoolLimitEnabledButton = + createButton(configGroup, SWT.CHECK, Messages.advConfigTab_threadPoolLimitEnabledButton, + Messages.advConfigTab_threadPoolLimitEnabledButtonTip, 224, 1, 1, modifyDialogListener); + threadPoolLimitCountSpinner = + createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_threadPoolLimitCountSpinnerTip, 32, -1, 1, 1, + modifyDialogListener); + threadPoolLimitCountSpinner.setMinimum(8); + threadPoolLimitCountSpinner.setMaximum(128); + threadPoolLimitCountSpinner.setIncrement(1); + threadPoolLimitCountSpinner.setPageIncrement(8); + createLabel(configGroup, Messages.advConfigTab_threadPoolLimitCountUnit, -1, SWT.LEFT, 1, 1); + + acceptorLimitEnabledButton = + createButton(configGroup, SWT.CHECK, Messages.advConfigTab_acceptorLimitEnabledButton, + Messages.advConfigTab_acceptorLimitEnabledButtonTip, 224, 1, 1, modifyDialogListener); + acceptorLimitCountSpinner = + createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_acceptorLimitCountSpinnerTip, 32, -1, 1, 1, + modifyDialogListener); + acceptorLimitCountSpinner.setMinimum(2); + acceptorLimitCountSpinner.setMaximum(64); + acceptorLimitCountSpinner.setIncrement(1); + acceptorLimitCountSpinner.setPageIncrement(8); + createLabel(configGroup, Messages.advConfigTab_acceptorLimitCountUnit, -1, SWT.LEFT, 1, 1); + + ajpSupportButton = + createButton(configGroup, SWT.CHECK, Messages.advConfigTab_ajpSupportButton, + Messages.advConfigTab_ajpSupportButtonTip, 224, 1, 1, modifyDialogListener); + // TODO enable when implemented + ajpSupportButton.setEnabled(false); + ajpPortSpinner = + createSpinner(configGroup, SWT.BORDER, Messages.advConfigTab_ajpPortSpinnerTip, 32, -1, 2, 1, + modifyDialogListener); + ajpPortSpinner.setMinimum(0); + ajpPortSpinner.setMaximum(65535); + ajpPortSpinner.setIncrement(1); + ajpPortSpinner.setPageIncrement(1000); + // TODO enable when implemented + ajpPortSpinner.setEnabled(false); + + customWebDefaultsEnabledButton = + createButton(configGroup, SWT.CHECK, Messages.advConfigTab_customWebDefaultsEnabledButton, + Messages.advConfigTab_customWebDefaultsEnabledButtonTip, 224, 1, 1, modifyDialogListener); + customWebDefaultsResourceText = + createText(configGroup, SWT.BORDER, Messages.advConfigTab_customWebDefaultsResourceTextTip, -1, -1, 2, 1, + modifyDialogListener); + + Composite customWebDefaultsButtons = createComposite(configGroup, SWT.NONE, 4, -1, false, 3, 1); + createLabel(customWebDefaultsButtons, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); + customWebDefaultsWorkspaceButton = + createButton(customWebDefaultsButtons, SWT.NONE, Messages.advConfigTab_customWebDefaultsWorkspaceButton, + Messages.advConfigTab_customWebDefaultsWorkspaceButtonTip, 96, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(final SelectionEvent e) + { + JettyLaunchConfigurationAdapter adapter = + JettyLaunchConfigurationAdapter.getInstance(getCurrentLaunchConfiguration()); + + String path = + chooseWorkspaceFile(getShell(), adapter.getProject(), + Messages.advConfigTab_customWebDefaultsWorkspaceTitle, + Messages.advConfigTab_customWebDefaultsWorkspaceMessage, + customWebDefaultsResourceText.getText()); + + if (path != null) + { + customWebDefaultsResourceText.setText(path); + } + } + }); + customWebDefaultsFileSystemButton = + createButton(customWebDefaultsButtons, SWT.NONE, Messages.advConfigTab_customWebDefaultsFileSystemButton, + Messages.advConfigTab_customWebDefaultsFileSystemButtonTip, 96, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(final SelectionEvent e) + { + String path = + chooseExternalFile(getShell(), customWebDefaultsResourceText.getText(), + Messages.advConfigTab_customWebDefaultsFileSystemTitle, "*.xml", "*.*"); //$NON-NLS-1$//$NON-NLS-2$ + + if (path != null) + { + customWebDefaultsResourceText.setText(path); + } + } + }); + customWebDefaultsVariablesButton = + createButton(customWebDefaultsButtons, SWT.NONE, Messages.advConfigTab_customWebDefaultsVariablesButton, + Messages.advConfigTab_customWebDefaultsVariablesButtonTip, 96, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + chooseVariable(getShell(), customWebDefaultsResourceText); + } + }); + + serverCacheDisabledButton = + createButton(configGroup, SWT.CHECK, Messages.advConfigTab_serverCacheDisabledButton, + Messages.advConfigTab_serverCacheDisabledButtonTip, 224, 3, 1, modifyDialogListener); + + clientCacheDisabledButton = + createButton(configGroup, SWT.CHECK, Messages.advConfigTab_clientCacheDisabledButton, + Messages.advConfigTab_clientCacheDisabledButtonTip, 224, 3, 1, modifyDialogListener); + } + + private void createContextGroup(Composite tabComposite) + { + Group contextGroup = createGroup(tabComposite, Messages.advConfigTab_contextGroupTitle, 6, -1, true, 2, 1); + + configTable = + createTable(contextGroup, SWT.BORDER | SWT.FULL_SELECTION, 320, 96, 5, 3, + Messages.advConfigTab_contextTableInclude, Messages.advConfigTab_contextTableFile); + configTable.addSelectionListener(new SelectionAdapter() + { + + @Override + public void widgetSelected(SelectionEvent e) + { + updateConfigButtonState(); + } + + }); + + moveUpConfigButton = + createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextUpButton, + Messages.advConfigTab_contextUpButtonTip, 128, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + moveUpConfig(); + } + }); + moveDownConfigButton = + createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextDownButton, + Messages.advConfigTab_contextDownButtonTip, 128, 1, 2, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + moveDownConfig(); + } + }); + + openConfigButton = + createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextOpenButton, + Messages.advConfigTab_contextOpenButtonTip, 128, 1, 1, new SelectionAdapter() + { + + @Override + public void widgetSelected(SelectionEvent e) + { + openConfig(); + } + + }); + + createLabel(contextGroup, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); + createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextAddButton, + Messages.advConfigTab_contextAddButtonTip, 128, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + addConig(); + } + }); + createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextAddExternalButton, + Messages.advConfigTab_contextAddExternalButtonTip, 128, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + addExternalConfig(); + } + }); + + editConfigButton = + createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextEditButton, + Messages.advConfigTab_contextEditButtonTip, 128, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + editConfig(); + } + }); + + removeConfigButton = + createButton(contextGroup, SWT.NONE, Messages.advConfigTab_contextRemoveButton, + Messages.advConfigTab_contextRemoveButtonTip, 128, 1, 1, new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent e) + { + removeConfig(); + } + }); + } + + private void createHelpGroup(Composite tabComposite) + { + Composite helpGroup = createTopComposite(tabComposite, SWT.NONE, 3, -1, false, 2, 1); + + createLabel(helpGroup, JettyPluginUtils.EMPTY, -1, SWT.LEFT, 1, 1); + createImage(helpGroup, JettyPlugin.getJettyIcon(), 16, SWT.CENTER, SWT.BOTTOM, 1, 1); + createLink(helpGroup, SWT.NONE, Messages.advConfigTab_homepageLink, SWT.RIGHT, 1, 1, new Listener() + { + public void handleEvent(Event event) + { + Program.launch("http://eclipse-jetty.github.io/"); //$NON-NLS-1$ + } + }); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() + */ + public String getName() + { + return Messages.advConfigTab_title; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getImage() + */ + @Override + public Image getImage() + { + return JettyPlugin.getJettyAdvancedIcon(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getMessage() + */ + @Override + public String getMessage() + { + return Messages.advConfigTab_message; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public void initializeFrom(final ILaunchConfiguration configuration) + { + super.initializeFrom(configuration); + + try + { + JettyLaunchConfigurationAdapter adapter = JettyLaunchConfigurationAdapter.getInstance(configuration); + + embeddedButton.setSelection(adapter.isEmbedded()); + externButton.setSelection(!adapter.isEmbedded()); + pathText.setText(adapter.getPathString()); + + enableOptimizedWebAppClassLoaderButton.setSelection(adapter.isOptimizedClassLoaderEnabled()); + optimizedClassLoaderExclusionPatternText.setText(adapter.getOptimizedClassLoaderExclusionPattern()); + + jspSupportButton.setSelection(adapter.isJspSupport()); + jmxSupportButton.setSelection(adapter.isJmxSupport()); + jndiSupportButton.setSelection(adapter.isJndiSupport()); + annotationsSupportButton.setSelection(adapter.isAnnotationsSupport()); + websocketSupportButton.setSelection(adapter.isWebsocketSupport()); + ajpSupportButton.setSelection(adapter.isAjpSupport()); + gracefulShutdownOverrideEnabledButton.setSelection(adapter.isGracefulShutdownOverrideEnabled()); + gracefulShutdownOverrideTimeoutSpinner.setSelection(adapter.getGracefulShutdownOverrideTimeout() / 100); + + threadPoolLimitEnabledButton.setSelection(adapter.isThreadPoolLimitEnabled()); + threadPoolLimitCountSpinner.setSelection(adapter.getThreadPoolLimitCount()); + acceptorLimitEnabledButton.setSelection(adapter.isAcceptorLimitEnabled()); + acceptorLimitCountSpinner.setSelection(adapter.getAcceptorLimitCount()); + + customWebDefaultsEnabledButton.setSelection(adapter.isCustomWebDefaultsEnabled()); + customWebDefaultsResourceText.setText(adapter.getCustomWebDefaultsResource()); + + serverCacheDisabledButton.setSelection(!adapter.isServerCacheEnabled()); + clientCacheDisabledButton.setSelection(!adapter.isClientCacheEnabled()); + + updateTable(adapter, true); + updateConfigButtonState(); + + showLauncherInfoButton.setSelection(adapter.isShowLauncherInfo()); + consoleEnabledButton.setSelection(adapter.isConsoleEnabled()); + } + catch (final CoreException e) + { + JettyPlugin.error(Messages.advConfigTab_initializeFailed, e); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) + { + // intentionally left blank + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void performApply(final ILaunchConfigurationWorkingCopy configuration) + { + JettyLaunchConfigurationAdapter adapter = JettyLaunchConfigurationAdapter.getInstance(configuration); + + try + { + adapter.updateConfigVersion(); + + boolean embedded = embeddedButton.getSelection(); + + adapter.setEmbedded(embedded); + + String jettyPath = pathText.getText().trim(); + + adapter.setPathString(jettyPath); + + try + { + JettyVersion jettyVersion = JettyVersion.detect(JettyPluginUtils.resolveVariables(jettyPath), embedded); + + adapter.setMainTypeName(jettyVersion); + adapter.setVersion(jettyVersion); + adapter.setMinorVersion(jettyVersion); + adapter.setMicroVersion(jettyVersion); + } + catch (IllegalArgumentException e) + { + // failed to detect + } + + adapter.setOptimizedClassLoaderEnabled(enableOptimizedWebAppClassLoaderButton.getSelection()); + adapter.setOptimizedClassLoaderExclusionPattern(optimizedClassLoaderExclusionPatternText.getText()); + + adapter.setJspSupport(jspSupportButton.getSelection()); + adapter.setJmxSupport(jmxSupportButton.getSelection()); + adapter.setJndiSupport(jndiSupportButton.getSelection()); + adapter.setAnnotationsSupport(annotationsSupportButton.getSelection()); + adapter.setWebsocketSupport(websocketSupportButton.getSelection()); + adapter.setAjpSupport(ajpSupportButton.getSelection()); + adapter.setGracefulShutdownOverrideEnabled(gracefulShutdownOverrideEnabledButton.getSelection()); + adapter.setGracefulShutdownOverrideTimeout(gracefulShutdownOverrideTimeoutSpinner.getSelection() * 100); + + adapter.setThreadPoolLimitEnabled(threadPoolLimitEnabledButton.getSelection()); + adapter.setThreadPoolLimitCount(threadPoolLimitCountSpinner.getSelection()); + adapter.setAcceptorLimitEnabled(acceptorLimitEnabledButton.getSelection()); + adapter.setAcceptorLimitCount(acceptorLimitCountSpinner.getSelection()); + + adapter.setShowLauncherInfo(showLauncherInfoButton.getSelection()); + adapter.setConsoleEnabled(consoleEnabledButton.getSelection()); + + adapter.setCustomWebDefaultsEnabled(customWebDefaultsEnabledButton.getSelection()); + adapter.setCustomWebDefaultsResource(customWebDefaultsResourceText.getText()); + + adapter.setServerCacheEnabled(!serverCacheDisabledButton.getSelection()); + adapter.setClientCacheEnabled(!clientCacheDisabledButton.getSelection()); + + adapter.setConfigs(configEntryList.getConfigs()); + + adapter.setClasspathProvider(JettyLaunchConfigurationAdapter.CLASSPATH_PROVIDER_JETTY); + + updateTable(adapter, false); + updateConfigButtonState(); + } + catch (CoreException e) + { + JettyPlugin.error(Messages.advConfigTab_performApplyFailed, e); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public boolean isValid(final ILaunchConfiguration configuration) + { + setErrorMessage(null); + setMessage(null); + + boolean jndi = jndiSupportButton.getSelection(); + + if (jndi) + { + annotationsSupportButton.setEnabled(false); + annotationsSupportButton.setSelection(true); + } + else + { + annotationsSupportButton.setEnabled(true); + } + + boolean embedded = embeddedButton.getSelection(); + + pathText.setEnabled(!embedded); + pathVariablesButton.setEnabled(!embedded); + pathBrowseButton.setEnabled(!embedded); + + optimizedClassLoaderExclusionPatternText.setEnabled(enableOptimizedWebAppClassLoaderButton.getSelection()); + + boolean threadPoolLimitEnabled = threadPoolLimitEnabledButton.getSelection(); + + threadPoolLimitCountSpinner.setEnabled(threadPoolLimitEnabled); + + boolean acceptorLimitEnabled = acceptorLimitEnabledButton.getSelection(); + + acceptorLimitCountSpinner.setEnabled(acceptorLimitEnabled); + + if (acceptorLimitEnabled) + { + int minimum = Math.max(8, acceptorLimitCountSpinner.getSelection() * 2); + + threadPoolLimitCountSpinner.setMinimum(minimum); + + if (threadPoolLimitCountSpinner.getSelection() < minimum) + { + threadPoolLimitCountSpinner.setSelection(minimum); + } + } + + gracefulShutdownOverrideTimeoutSpinner.setEnabled(gracefulShutdownOverrideEnabledButton.getSelection()); + + boolean customWebDefaultsEnabled = customWebDefaultsEnabledButton.getSelection(); + + customWebDefaultsResourceText.setEnabled(customWebDefaultsEnabled); + customWebDefaultsVariablesButton.setEnabled(customWebDefaultsEnabled); + customWebDefaultsFileSystemButton.setEnabled(customWebDefaultsEnabled); + customWebDefaultsWorkspaceButton.setEnabled(customWebDefaultsEnabled); + serverCacheDisabledButton.setEnabled(!customWebDefaultsEnabled); + clientCacheDisabledButton.setEnabled(!customWebDefaultsEnabled); + + String jettyPath = null; + + if (!embedded) + { + jettyPath = JettyPluginUtils.resolveVariables(pathText.getText()).trim(); + + if (jettyPath.length() > 0) + { + File f = new File(jettyPath); + if (!f.exists() || !f.isDirectory()) + { + setErrorMessage(String.format(Messages.advConfigTab_pathInvalid, jettyPath)); + return false; + } + } + else + { + setErrorMessage(Messages.advConfigTab_pathMissing); + return false; + } + } + + try + { + JettyVersion version = JettyVersion.detect(JettyPluginUtils.resolveVariables(jettyPath), embedded); + + versionHint.setText(String.format("Detected Jetty Version: %s", version.getVersion())); + } + catch (final IllegalArgumentException e) + { + versionHint.setText(String.format("Detected Jetty Version: %s", "unknown")); + setErrorMessage(String.format(Messages.advConfigTab_versionDetectionFailed, jettyPath)); + return false; + } + + if (customWebDefaultsEnabled) + { + String customWebDefaultsPath = + JettyPluginUtils.resolveVariables(customWebDefaultsResourceText.getText()).trim(); + + if (customWebDefaultsPath.length() > 0) + { + JettyLaunchConfigurationAdapter adapter = JettyLaunchConfigurationAdapter.getInstance(configuration); + + File file = JettyPluginUtils.resolveFile(adapter.getProject(), customWebDefaultsPath); + + if ((file == null) || (!file.exists())) + { + setErrorMessage(String + .format(Messages.advConfigTab_customWebDefaultsInvalid, customWebDefaultsPath)); + + return false; + } + } + else + { + setErrorMessage(String.format(Messages.advConfigTab_customWebDefaultsMissing)); + } + } + + List contexts = configEntryList.getConfigs(); + + for (JettyConfig context : contexts) + { + if ((context.isActive()) && (!context.isValid(ResourcesPlugin.getWorkspace()))) + { + setErrorMessage(String.format(Messages.advConfigTab_contextInvalid, context.getPath())); + } + } + + setDirty(true); + + return true; + } + + /** + * Update the table with the Jetty configuration XML files + * + * @param adapter the adapter + * @param updateType true to update all types + */ + private void updateTable(JettyLaunchConfigurationAdapter adapter, boolean updateType) + { + try + { + List contexts = adapter.getConfigs(); + + if (configEntryList.update(adapter.getConfiguration(), configTable, contexts)) + { + if (!configTableFormatted) + { + for (int i = 0; i < configTable.getColumnCount(); i += 1) + { + configTable.getColumn(i).pack(); + } + } + + if (configTable.getItemCount() > 0) + { + configTableFormatted = true; + } + } + } + catch (CoreException e) + { + JettyPlugin.error(Messages.advConfigTab_updateTableFailed, e); + } + } + + /** + * Choose one Jetty configuration XML file from the workspace + * + * @param path the inital path + * @return the selected file, null if none was selected + */ + protected String chooseConfig(String path) + { + JettyLaunchConfigurationAdapter adapter = + JettyLaunchConfigurationAdapter.getInstance(getCurrentLaunchConfiguration()); + + return chooseWorkspaceFile(getShell(), adapter.getProject(), Messages.advConfigTab_contextAddTitle, + Messages.advConfigTab_contextAddMessage, path); + } + + /** + * Choose one Jetty configuration XML file from the file system + * + * @param path the initial path + * @return the selected file, null if none was selected + */ + protected String chooseConfigFromFileSystem(String path) + { + return chooseExternalFile(getShell(), path, Messages.advConfigTab_contextAddExternalTitle, "*.xml", "*.*"); //$NON-NLS-1$//$NON-NLS-2$ + } + + /** + * Update the state of the buttons for the Jetty configuration XML files + */ + public void updateConfigButtonState() + { + int index = configTable.getSelectionIndex(); + JettyLaunchConfigEntry entry = (index >= 0) ? configEntryList.get(index) : null; + JettyConfigType type = (entry != null) ? entry.getType() : null; + + openConfigButton.setEnabled(configTable.getSelectionIndex() >= 0); + editConfigButton.setEnabled((type == JettyConfigType.PATH) || (type == JettyConfigType.WORKSPACE)); + moveUpConfigButton.setEnabled(index > 0); + moveDownConfigButton.setEnabled((index >= 0) && (index < (configTable.getItemCount() - 1))); + removeConfigButton.setEnabled((type == JettyConfigType.PATH) || (type == JettyConfigType.WORKSPACE)); + } + + /** + * Move the Jetty configuration XML file one step up + */ + private void moveUpConfig() + { + int index = configTable.getSelectionIndex(); + + if (index > 0) + { + configEntryList.exchange(configTable, index - 1); + configTable.setSelection(index - 1); + updateLaunchConfigurationDialog(); + } + } + + /** + * Move the selected Jetty configuration XML file one step down + */ + private void moveDownConfig() + { + int index = configTable.getSelectionIndex(); + + if ((index >= 0) && (index < (configTable.getItemCount() - 1))) + { + configEntryList.exchange(configTable, index); + configTable.setSelection(index + 1); + updateLaunchConfigurationDialog(); + } + } + + /** + * Adds an Jetty configuration XML file from the workspace. + */ + private void addConig() + { + String path = chooseConfig(null); + + if (path != null) + { + configEntryList.add(configTable, new JettyLaunchConfigEntry(new JettyConfig(path, + JettyConfigType.WORKSPACE, true))); + updateLaunchConfigurationDialog(); + } + } + + /** + * Adds an Jetty configuration XML file from the file system. + */ + private void addExternalConfig() + { + String path = chooseConfigFromFileSystem(null); + + if (path != null) + { + configEntryList.add(configTable, new JettyLaunchConfigEntry(new JettyConfig(path, JettyConfigType.PATH, + true))); + updateLaunchConfigurationDialog(); + } + } + + /** + * Opens the Jetty configuration XML file. + */ + private void openConfig() + { + int index = configTable.getSelectionIndex(); + + if (index >= 0) + { + JettyLaunchConfigEntry entry = configEntryList.get(index); + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IWorkbenchPage page = window.getActivePage(); + IEditorInput input = null; + IEditorDescriptor descriptor = null; + + switch (entry.getType()) + { + case DEFAULT: + try + { + JettyLaunchConfigurationAdapter adapter = + JettyLaunchConfigurationAdapter.getInstance(getCurrentLaunchConfiguration()); + ILaunchDelegate[] delegates = + adapter.getConfiguration().getType() + .getDelegates(new HashSet(Arrays.asList("run"))); //$NON-NLS-1$ + + if (delegates.length == 1) + { + JettyLaunchConfigurationDelegate delegate = + (JettyLaunchConfigurationDelegate) delegates[0].getDelegate(); + + File file = delegate.createJettyConfigurationFile(adapter, true); + descriptor = workbench.getEditorRegistry().getDefaultEditor(file.getName()); + input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile(file)); + } + } + catch (CoreException ex) + { + JettyPlugin.error(Messages.advConfigTab_contextCreateFailed, ex); + } + + break; + + case PATH: + { + File file = new File(entry.getPath()); + descriptor = workbench.getEditorRegistry().getDefaultEditor(file.getName()); + input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile(file)); + } + break; + + case WORKSPACE: + { + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(entry.getPath())); + descriptor = workbench.getEditorRegistry().getDefaultEditor(file.getName()); + input = new FileEditorInput(file); + } + break; + } + + if (descriptor != null) + { + try + { + IDE.openEditor(page, input, descriptor.getId()); + } + catch (PartInitException ex) + { + JettyPlugin.error(Messages.advConfigTab_contextOpenFailed, ex); + } + } + } + } + + /** + * Edits the table entry of the Jetty configuration XML file + */ + private void editConfig() + { + int index = configTable.getSelectionIndex(); + + if (index > 0) + { + String path = null; + JettyLaunchConfigEntry entry = configEntryList.get(index); + + switch (entry.getType()) + { + case PATH: + path = chooseConfigFromFileSystem(entry.getPath()); + break; + + case WORKSPACE: + path = chooseConfig(entry.getPath()); + break; + + default: + break; + } + + if (path != null) + { + entry.setPath(path); + updateLaunchConfigurationDialog(); + } + } + } + + /** + * Removes the Jetty configuration XML file from the table + */ + private void removeConfig() + { + int index = configTable.getSelectionIndex(); + + if (index >= 0) + { + JettyLaunchConfigEntry entry = configEntryList.get(index); + + if ((entry.getType() == JettyConfigType.PATH) || (entry.getType() == JettyConfigType.WORKSPACE)) + { + configEntryList.remove(configTable, index); + updateLaunchConfigurationDialog(); + } + } + } + + public final class ModifyDialogListener implements ModifyListener, SelectionListener + { + /** + * {@inheritDoc} + * + * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) + */ + @SuppressWarnings("synthetic-access") + public void modifyText(final ModifyEvent e) + { + updateLaunchConfigurationDialog(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetDefaultSelected(final SelectionEvent arg0) + { + // intentionally left blank + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @SuppressWarnings("synthetic-access") + public void widgetSelected(final SelectionEvent arg0) + { + updateLaunchConfigurationDialog(); + } + } +} diff --git a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationAdapter.java b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationAdapter.java index 0c7f4b1..81fec4f 100644 --- a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationAdapter.java +++ b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationAdapter.java @@ -1,1643 +1,1681 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package net.sourceforge.eclipsejetty.launch.util; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import net.sourceforge.eclipsejetty.JettyPlugin; -import net.sourceforge.eclipsejetty.JettyPluginM2EUtils; -import net.sourceforge.eclipsejetty.JettyPluginUtils; -import net.sourceforge.eclipsejetty.Messages; -import net.sourceforge.eclipsejetty.jetty.JettyConfig; -import net.sourceforge.eclipsejetty.jetty.JettyConfigType; -import net.sourceforge.eclipsejetty.jetty.JettyVersion; -import net.sourceforge.eclipsejetty.jetty.JettyVersionType; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.osgi.service.prefs.BackingStoreException; - -/** - * Constants for the Jetty plugin and an adapter for the configuration. - * - * @author Christian Köberl - * @author Manfred Hantschel - */ -public class JettyLaunchConfigurationAdapter -{ - - public static final String LAUNCH_CONFIG_TYPE = JettyPlugin.PLUGIN_ID + ".launchConfigurationType"; //$NON-NLS-1$ - public static final String CLASSPATH_PROVIDER_JETTY = JettyPlugin.PLUGIN_ID + ".JettyLaunchClassPathProvider"; //$NON-NLS-1$ - - private static final int CONFIG_VERSION = 1; - - private static final String ATTR_CONFIG_VERSION = JettyPlugin.PLUGIN_ID + ".configVersion"; //$NON-NLS-1$ - private static final String ATTR_CONTEXT = JettyPlugin.PLUGIN_ID + ".context"; //$NON-NLS-1$ - private static final String ATTR_WEBAPPDIR = JettyPlugin.PLUGIN_ID + ".webappdir"; //$NON-NLS-1$ - private static final String ATTR_PORT = JettyPlugin.PLUGIN_ID + ".port"; //$NON-NLS-1$ - private static final String ATTR_HTTPS_PORT = JettyPlugin.PLUGIN_ID + ".httpsPort"; //$NON-NLS-1$ - private static final String ATTR_HTTPS_ENABLED = JettyPlugin.PLUGIN_ID + ".httpsEnabled"; //$NON-NLS-1$ - private static final String ATTR_JETTY_PATH = JettyPlugin.PLUGIN_ID + ".jetty.path"; //$NON-NLS-1$ - private static final String ATTR_JETTY_EMBEDDED = JettyPlugin.PLUGIN_ID + ".jetty.embedded"; //$NON-NLS-1$ - private static final String ATTR_JETTY_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.version"; //$NON-NLS-1$ - private static final String ATTR_JETTY_MAJOR_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.majorVersion"; //$NON-NLS-1$ - private static final String ATTR_JETTY_MINOR_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.minorVersion"; //$NON-NLS-1$ - private static final String ATTR_JETTY_MICRO_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.microVersion"; //$NON-NLS-1$ - private static final String ATTR_JETTY_CONFIG_PATH = JettyPlugin.PLUGIN_ID + ".jetty.config.path."; //$NON-NLS-1$ - private static final String ATTR_JETTY_CONFIG_TYPE = JettyPlugin.PLUGIN_ID + ".jetty.config.type."; //$NON-NLS-1$ - private static final String ATTR_JETTY_CONFIG_ACTIVE = JettyPlugin.PLUGIN_ID + ".jetty.config.active."; //$NON-NLS-1$ - private static final String ATTR_ANNOTATIONS_ENABLED = JettyPlugin.PLUGIN_ID + ".annotations.enabled"; //$NON-NLS-1$ - private static final String ATTR_JSP_ENABLED = JettyPlugin.PLUGIN_ID + ".jsp.enabled"; //$NON-NLS-1$ - private static final String ATTR_JMX_ENABLED = JettyPlugin.PLUGIN_ID + ".jmx.enabled"; //$NON-NLS-1$ - private static final String ATTR_JNDI_ENABLED = JettyPlugin.PLUGIN_ID + ".jndi.enabled"; //$NON-NLS-1$ - private static final String ATTR_AJP_ENABLED = JettyPlugin.PLUGIN_ID + ".ajp.enabled"; //$NON-NLS-1$ - private static final String ATTR_WEBSOCKET_ENABLED = JettyPlugin.PLUGIN_ID + ".websocket.enabled"; //$NON-NLS-1$ - private static final String ATTR_THREAD_POOL_LIMIT_ENABLED = JettyPlugin.PLUGIN_ID + ".threadPool.limit.enabled"; //$NON-NLS-1$ - private static final String ATTR_THREAD_POOL_LIMIT_COUNT = JettyPlugin.PLUGIN_ID + ".threadPool.limit.count"; //$NON-NLS-1$ - private static final String ATTR_ACCEPTOR_LIMIT_ENABLED = JettyPlugin.PLUGIN_ID + ".acceptor.limit.enabled"; //$NON-NLS-1$ - private static final String ATTR_ACCEPTOR_LIMIT_COUNT = JettyPlugin.PLUGIN_ID + ".acceptor.limit.count"; //$NON-NLS-1$ - private static final String ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_ENABLED = JettyPlugin.PLUGIN_ID - + ".gracefulShutdown.override.enabled"; //$NON-NLS-1$ - private static final String ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_TIMEOUT = JettyPlugin.PLUGIN_ID - + ".gracefulShutdown.override.timeout"; //$NON-NLS-1$ - private static final String ATTR_SERVER_CACHE_ENABLED = JettyPlugin.PLUGIN_ID + ".cache.server.enabled"; //$NON-NLS-1$ - private static final String ATTR_CLIENT_CACHE_ENABLED = JettyPlugin.PLUGIN_ID + ".cache.client.enabled"; //$NON-NLS-1$ - private static final String ATTR_CUSTOM_WEB_DEFAULTS_ENABLED = JettyPlugin.PLUGIN_ID + ".customWebDefaults.enabled"; //$NON-NLS-1$ - private static final String ATTR_CUSTOM_WEB_DEFAULTS_RESOURCE = JettyPlugin.PLUGIN_ID - + ".customWebDefaults.resource"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDE_SCOPE_COMPILE = JettyPlugin.PLUGIN_ID + ".scope.compile.exclude"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDE_SCOPE_PROVIDED = JettyPlugin.PLUGIN_ID + ".scope.provided.exclude"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDE_SCOPE_RUNTIME = JettyPlugin.PLUGIN_ID + ".scope.runtime.exclude"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDE_SCOPE_TEST = JettyPlugin.PLUGIN_ID + ".scope.test.exclude"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDE_SCOPE_SYSTEM = JettyPlugin.PLUGIN_ID + ".scope.system.exclude"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDE_SCOPE_IMPORT = JettyPlugin.PLUGIN_ID + ".scope.import.exclude"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDE_SCOPE_NONE = JettyPlugin.PLUGIN_ID + ".scope.none.exclude"; //$NON-NLS-1$ - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - private static final String ATTR_EXCLUDED_LIBS = JettyPlugin.PLUGIN_ID + ".launcher.excludeLibs"; //$NON-NLS-1$ - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - private static final String ATTR_INCLUDED_LIBS = JettyPlugin.PLUGIN_ID + ".launcher.includeLibs"; //$NON-NLS-1$ - private static final String ATTR_EXCLUDED_GENERIC_IDS = JettyPlugin.PLUGIN_ID + ".launcher.excludeGenericIds"; //$NON-NLS-1$ - private static final String ATTR_INCLUDED_GENERIC_IDS = JettyPlugin.PLUGIN_ID + ".launcher.includeGenericIds"; //$NON-NLS-1$ - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - private static final String ATTR_GLOBAL_LIBS = JettyPlugin.PLUGIN_ID + ".launcher.globalLibs"; //$NON-NLS-1$ - private static final String ATTR_GLOBAL_GENERIC_IDS = JettyPlugin.PLUGIN_ID + ".launcher.globalGenericIds"; //$NON-NLS-1$ - private static final String ATTR_SHOW_LAUNCHER_INFO = JettyPlugin.PLUGIN_ID + ".launcher.info"; //$NON-NLS-1$ - private static final String ATTR_CONSOLE_ENABLED = JettyPlugin.PLUGIN_ID + ".console.enabled"; //$NON-NLS-1$ - - /** - * Creates an readable configuration adapter. - * - * @param configuration the configuration, must not be null - * @return the adapter - */ - public static JettyLaunchConfigurationAdapter getInstance(ILaunchConfiguration configuration) - { - return new JettyLaunchConfigurationAdapter(configuration); - } - - /** - * Creates an read and writable configuration adapter. - * - * @param configuration the configuration, must not be null - * @return the adapter - */ - public static JettyLaunchConfigurationAdapter getInstance(ILaunchConfigurationWorkingCopy configuration) - { - return new JettyLaunchConfigurationAdapter(configuration); - } - - private final ILaunchConfiguration configuration; - - /** - * Creates the adapter. - * - * @param configuration the configuration - */ - protected JettyLaunchConfigurationAdapter(ILaunchConfiguration configuration) - { - super(); - - this.configuration = configuration; - } - - /** - * Returns the readable configuration. - * - * @return the configuration - */ - public ILaunchConfiguration getConfiguration() - { - return configuration; - } - - /** - * Returns the read and writable configuration. - * - * @return the configuration - * @throws CoreException if configuration is only readable - */ - public ILaunchConfigurationWorkingCopy getConfigurationWorkingCopy() throws CoreException - { - try - { - return (ILaunchConfigurationWorkingCopy) configuration; - } - catch (ClassCastException e) - { - throw new CoreException(new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, - Messages.adapter_configurationOnlyReadable)); - } - } - - /** - * Initializes a new launch configuration. - * - * @param project the project, must not be null - * @param webAppPath the web application path, must not be null - * @throws CoreException on occasion - */ - public void initialize(IProject project, File webAppPath) throws CoreException - { - ILaunchConfigurationWorkingCopy configuration = getConfigurationWorkingCopy(); - String projectName = (project != null) ? project.getName() : JettyPluginUtils.EMPTY; - - setProjectName(projectName); - setClasspathProvider(CLASSPATH_PROVIDER_JETTY); - updateConfigVersion(); - - String launchConfigName = projectName; - - if ((launchConfigName == null) || (launchConfigName.length() == 0)) - { - launchConfigName = Messages.adapter_defaultConfigName; - } - - launchConfigName = JettyLaunchUtils.generateLaunchConfigurationName(launchConfigName); - - configuration.rename(launchConfigName); - - setContext(getContext()); - - if (webAppPath == null) - { - try - { - List path = JettyLaunchUtils.findWebXMLs(project, 1); - - if (path.size() > 0) - { - IPath webAppResource = path.get(0).getFullPath().removeLastSegments(2); - - webAppPath = JettyPluginUtils.resolveFolder(project, webAppResource.toString()); - } - } - catch (CoreException e) - { - // ignore - } - } - - if (webAppPath != null) - { - setWebAppString(JettyPluginUtils.toRelativePath(project, webAppPath.toString())); - } - else - { - setWebAppString("src/main/webapp"); //$NON-NLS-1$ - } - - setPort(getPort()); - setHttpsPort(getHttpsPort()); - setHttpsEnabled(isHttpsEnabled()); - - boolean embedded = isEmbedded(); - - setEmbedded(embedded); - - String jettyPath = getPathString(); - - setPathString(jettyPath); - - try - { - JettyVersion jettyVersion = JettyVersion.detect(JettyPluginUtils.resolveVariables(jettyPath), embedded); - - setMainTypeName(jettyVersion); - setVersion(jettyVersion); - setMinorVersion(jettyVersion); - setMicroVersion(jettyVersion); - } - catch (IllegalArgumentException e) - { - // failed to detect - } - - setJspSupport(isJspSupport()); - setJmxSupport(isJmxSupport()); - setJndiSupport(isJndiSupport()); - setAjpSupport(isAjpSupport()); - - setThreadPoolLimitEnabled(isThreadPoolLimitEnabled()); - setThreadPoolLimitCount(getThreadPoolLimitCount()); - setAcceptorLimitEnabled(isAcceptorLimitEnabled()); - setAcceptorLimitCount(getAcceptorLimitCount()); - setGracefulShutdownOverrideEnabled(isGracefulShutdownOverrideEnabled()); - setGracefulShutdownOverrideTimeout(getGracefulShutdownOverrideTimeout()); - - setServerCacheEnabled(isServerCacheEnabled()); - setClientCacheEnabled(isClientCacheEnabled()); - - setShowLauncherInfo(isShowLauncherInfo()); - setConsoleEnabled(isConsoleEnabled()); - - setCustomWebDefaultsEnabled(isCustomWebDefaultsEnabled()); - setCustomWebDefaultsResource(getCustomWebDefaultsResource()); - - setConfigs(getConfigs()); - - setScopeCompileExcluded(isScopeCompileExcluded()); - setScopeProvidedExcluded(isScopeProvidedExcluded()); - setScopeRuntimeExcluded(isScopeRuntimeExcluded()); - setScopeSystemExcluded(isScopeSystemExcluded()); - setScopeTestExcluded(isScopeTestExcluded()); - setScopeImportExcluded(isScopeImportExcluded()); - setScopeNoneExcluded(isScopeNoneExcluded()); - - setExcludedGenericIds(getExcludedGenericIds()); - setIncludedGenericIds(getIncludedGenericIds()); - setGlobalGenericIds(getGlobalGenericIds()); - - deprecatedInitialize(); - } - - private void deprecatedInitialize() throws CoreException - { - setExcludedLibs(getExcludedLibs()); - setIncludedLibs(getIncludedLibs()); - setGlobalLibs(getGlobalLibs()); - } - - /** - * Returns the configuration version to distinguish between versions of the plugin. - * - * @return the configuration version - * @throws CoreException on occasion - */ - public int getConfigVersion() throws CoreException - { - return getAttribute(false, ATTR_CONFIG_VERSION, 0); - } - - /** - * Updates the configuration version to the one supported by the plugin. - * - * @throws CoreException on occasion - */ - public void updateConfigVersion() throws CoreException - { - setAttribute(false, ATTR_CONFIG_VERSION, CONFIG_VERSION); - } - - /** - * Returns the name of the selected eclipse project, that should be launched. - * - * @return the project - * @throws CoreException on occasion - */ - public String getProjectName() throws CoreException - { - return getAttribute(false, IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, JettyPluginUtils.EMPTY); - } - - /** - * Sets the name of the selected eclipse project, that should be launched. - * - * @param project the project - * @throws CoreException on occasion - */ - public void setProjectName(String project) throws CoreException - { - setAttribute(false, IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project); - } - - /** - * Returns the project as defined by the project name. - * - * @return the project, null if unable to locate - */ - public IProject getProject() - { - try - { - return JettyPluginUtils.getProject(getProjectName()); - } - catch (CoreException e) - { - return null; - } - } - - /** - * Returns the context path (path part of the URL) of the application. - * - * @return the context path - * @throws CoreException on occasion - */ - public String getContext() throws CoreException - { - return getAttribute(false, ATTR_CONTEXT, "/"); //$NON-NLS-1$ - } - - /** - * Sets the context path (path part of the URL) of the application. - * - * @param context the context - * @throws CoreException on occasion - */ - public void setContext(String context) throws CoreException - { - setAttribute(false, ATTR_CONTEXT, context); - } - - /** - * Returns the location of the web application directory in the workspace. - * - * @return the location of the web application directory - * @throws CoreException on occasion - */ - public String getWebAppString() throws CoreException - { - return getAttribute(false, ATTR_WEBAPPDIR, "src/main/webapp"); //$NON-NLS-1$ - } - - /** - * Sets the location of the web application directory in the workspace. - * - * @param webappdir the location of the web application directory - * @throws CoreException on occasion - */ - public void setWebAppString(String webappdir) throws CoreException - { - setAttribute(false, ATTR_WEBAPPDIR, webappdir); - } - - /** - * Tries to determine the web application path from the web application directory. - * - * @return the path, null if unable to determine - */ - public File getWebAppPath() - { - try - { - return JettyPluginUtils.resolveFolder(getProject(), getWebAppString()); - } - catch (CoreException e) - { - return null; - } - } - - /** - * Returns the (HTTP) port. - * - * @return the port - * @throws CoreException on occasion - */ - public int getPort() throws CoreException - { - try - { - return Integer.parseInt(getAttribute(true, ATTR_PORT, "8080")); // string for backward compatibility //$NON-NLS-1$ - } - catch (NumberFormatException e) - { - return 8080; - } - } - - /** - * Sets the (HTTP) port. - * - * @param port the port - * @throws CoreException on occasion - */ - public void setPort(int port) throws CoreException - { - setAttribute(true, ATTR_PORT, String.valueOf(port)); // string for backward compatibility - } - - /** - * Returns the (HTTPs) port. - * - * @return the port - * @throws CoreException on occasion - */ - public int getHttpsPort() throws CoreException - { - try - { - return Integer.parseInt(getAttribute(true, ATTR_HTTPS_PORT, "8443")); // string for backward compatibility //$NON-NLS-1$ - } - catch (NumberFormatException e) - { - return 8443; - } - } - - /** - * Sets the (HTTPs) port. - * - * @param httpsPort the port - * @throws CoreException on occasion - */ - public void setHttpsPort(int httpsPort) throws CoreException - { - setAttribute(true, ATTR_HTTPS_PORT, String.valueOf(httpsPort)); // string for backward compatibility - } - - /** - * Returns true if HTTPs is enabled. - * - * @return true if enabled - * @throws CoreException on occasion - */ - public boolean isHttpsEnabled() throws CoreException - { - return getAttribute(true, ATTR_HTTPS_ENABLED, false); - } - - /** - * Set to true, if the HTTPs is enabled. - * - * @param httpsEnabled true if enabled - * @throws CoreException on occasion - */ - public void setHttpsEnabled(boolean httpsEnabled) throws CoreException - { - setAttribute(true, ATTR_HTTPS_ENABLED, httpsEnabled); - } - - /** - * Returns the path to an optionally available Jetty. - * - * @return the path - * @throws CoreException on occasion - */ - public String getPathString() throws CoreException - { - return getAttribute(true, ATTR_JETTY_PATH, JettyPluginUtils.EMPTY); - } - - /** - * Sets the path to an optionally available Jetty. - * - * @param path the path - * @throws CoreException on occasion - */ - public void setPathString(String path) throws CoreException - { - setAttribute(true, ATTR_JETTY_PATH, path); - } - - /** - * Tries to determine the path to an optionally available Jetty. - * - * @return the path, null if unable to determine - */ - public File getPath() - { - try - { - return JettyPluginUtils.resolveFolder(getProject(), getPathString()); - } - catch (CoreException e) - { - return null; - } - } - - /** - * Returns true, if the embedded Jetty should be used. - * - * @return true, if the embedded Jetty should be used. - * @throws CoreException on occasion - */ - public boolean isEmbedded() throws CoreException - { - return getAttribute(true, ATTR_JETTY_EMBEDDED, true); - } - - /** - * Set to true, if the embedded Jetty should be used. - * - * @param embedded true, if the embedded Jetty should be used - * @throws CoreException on occasion - */ - public void setEmbedded(boolean embedded) throws CoreException - { - setAttribute(true, ATTR_JETTY_EMBEDDED, embedded); - } - - /** - * Returns the version of the Jetty. - * - * @return the version of the Jetty - * @throws CoreException on occasion - */ - public JettyVersionType getVersion() throws CoreException - { - return JettyVersionType.valueOf(getAttribute(true, ATTR_JETTY_VERSION, JettyVersionType.JETTY_EMBEDDED.name())); - } - - /** - * Sets the version of the Jetty. - * - * @param jettyVersion the version - * @throws CoreException on occasion - */ - public void setVersion(JettyVersion jettyVersion) throws CoreException - { - setAttribute(true, ATTR_JETTY_VERSION, jettyVersion.getType().name()); - } - - /** - * Returns the major version of the Jetty. - * - * @return the major version of the Jetty - * @throws CoreException on occasion - */ - public int getMajorVersion() throws CoreException - { - return getAttribute(true, ATTR_JETTY_MAJOR_VERSION, -1); - } - - /** - * Sets the major version of the Jetty. - * - * @param jettyVersion the version - * @throws CoreException on occasion - */ - public void setMajorVersion(JettyVersion jettyVersion) throws CoreException - { - setAttribute(true, ATTR_JETTY_MAJOR_VERSION, (jettyVersion.getMajorVersion() != null) ? jettyVersion - .getMajorVersion().intValue() : -1); - } - - /** - * Returns the minor version of the Jetty. - * - * @return the minor version of the Jetty - * @throws CoreException on occasion - */ - public int getMinorVersion() throws CoreException - { - return getAttribute(true, ATTR_JETTY_MINOR_VERSION, -1); - } - - /** - * Sets the minor version of the Jetty. - * - * @param jettyVersion the version - * @throws CoreException on occasion - */ - public void setMinorVersion(JettyVersion jettyVersion) throws CoreException - { - setAttribute(true, ATTR_JETTY_MINOR_VERSION, (jettyVersion.getMinorVersion() != null) ? jettyVersion - .getMinorVersion().intValue() : -1); - } - - /** - * Returns the micro version of the Jetty. - * - * @return the micro version of the Jetty - * @throws CoreException on occasion - */ - public int getMicroVersion() throws CoreException - { - return getAttribute(true, ATTR_JETTY_MICRO_VERSION, -1); - } - - /** - * Sets the micro version of the Jetty. - * - * @param jettyVersion the version - * @throws CoreException on occasion - */ - public void setMicroVersion(JettyVersion jettyVersion) throws CoreException - { - setAttribute(true, ATTR_JETTY_MICRO_VERSION, (jettyVersion.getMicroVersion() != null) ? jettyVersion - .getMicroVersion().intValue() : -1); - } - - /** - * Returns the configuration context holders. - * - * @return a list of {@link JettyConfig}s - * @throws CoreException on occasion - */ - public List getConfigs() throws CoreException - { - List results = new ArrayList(); - int index = 0; - - while (true) - { - String path = getAttribute(false, ATTR_JETTY_CONFIG_PATH + index, (String) null); - - if (path == null) - { - break; - } - - JettyConfigType type = - JettyConfigType - .valueOf(getAttribute(false, ATTR_JETTY_CONFIG_TYPE + index, JettyConfigType.PATH.name())); - boolean active = getAttribute(false, ATTR_JETTY_CONFIG_ACTIVE + index, true); - - results.add(new JettyConfig(path, type, active)); - index += 1; - } - - if (results.size() == 0) - { - results.add(new JettyConfig(JettyPluginUtils.EMPTY, JettyConfigType.DEFAULT, true)); - } - - return results; - } - - /** - * Sets the configuration context holders. - * - * @param entries the entries - * @throws CoreException on occasion - */ - public void setConfigs(List entries) throws CoreException - { - int index = 0; - - for (JettyConfig entry : entries) - { - setAttribute(false, ATTR_JETTY_CONFIG_PATH + index, entry.getPath()); - setAttribute(false, ATTR_JETTY_CONFIG_TYPE + index, entry.getType().name()); - setAttribute(false, ATTR_JETTY_CONFIG_ACTIVE + index, entry.isActive()); - - index += 1; - } - - ILaunchConfigurationWorkingCopy configuration = getConfigurationWorkingCopy(); - - while (configuration.getAttribute(ATTR_JETTY_CONFIG_PATH + index, (String) null) != null) - { - configuration.removeAttribute(ATTR_JETTY_CONFIG_PATH + index); - configuration.removeAttribute(ATTR_JETTY_CONFIG_TYPE + index); - configuration.removeAttribute(ATTR_JETTY_CONFIG_ACTIVE + index); - - index += 1; - } - } - - /** - * Returns true, if annotations should be supported. - * - * @return true, if annotations should be supported - * @throws CoreException on occasion - */ - public boolean isAnnotationsSupport() throws CoreException - { - return !"false".equals(getAttribute(true, ATTR_ANNOTATIONS_ENABLED, "true")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Set to true, if JSPs should be supported. - * - * @param annotationsSupport true, if JSPs should be supported - * @throws CoreException on occasion - */ - public void setAnnotationsSupport(boolean annotationsSupport) throws CoreException - { - setAttribute(true, ATTR_ANNOTATIONS_ENABLED, String.valueOf(annotationsSupport)); // string for backward compatibility - } - - /** - * Returns true, if JSPs should be supported. - * - * @return true, if JSPs should be supported - * @throws CoreException on occasion - */ - public boolean isJspSupport() throws CoreException - { - return !"false".equals(getAttribute(true, ATTR_JSP_ENABLED, "true")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Set to true, if JSPs should be supported. - * - * @param jspSupport true, if JSPs should be supported - * @throws CoreException on occasion - */ - public void setJspSupport(boolean jspSupport) throws CoreException - { - setAttribute(true, ATTR_JSP_ENABLED, String.valueOf(jspSupport)); // string for backward compatibility - } - - /** - * Returns true, if JMX should be supported. - * - * @return true, if JMX should be supported - * @throws CoreException on occasion - */ - public boolean isJmxSupport() throws CoreException - { - return "true".equals(getAttribute(true, ATTR_JMX_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Set to true, if JMX should be supported. - * - * @param jmxSupport true, if JMX should be supported - * @throws CoreException on occasion - */ - public void setJmxSupport(boolean jmxSupport) throws CoreException - { - setAttribute(true, ATTR_JMX_ENABLED, String.valueOf(jmxSupport)); // string for backward compatibility - } - - /** - * Returns true, if JNDI should be supported. - * - * @return true, if JNDI should be supported - * @throws CoreException on occasion - */ - public boolean isJndiSupport() throws CoreException - { - return "true".equals(getAttribute(true, ATTR_JNDI_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Set to true, if JNDI should be supported. - * - * @param jndiSupport true, if JNDI should be supported - * @throws CoreException on occasion - */ - public void setJndiSupport(boolean jndiSupport) throws CoreException - { - setAttribute(true, ATTR_JNDI_ENABLED, String.valueOf(jndiSupport)); // string for backward compatibility - } - - /** - * Returns true, if an AJP connector should be supported. - * - * @return true, if an AJP connector should be supported - * @throws CoreException on occasion - */ - public boolean isAjpSupport() throws CoreException - { - return "true".equals(getAttribute(true, ATTR_AJP_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Set to true, if an AJP connector should be supported. - * - * @param ajpSupport true, if an AJP connector should be supported. - * @throws CoreException on occasion - */ - public void setAjpSupport(boolean ajpSupport) throws CoreException - { - setAttribute(true, ATTR_AJP_ENABLED, String.valueOf(ajpSupport)); // string for backward compatibility - } - - /** - * Returns true, if Websockets should be supported. - * - * @return true, if Websockets should be supported - * @throws CoreException on occasion - */ - public boolean isWebsocketSupport() throws CoreException - { - return "true".equals(getAttribute(true, ATTR_WEBSOCKET_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Set to true, if Websockets should be supported. - * - * @param websocketSupport true, if Websockets should be supported. - * @throws CoreException on occasion - */ - public void setWebsocketSupport(boolean websocketSupport) throws CoreException - { - setAttribute(true, ATTR_WEBSOCKET_ENABLED, String.valueOf(websocketSupport)); // string for backward compatibility - } - - /** - * Returns true, if the size of Jetty's thread pool is limited. - * - * @return true, if the size of Jetty's thread pool is limited - * @throws CoreException on occasion - */ - public boolean isThreadPoolLimitEnabled() throws CoreException - { - return getAttribute(true, ATTR_THREAD_POOL_LIMIT_ENABLED, false); - } - - /** - * Set to true, if the size of Jetty's thread pool is limited. - * - * @param value true, if the size of Jetty's thread pool is limited - * @throws CoreException on occasion - */ - public void setThreadPoolLimitEnabled(boolean value) throws CoreException - { - setAttribute(true, ATTR_THREAD_POOL_LIMIT_ENABLED, value); - } - - /** - * Returns the maximum size of Jetty's thead pool. - * - * @return the maximum size of Jetty's thead pool - * @throws CoreException on occasion - */ - public int getThreadPoolLimitCount() throws CoreException - { - return getAttribute(true, ATTR_THREAD_POOL_LIMIT_COUNT, 16); - } - - /** - * Sets the maximum size of Jetty's thead pool - * - * @param value the maximum size of Jetty's thead pool - * @throws CoreException on occasion - */ - public void setThreadPoolLimitCount(int value) throws CoreException - { - setAttribute(true, ATTR_THREAD_POOL_LIMIT_COUNT, value); - } - - /** - * Returns true, if the number of Jetty's acceptors is limited. - * - * @return true, if the number of Jetty's acceptors is limited - * @throws CoreException on occasion - */ - public boolean isAcceptorLimitEnabled() throws CoreException - { - return getAttribute(true, ATTR_ACCEPTOR_LIMIT_ENABLED, false); - } - - /** - * Set to true, if the number of Jetty's acceptors is limited - * - * @param value true, if the number of Jetty's acceptors is limited - * @throws CoreException on occasion - */ - public void setAcceptorLimitEnabled(boolean value) throws CoreException - { - setAttribute(true, ATTR_ACCEPTOR_LIMIT_ENABLED, value); - } - - /** - * Returns the maximum number of acceptors Jetty should use. - * - * @return the maximum number of acceptors Jetty should use - * @throws CoreException on occasion - */ - public int getAcceptorLimitCount() throws CoreException - { - return getAttribute(true, ATTR_ACCEPTOR_LIMIT_COUNT, 8); - } - - /** - * Sets the the maximum number of acceptors Jetty should use. - * - * @param value the maximum number of acceptors Jetty should use - * @throws CoreException on occasion - */ - public void setAcceptorLimitCount(int value) throws CoreException - { - setAttribute(true, ATTR_ACCEPTOR_LIMIT_COUNT, value); - } - - /** - * Return true, if the graceful shutdown override is enabled. - * - * @return true, if the graceful shutdown override is enabled - * @throws CoreException on occasion - */ - public boolean isGracefulShutdownOverrideEnabled() throws CoreException - { - return getAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_ENABLED, false); - } - - /** - * Set to true, if the graceful shutdown override is enabled. - * - * @param value true, if the graceful shutdown override is enabled - * @throws CoreException on occasion - */ - public void setGracefulShutdownOverrideEnabled(boolean value) throws CoreException - { - setAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_ENABLED, value); - } - - /** - * Returns the timeout for the graceful shutdown (in milliseconds). - * - * @return the timeout for the graceful shutdown (in milliseconds) - * @throws CoreException on occasion - */ - public int getGracefulShutdownOverrideTimeout() throws CoreException - { - return getAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_TIMEOUT, 1000); - } - - /** - * Sets the timeout for the graceful shutdown (in milliseconds) - * - * @param value the timeout for the graceful shutdown (in milliseconds) - * @throws CoreException on occasion - */ - public void setGracefulShutdownOverrideTimeout(int value) throws CoreException - { - setAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_TIMEOUT, value); - } - - /** - * Returns true, if Jetty's server cache is enabled. - * - * @return true, if Jetty's server cache is enabled - * @throws CoreException on occasion - */ - public boolean isServerCacheEnabled() throws CoreException - { - return getAttribute(true, ATTR_SERVER_CACHE_ENABLED, true); - } - - /** - * Set to true, if Jetty's server cache is enabled. - * - * @param enabled true, if Jetty's server cache is enabled - * @throws CoreException on occasion - */ - public void setServerCacheEnabled(boolean enabled) throws CoreException - { - setAttribute(true, ATTR_SERVER_CACHE_ENABLED, enabled); - } - - /** - * Returns true, if the cache pragma no cache should not be sent. - * - * @return true, if the cache pragma no cache should not be sent - * @throws CoreException on occasion - */ - public boolean isClientCacheEnabled() throws CoreException - { - return getAttribute(true, ATTR_CLIENT_CACHE_ENABLED, true); - } - - /** - * Set to true, if the cache pragma no cache should not be sent. - * - * @param enabled true, if the cache pragma no cache should not be sent - * @throws CoreException on occasion - */ - public void setClientCacheEnabled(boolean enabled) throws CoreException - { - setAttribute(true, ATTR_CLIENT_CACHE_ENABLED, enabled); - } - - /** - * Returns true, if a custom default web.xml should be used. - * - * @return true, if a custom default web.xml should be used - * @throws CoreException on occasion - */ - public boolean isCustomWebDefaultsEnabled() throws CoreException - { - return getAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_ENABLED, false); - } - - /** - * Set to true, if a custom default web.xml should be used - * - * @param value true, if a custom default web.xml should be used - * @throws CoreException on occasion - */ - public void setCustomWebDefaultsEnabled(boolean value) throws CoreException - { - setAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_ENABLED, value); - } - - /** - * Returns the custom default web.xml. - * - * @return the custom default web.xml - * @throws CoreException on occasion - */ - public String getCustomWebDefaultsResource() throws CoreException - { - return getAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_RESOURCE, JettyPluginUtils.EMPTY); - } - - /** - * Sets the custom default web.xml - * - * @param value the custom default web.xml - * @throws CoreException on occasion - */ - public void setCustomWebDefaultsResource(String value) throws CoreException - { - setAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_RESOURCE, value); - } - - /** - * Tries to determine the custom web.xml file from the resource. - * - * @return the custom web.xml file, null if not found or not enabled - */ - public File getCustomWebDefaultFile() - { - try - { - if (!isCustomWebDefaultsEnabled()) - { - return null; - } - - return JettyPluginUtils.resolveFile(getProject(), getCustomWebDefaultsResource()); - } - catch (CoreException e) - { - // ignore - } - - return null; - } - - /** - * Returns true, if Maven dependencies with the compile scope should be excluded. - * - * @return true, if Maven dependencies with the compile scope should be excluded - * @throws CoreException on occasion - */ - public boolean isScopeCompileExcluded() throws CoreException - { - return getAttribute(false, ATTR_EXCLUDE_SCOPE_COMPILE, false); - } - - /** - * Set to true, if Maven dependencies with the compile scope should be excluded. - * - * @param value true, if Maven dependencies with the compile scope should be excluded - * @throws CoreException on occasion - */ - public void setScopeCompileExcluded(boolean value) throws CoreException - { - setAttribute(false, ATTR_EXCLUDE_SCOPE_COMPILE, value); - } - - /** - * Returns true, if Maven dependencies with the provided scope should be excluded. - * - * @return true, if Maven dependencies with the provided scope should be excluded - * @throws CoreException on occasion - */ - public boolean isScopeProvidedExcluded() throws CoreException - { - return getAttribute(false, ATTR_EXCLUDE_SCOPE_PROVIDED, true); - } - - /** - * Set to true, if Maven dependencies with the provided scope should be excluded. - * - * @param value true, if Maven dependencies with the provided scope should be excluded - * @throws CoreException on occasion - */ - public void setScopeProvidedExcluded(boolean value) throws CoreException - { - setAttribute(false, ATTR_EXCLUDE_SCOPE_PROVIDED, value); - } - - /** - * Returns true, if Maven dependencies with the runtime scope should be excluded. - * - * @return true, if Maven dependencies with the runtime scope should be excluded - * @throws CoreException on occasion - */ - public boolean isScopeRuntimeExcluded() throws CoreException - { - return getAttribute(false, ATTR_EXCLUDE_SCOPE_RUNTIME, false); - } - - /** - * Set to true, if Maven dependencies with the runtime scope should be excluded. - * - * @param value true, if Maven dependencies with the runtime scope should be excluded - * @throws CoreException on occasion - */ - public void setScopeRuntimeExcluded(boolean value) throws CoreException - { - setAttribute(false, ATTR_EXCLUDE_SCOPE_RUNTIME, value); - } - - /** - * Returns true, if Maven dependencies with the test scope should be excluded. - * - * @return true, if Maven dependencies with the test scope should be excluded - * @throws CoreException on occasion - */ - public boolean isScopeTestExcluded() throws CoreException - { - return getAttribute(false, ATTR_EXCLUDE_SCOPE_TEST, true); - } - - /** - * Set to true, if Maven dependencies with the test scope should be excluded. - * - * @param value true, if Maven dependencies with the test scope should be excluded - * @throws CoreException on occasion - */ - public void setScopeTestExcluded(boolean value) throws CoreException - { - setAttribute(false, ATTR_EXCLUDE_SCOPE_TEST, value); - } - - /** - * Returns true, if Maven dependencies with the system scope should be excluded. - * - * @return true, if Maven dependencies with the system scope should be excluded - * @throws CoreException on occasion - */ - public boolean isScopeSystemExcluded() throws CoreException - { - return getAttribute(false, ATTR_EXCLUDE_SCOPE_SYSTEM, true); - } - - /** - * Set to true, if Maven dependencies with the system scope should be excluded. - * - * @param value true, if Maven dependencies with the system scope should be excluded - * @throws CoreException on occasion - */ - public void setScopeSystemExcluded(boolean value) throws CoreException - { - setAttribute(false, ATTR_EXCLUDE_SCOPE_SYSTEM, value); - } - - /** - * Returns true, if Maven dependencies with the import scope should be excluded. - * - * @return true, if Maven dependencies with the import scope should be excluded - * @throws CoreException on occasion - */ - public boolean isScopeImportExcluded() throws CoreException - { - return getAttribute(false, ATTR_EXCLUDE_SCOPE_IMPORT, true); - } - - /** - * Set to true, if Maven dependencies with the import scope should be excluded. - * - * @param value true, if Maven dependencies with the import scope should be excluded - * @throws CoreException on occasion - */ - public void setScopeImportExcluded(boolean value) throws CoreException - { - setAttribute(false, ATTR_EXCLUDE_SCOPE_IMPORT, value); - } - - /** - * Returns true, if dependencies unknown to Maven should be excluded. - * - * @return true, if dependencies unknown to Maven should be excluded - * @throws CoreException on occasion - */ - public boolean isScopeNoneExcluded() throws CoreException - { - if (!hasAttribute(ATTR_EXCLUDE_SCOPE_NONE)) - { - return JettyPluginM2EUtils.getMavenProjectFacade(this) != null; - } - - return getAttribute(false, ATTR_EXCLUDE_SCOPE_NONE, false); - } - - /** - * Set to true, if dependencies unknown to Maven should be excluded. - * - * @param value true, if dependencies unknown to Maven should be excluded - * @throws CoreException on occasion - */ - public void setScopeNoneExcluded(boolean value) throws CoreException - { - setAttribute(false, ATTR_EXCLUDE_SCOPE_NONE, value); - } - - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - public String getExcludedLibs() throws CoreException - { - return getAttribute(false, ATTR_EXCLUDED_LIBS, ".*servlet-api.*"); //$NON-NLS-1$ - } - - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - public void setExcludedLibs(String excludedLibs) throws CoreException - { - setAttribute(false, ATTR_EXCLUDED_LIBS, excludedLibs); - } - - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - public String getIncludedLibs() throws CoreException - { - return getAttribute(false, ATTR_INCLUDED_LIBS, JettyPluginUtils.EMPTY); - } - - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - public void setIncludedLibs(String includedLibs) throws CoreException - { - setAttribute(false, ATTR_INCLUDED_LIBS, includedLibs); - } - - /** - * Returns all generic ids of dependencies, that should be explicitly excluded. - * - * @return all generic ids of dependencies, that should be explicitly excluded - * @throws CoreException on occasion - */ - public Collection getExcludedGenericIds() throws CoreException - { - return JettyPluginUtils.fromCommaSeparatedString(getAttribute(false, ATTR_EXCLUDED_GENERIC_IDS, - JettyPluginUtils.EMPTY)); - } - - /** - * Sets all generic ids of dependencies, that should be explicitly excluded. - * - * @param excludedGenericIds all generic ids of dependencies, that should be explicitly excluded - * @throws CoreException on occasion - */ - public void setExcludedGenericIds(Collection excludedGenericIds) throws CoreException - { - setAttribute(false, ATTR_EXCLUDED_GENERIC_IDS, JettyPluginUtils.toCommaSeparatedString(excludedGenericIds)); - } - - /** - * Returns all generic ids of dependencies, that should be explicitly included. - * - * @return all generic ids of dependencies, that should be explicitly included - * @throws CoreException on occasion - */ - public Collection getIncludedGenericIds() throws CoreException - { - return JettyPluginUtils.fromCommaSeparatedString(getAttribute(false, ATTR_INCLUDED_GENERIC_IDS, - JettyPluginUtils.EMPTY)); - } - - /** - * Sets all generic ids of dependencies, that should be explicitly included. - * - * @param includedGenericIds all generic ids of dependencies, that should be explicitly included - * @throws CoreException on occasion - */ - public void setIncludedGenericIds(Collection includedGenericIds) throws CoreException - { - setAttribute(false, ATTR_INCLUDED_GENERIC_IDS, JettyPluginUtils.toCommaSeparatedString(includedGenericIds)); - } - - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - public String getGlobalLibs() throws CoreException - { - return getAttribute(false, ATTR_GLOBAL_LIBS, JettyPluginUtils.EMPTY); - } - - /** - * @deprecated Replaced by mechanism using generic ids - */ - @Deprecated - public void setGlobalLibs(String globalLibs) throws CoreException - { - setAttribute(false, ATTR_GLOBAL_LIBS, globalLibs); - } - - /** - * Returns all generic ids of dependencies, that should be part of the Jetty classpath, rather than the web - * application classpath. - * - * @return all generic ids of dependencies, that should be part of the Jetty classpath, rather than the web - * application classpath - * @throws CoreException on occasion - */ - public Collection getGlobalGenericIds() throws CoreException - { - return JettyPluginUtils.fromCommaSeparatedString(getAttribute(false, ATTR_GLOBAL_GENERIC_IDS, - JettyPluginUtils.EMPTY)); - } - - /** - * Sets all generic ids of dependencies, that should be part of the Jetty classpath, rather than the web application - * classpath. - * - * @param globalGenericIds all generic ids of dependencies, that should be part of the Jetty classpath, rather than - * the web application classpath - * @throws CoreException on occasion - */ - public void setGlobalGenericIds(Collection globalGenericIds) throws CoreException - { - setAttribute(false, ATTR_GLOBAL_GENERIC_IDS, JettyPluginUtils.toCommaSeparatedString(globalGenericIds)); - } - - /** - * Returns true, if the launch should display it's launch info. - * - * @return true, if the launch should display it's launch info - * @throws CoreException on occasion - */ - public boolean isShowLauncherInfo() throws CoreException - { - return getAttribute(true, ATTR_SHOW_LAUNCHER_INFO, true); - } - - /** - * Set to true, if the launch should display it's launch info - * - * @param value true, if the launch should display it's launch info - * @throws CoreException on occasion - */ - public void setShowLauncherInfo(boolean value) throws CoreException - { - setAttribute(true, ATTR_SHOW_LAUNCHER_INFO, value); - } - - /** - * Returns true, if the console of the launcher is available. - * - * @return true, if the console of the launcher is available - * @throws CoreException on occasion - */ - public boolean isConsoleEnabled() throws CoreException - { - return getAttribute(true, ATTR_CONSOLE_ENABLED, true); - } - - /** - * Set to true, if the console of the launcher is available - * - * @param value true, if the console of the launcher is available - * @throws CoreException on occasion - */ - public void setConsoleEnabled(boolean value) throws CoreException - { - setAttribute(true, ATTR_CONSOLE_ENABLED, value); - } - - /** - * Sets the default classpath provider for the Jetty plugin - * - * @param classpathProvider the classpath provider - * @throws CoreException on occasion - */ - public void setClasspathProvider(String classpathProvider) throws CoreException - { - setAttribute(false, IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, classpathProvider); - } - - /** - * Returns the main type name of the Jetty plugin. - * - * @return the main type name of the Jetty plugin - * @throws CoreException on occasion - */ - public String getMainTypeName() throws CoreException - { - return getAttribute(false, IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, JettyPluginUtils.EMPTY); - } - - /** - * Sets the main type name of the Jetty plugin. - * - * @param jettyVersion the version - * @throws CoreException on occasion - */ - public void setMainTypeName(JettyVersion jettyVersion) throws CoreException - { - setAttribute(false, IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, jettyVersion.getType() - .getMainClass()); - } - - /** - * Returns true if the generic id mechanis is available. - * - * @return true if the generic id mechanis is available - * @throws CoreException on occasion - */ - public boolean isGenericIdsSupported() throws CoreException - { - return getConfigVersion() >= 1; - } - - /** - * Returns the specified attribute. - * - * @param globalFallback true to fallback to the global definition - * @param name the name of the attribute - * @param defaultValue the default value - * @return the value of the attribute, the default one if not found. - * @throws CoreException on occasion - */ - protected boolean getAttribute(boolean globalFallback, String name, boolean defaultValue) throws CoreException - { - return configuration.getAttribute( - name, - (globalFallback) ? JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID) - .getBoolean(name, defaultValue) : defaultValue); - } - - /** - * Returns the specified attribute. - * - * @param globalFallback true to fallback to the global definition - * @param name the name of the attribute - * @param defaultValue the default value - * @return the value of the attribute, the default one if not found. - * @throws CoreException on occasion - */ - protected int getAttribute(boolean globalFallback, String name, int defaultValue) throws CoreException - { - return configuration.getAttribute(name, - (globalFallback) ? JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).getInt(name, defaultValue) - : defaultValue); - } - - /** - * Returns the specified attribute. - * - * @param globalFallback true to fallback to the global definition - * @param name the name of the attribute - * @param defaultValue the default value - * @return the value of the attribute, the default one if not found. - * @throws CoreException on occasion - */ - protected String getAttribute(boolean globalFallback, String name, String defaultValue) throws CoreException - { - return configuration.getAttribute(name, - (globalFallback) ? JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).get(name, defaultValue) - : defaultValue); - } - - /** - * Returns true if the specified attribute exists in the configuration. - * - * @param name the name of the attribute - * @return true if exists - * @throws CoreException on occasion - */ - protected boolean hasAttribute(String name) throws CoreException - { - try - { - configuration.getClass().getMethod("hasAttribute", String.class); //$NON-NLS-1$ - - return configuration.hasAttribute(name); - } - catch (SecurityException e) - { - JettyPlugin.error(Messages.adapter_noHasAttribute, e); - } - catch (NoSuchMethodException e) - { - JettyPlugin.warning(Messages.adapter_noDefaultScope, e); - } - - return configuration.getAttributes().containsKey(name); - } - - /** - * Sets the specified attribute. - * - * @param globalFallback true if the value should be written to the global configuration, too - * @param name the name of the attribute - * @param value the value - * @throws CoreException on occasion - */ - protected void setAttribute(boolean globalFallback, String name, boolean value) throws CoreException - { - getConfigurationWorkingCopy().setAttribute(name, value); - - if (!globalFallback) - { - return; - } - - JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).putBoolean(name, value); - - try - { - JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).flush(); - } - catch (BackingStoreException e) - { - // ignore - } - } - - /** - * Sets the specified attribute. - * - * @param globalFallback true if the value should be written to the global configuration, too - * @param name the name of the attribute - * @param value the value - * @throws CoreException on occasion - */ - protected void setAttribute(boolean globalFallback, String name, int value) throws CoreException - { - getConfigurationWorkingCopy().setAttribute(name, value); - - if (!globalFallback) - { - return; - } - - JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).putInt(name, value); - - try - { - JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).flush(); - } - catch (BackingStoreException e) - { - // ignore - } - } - - /** - * Sets the specified attribute. - * - * @param globalFallback true if the value should be written to the global configuration, too - * @param name the name of the attribute - * @param value the value - * @throws CoreException on occasion - */ - protected void setAttribute(boolean globalFallback, String name, String value) throws CoreException - { - getConfigurationWorkingCopy().setAttribute(name, value); - - if (!globalFallback) - { - return; - } - - JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).put(name, value); - - try - { - JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).flush(); - } - catch (BackingStoreException e) - { - // ignore - } - } - -} +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package net.sourceforge.eclipsejetty.launch.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.sourceforge.eclipsejetty.JettyPlugin; +import net.sourceforge.eclipsejetty.JettyPluginM2EUtils; +import net.sourceforge.eclipsejetty.JettyPluginUtils; +import net.sourceforge.eclipsejetty.Messages; +import net.sourceforge.eclipsejetty.jetty.JettyConfig; +import net.sourceforge.eclipsejetty.jetty.JettyConfigType; +import net.sourceforge.eclipsejetty.jetty.JettyVersion; +import net.sourceforge.eclipsejetty.jetty.JettyVersionType; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.osgi.service.prefs.BackingStoreException; + +/** + * Constants for the Jetty plugin and an adapter for the configuration. + * + * @author Christian Köberl + * @author Manfred Hantschel + */ +public class JettyLaunchConfigurationAdapter +{ + + public static final String LAUNCH_CONFIG_TYPE = JettyPlugin.PLUGIN_ID + ".launchConfigurationType"; //$NON-NLS-1$ + public static final String CLASSPATH_PROVIDER_JETTY = JettyPlugin.PLUGIN_ID + ".JettyLaunchClassPathProvider"; //$NON-NLS-1$ + + private static final int CONFIG_VERSION = 1; + + private static final String ATTR_CONFIG_VERSION = JettyPlugin.PLUGIN_ID + ".configVersion"; //$NON-NLS-1$ + private static final String ATTR_CONTEXT = JettyPlugin.PLUGIN_ID + ".context"; //$NON-NLS-1$ + private static final String ATTR_WEBAPPDIR = JettyPlugin.PLUGIN_ID + ".webappdir"; //$NON-NLS-1$ + private static final String ATTR_PORT = JettyPlugin.PLUGIN_ID + ".port"; //$NON-NLS-1$ + private static final String ATTR_HTTPS_PORT = JettyPlugin.PLUGIN_ID + ".httpsPort"; //$NON-NLS-1$ + private static final String ATTR_HTTPS_ENABLED = JettyPlugin.PLUGIN_ID + ".httpsEnabled"; //$NON-NLS-1$ + private static final String ATTR_JETTY_PATH = JettyPlugin.PLUGIN_ID + ".jetty.path"; //$NON-NLS-1$ + private static final String ATTR_JETTY_EMBEDDED = JettyPlugin.PLUGIN_ID + ".jetty.embedded"; //$NON-NLS-1$ + private static final String ATTR_JETTY_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.version"; //$NON-NLS-1$ + private static final String ATTR_JETTY_MAJOR_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.majorVersion"; //$NON-NLS-1$ + private static final String ATTR_JETTY_MINOR_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.minorVersion"; //$NON-NLS-1$ + private static final String ATTR_JETTY_MICRO_VERSION = JettyPlugin.PLUGIN_ID + ".jetty.microVersion"; //$NON-NLS-1$ + private static final String ATTR_JETTY_CONFIG_PATH = JettyPlugin.PLUGIN_ID + ".jetty.config.path."; //$NON-NLS-1$ + private static final String ATTR_JETTY_CONFIG_TYPE = JettyPlugin.PLUGIN_ID + ".jetty.config.type."; //$NON-NLS-1$ + private static final String ATTR_JETTY_CONFIG_ACTIVE = JettyPlugin.PLUGIN_ID + ".jetty.config.active."; //$NON-NLS-1$ + private static final String ATTR_ANNOTATIONS_ENABLED = JettyPlugin.PLUGIN_ID + ".annotations.enabled"; //$NON-NLS-1$ + private static final String ATTR_OPTMIZED_CLASSLOADER_ENABLED = JettyPlugin.PLUGIN_ID + ".optimizedClassloader.enabled"; //$NON-NLS-1$ + private static final String ATTR_OPTMIZED_CLASSLOADER_EXCLUSION_PATTERN = JettyPlugin.PLUGIN_ID + + ".optimizedClassloader.exclusionPattern"; //$NON-NLS-1$ + private static final String ATTR_JSP_ENABLED = JettyPlugin.PLUGIN_ID + ".jsp.enabled"; //$NON-NLS-1$ + private static final String ATTR_JMX_ENABLED = JettyPlugin.PLUGIN_ID + ".jmx.enabled"; //$NON-NLS-1$ + private static final String ATTR_JNDI_ENABLED = JettyPlugin.PLUGIN_ID + ".jndi.enabled"; //$NON-NLS-1$ + private static final String ATTR_AJP_ENABLED = JettyPlugin.PLUGIN_ID + ".ajp.enabled"; //$NON-NLS-1$ + private static final String ATTR_WEBSOCKET_ENABLED = JettyPlugin.PLUGIN_ID + ".websocket.enabled"; //$NON-NLS-1$ + private static final String ATTR_THREAD_POOL_LIMIT_ENABLED = JettyPlugin.PLUGIN_ID + ".threadPool.limit.enabled"; //$NON-NLS-1$ + private static final String ATTR_THREAD_POOL_LIMIT_COUNT = JettyPlugin.PLUGIN_ID + ".threadPool.limit.count"; //$NON-NLS-1$ + private static final String ATTR_ACCEPTOR_LIMIT_ENABLED = JettyPlugin.PLUGIN_ID + ".acceptor.limit.enabled"; //$NON-NLS-1$ + private static final String ATTR_ACCEPTOR_LIMIT_COUNT = JettyPlugin.PLUGIN_ID + ".acceptor.limit.count"; //$NON-NLS-1$ + private static final String ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_ENABLED = JettyPlugin.PLUGIN_ID + + ".gracefulShutdown.override.enabled"; //$NON-NLS-1$ + private static final String ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_TIMEOUT = JettyPlugin.PLUGIN_ID + + ".gracefulShutdown.override.timeout"; //$NON-NLS-1$ + private static final String ATTR_SERVER_CACHE_ENABLED = JettyPlugin.PLUGIN_ID + ".cache.server.enabled"; //$NON-NLS-1$ + private static final String ATTR_CLIENT_CACHE_ENABLED = JettyPlugin.PLUGIN_ID + ".cache.client.enabled"; //$NON-NLS-1$ + private static final String ATTR_CUSTOM_WEB_DEFAULTS_ENABLED = JettyPlugin.PLUGIN_ID + ".customWebDefaults.enabled"; //$NON-NLS-1$ + private static final String ATTR_CUSTOM_WEB_DEFAULTS_RESOURCE = JettyPlugin.PLUGIN_ID + + ".customWebDefaults.resource"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDE_SCOPE_COMPILE = JettyPlugin.PLUGIN_ID + ".scope.compile.exclude"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDE_SCOPE_PROVIDED = JettyPlugin.PLUGIN_ID + ".scope.provided.exclude"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDE_SCOPE_RUNTIME = JettyPlugin.PLUGIN_ID + ".scope.runtime.exclude"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDE_SCOPE_TEST = JettyPlugin.PLUGIN_ID + ".scope.test.exclude"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDE_SCOPE_SYSTEM = JettyPlugin.PLUGIN_ID + ".scope.system.exclude"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDE_SCOPE_IMPORT = JettyPlugin.PLUGIN_ID + ".scope.import.exclude"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDE_SCOPE_NONE = JettyPlugin.PLUGIN_ID + ".scope.none.exclude"; //$NON-NLS-1$ + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + private static final String ATTR_EXCLUDED_LIBS = JettyPlugin.PLUGIN_ID + ".launcher.excludeLibs"; //$NON-NLS-1$ + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + private static final String ATTR_INCLUDED_LIBS = JettyPlugin.PLUGIN_ID + ".launcher.includeLibs"; //$NON-NLS-1$ + private static final String ATTR_EXCLUDED_GENERIC_IDS = JettyPlugin.PLUGIN_ID + ".launcher.excludeGenericIds"; //$NON-NLS-1$ + private static final String ATTR_INCLUDED_GENERIC_IDS = JettyPlugin.PLUGIN_ID + ".launcher.includeGenericIds"; //$NON-NLS-1$ + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + private static final String ATTR_GLOBAL_LIBS = JettyPlugin.PLUGIN_ID + ".launcher.globalLibs"; //$NON-NLS-1$ + private static final String ATTR_GLOBAL_GENERIC_IDS = JettyPlugin.PLUGIN_ID + ".launcher.globalGenericIds"; //$NON-NLS-1$ + private static final String ATTR_SHOW_LAUNCHER_INFO = JettyPlugin.PLUGIN_ID + ".launcher.info"; //$NON-NLS-1$ + private static final String ATTR_CONSOLE_ENABLED = JettyPlugin.PLUGIN_ID + ".console.enabled"; //$NON-NLS-1$ + + /** + * Creates an readable configuration adapter. + * + * @param configuration the configuration, must not be null + * @return the adapter + */ + public static JettyLaunchConfigurationAdapter getInstance(ILaunchConfiguration configuration) + { + return new JettyLaunchConfigurationAdapter(configuration); + } + + /** + * Creates an read and writable configuration adapter. + * + * @param configuration the configuration, must not be null + * @return the adapter + */ + public static JettyLaunchConfigurationAdapter getInstance(ILaunchConfigurationWorkingCopy configuration) + { + return new JettyLaunchConfigurationAdapter(configuration); + } + + private final ILaunchConfiguration configuration; + + /** + * Creates the adapter. + * + * @param configuration the configuration + */ + protected JettyLaunchConfigurationAdapter(ILaunchConfiguration configuration) + { + super(); + + this.configuration = configuration; + } + + /** + * Returns the readable configuration. + * + * @return the configuration + */ + public ILaunchConfiguration getConfiguration() + { + return configuration; + } + + /** + * Returns the read and writable configuration. + * + * @return the configuration + * @throws CoreException if configuration is only readable + */ + public ILaunchConfigurationWorkingCopy getConfigurationWorkingCopy() throws CoreException + { + try + { + return (ILaunchConfigurationWorkingCopy) configuration; + } + catch (ClassCastException e) + { + throw new CoreException(new Status(IStatus.ERROR, JettyPlugin.PLUGIN_ID, + Messages.adapter_configurationOnlyReadable)); + } + } + + /** + * Initializes a new launch configuration. + * + * @param project the project, must not be null + * @param webAppPath the web application path, must not be null + * @throws CoreException on occasion + */ + public void initialize(IProject project, File webAppPath) throws CoreException + { + ILaunchConfigurationWorkingCopy configuration = getConfigurationWorkingCopy(); + String projectName = (project != null) ? project.getName() : JettyPluginUtils.EMPTY; + + setProjectName(projectName); + setClasspathProvider(CLASSPATH_PROVIDER_JETTY); + updateConfigVersion(); + + String launchConfigName = projectName; + + if ((launchConfigName == null) || (launchConfigName.length() == 0)) + { + launchConfigName = Messages.adapter_defaultConfigName; + } + + launchConfigName = JettyLaunchUtils.generateLaunchConfigurationName(launchConfigName); + + configuration.rename(launchConfigName); + + setContext(getContext()); + + if (webAppPath == null) + { + try + { + List path = JettyLaunchUtils.findWebXMLs(project, 1); + + if (path.size() > 0) + { + IPath webAppResource = path.get(0).getFullPath().removeLastSegments(2); + + webAppPath = JettyPluginUtils.resolveFolder(project, webAppResource.toString()); + } + } + catch (CoreException e) + { + // ignore + } + } + + if (webAppPath != null) + { + setWebAppString(JettyPluginUtils.toRelativePath(project, webAppPath.toString())); + } + else + { + setWebAppString("src/main/webapp"); //$NON-NLS-1$ + } + + setPort(getPort()); + setHttpsPort(getHttpsPort()); + setHttpsEnabled(isHttpsEnabled()); + + boolean embedded = isEmbedded(); + + setEmbedded(embedded); + + String jettyPath = getPathString(); + + setPathString(jettyPath); + + try + { + JettyVersion jettyVersion = JettyVersion.detect(JettyPluginUtils.resolveVariables(jettyPath), embedded); + + setMainTypeName(jettyVersion); + setVersion(jettyVersion); + setMinorVersion(jettyVersion); + setMicroVersion(jettyVersion); + } + catch (IllegalArgumentException e) + { + // failed to detect + } + + setOptimizedClassLoaderEnabled(isOptimizedClassLoaderEnabled()); + setOptimizedClassLoaderExclusionPattern(getOptimizedClassLoaderExclusionPattern()); + + setJspSupport(isJspSupport()); + setJmxSupport(isJmxSupport()); + setJndiSupport(isJndiSupport()); + setAjpSupport(isAjpSupport()); + + setThreadPoolLimitEnabled(isThreadPoolLimitEnabled()); + setThreadPoolLimitCount(getThreadPoolLimitCount()); + setAcceptorLimitEnabled(isAcceptorLimitEnabled()); + setAcceptorLimitCount(getAcceptorLimitCount()); + setGracefulShutdownOverrideEnabled(isGracefulShutdownOverrideEnabled()); + setGracefulShutdownOverrideTimeout(getGracefulShutdownOverrideTimeout()); + + setServerCacheEnabled(isServerCacheEnabled()); + setClientCacheEnabled(isClientCacheEnabled()); + + setShowLauncherInfo(isShowLauncherInfo()); + setConsoleEnabled(isConsoleEnabled()); + + setCustomWebDefaultsEnabled(isCustomWebDefaultsEnabled()); + setCustomWebDefaultsResource(getCustomWebDefaultsResource()); + + setConfigs(getConfigs()); + + setScopeCompileExcluded(isScopeCompileExcluded()); + setScopeProvidedExcluded(isScopeProvidedExcluded()); + setScopeRuntimeExcluded(isScopeRuntimeExcluded()); + setScopeSystemExcluded(isScopeSystemExcluded()); + setScopeTestExcluded(isScopeTestExcluded()); + setScopeImportExcluded(isScopeImportExcluded()); + setScopeNoneExcluded(isScopeNoneExcluded()); + + setExcludedGenericIds(getExcludedGenericIds()); + setIncludedGenericIds(getIncludedGenericIds()); + setGlobalGenericIds(getGlobalGenericIds()); + + deprecatedInitialize(); + } + + private void deprecatedInitialize() throws CoreException + { + setExcludedLibs(getExcludedLibs()); + setIncludedLibs(getIncludedLibs()); + setGlobalLibs(getGlobalLibs()); + } + + /** + * Returns the configuration version to distinguish between versions of the plugin. + * + * @return the configuration version + * @throws CoreException on occasion + */ + public int getConfigVersion() throws CoreException + { + return getAttribute(false, ATTR_CONFIG_VERSION, 0); + } + + /** + * Updates the configuration version to the one supported by the plugin. + * + * @throws CoreException on occasion + */ + public void updateConfigVersion() throws CoreException + { + setAttribute(false, ATTR_CONFIG_VERSION, CONFIG_VERSION); + } + + /** + * Returns the name of the selected eclipse project, that should be launched. + * + * @return the project + * @throws CoreException on occasion + */ + public String getProjectName() throws CoreException + { + return getAttribute(false, IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, JettyPluginUtils.EMPTY); + } + + /** + * Sets the name of the selected eclipse project, that should be launched. + * + * @param project the project + * @throws CoreException on occasion + */ + public void setProjectName(String project) throws CoreException + { + setAttribute(false, IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project); + } + + /** + * Returns the project as defined by the project name. + * + * @return the project, null if unable to locate + */ + public IProject getProject() + { + try + { + return JettyPluginUtils.getProject(getProjectName()); + } + catch (CoreException e) + { + return null; + } + } + + /** + * Returns the context path (path part of the URL) of the application. + * + * @return the context path + * @throws CoreException on occasion + */ + public String getContext() throws CoreException + { + return getAttribute(false, ATTR_CONTEXT, "/"); //$NON-NLS-1$ + } + + /** + * Sets the context path (path part of the URL) of the application. + * + * @param context the context + * @throws CoreException on occasion + */ + public void setContext(String context) throws CoreException + { + setAttribute(false, ATTR_CONTEXT, context); + } + + /** + * Returns the location of the web application directory in the workspace. + * + * @return the location of the web application directory + * @throws CoreException on occasion + */ + public String getWebAppString() throws CoreException + { + return getAttribute(false, ATTR_WEBAPPDIR, "src/main/webapp"); //$NON-NLS-1$ + } + + /** + * Sets the location of the web application directory in the workspace. + * + * @param webappdir the location of the web application directory + * @throws CoreException on occasion + */ + public void setWebAppString(String webappdir) throws CoreException + { + setAttribute(false, ATTR_WEBAPPDIR, webappdir); + } + + /** + * Tries to determine the web application path from the web application directory. + * + * @return the path, null if unable to determine + */ + public File getWebAppPath() + { + try + { + return JettyPluginUtils.resolveFolder(getProject(), getWebAppString()); + } + catch (CoreException e) + { + return null; + } + } + + /** + * Returns the (HTTP) port. + * + * @return the port + * @throws CoreException on occasion + */ + public int getPort() throws CoreException + { + try + { + return Integer.parseInt(getAttribute(true, ATTR_PORT, "8080")); // string for backward compatibility //$NON-NLS-1$ + } + catch (NumberFormatException e) + { + return 8080; + } + } + + /** + * Sets the (HTTP) port. + * + * @param port the port + * @throws CoreException on occasion + */ + public void setPort(int port) throws CoreException + { + setAttribute(true, ATTR_PORT, String.valueOf(port)); // string for backward compatibility + } + + /** + * Returns the (HTTPs) port. + * + * @return the port + * @throws CoreException on occasion + */ + public int getHttpsPort() throws CoreException + { + try + { + return Integer.parseInt(getAttribute(true, ATTR_HTTPS_PORT, "8443")); // string for backward compatibility //$NON-NLS-1$ + } + catch (NumberFormatException e) + { + return 8443; + } + } + + /** + * Sets the (HTTPs) port. + * + * @param httpsPort the port + * @throws CoreException on occasion + */ + public void setHttpsPort(int httpsPort) throws CoreException + { + setAttribute(true, ATTR_HTTPS_PORT, String.valueOf(httpsPort)); // string for backward compatibility + } + + /** + * Returns true if HTTPs is enabled. + * + * @return true if enabled + * @throws CoreException on occasion + */ + public boolean isHttpsEnabled() throws CoreException + { + return getAttribute(true, ATTR_HTTPS_ENABLED, false); + } + + /** + * Set to true, if the HTTPs is enabled. + * + * @param httpsEnabled true if enabled + * @throws CoreException on occasion + */ + public void setHttpsEnabled(boolean httpsEnabled) throws CoreException + { + setAttribute(true, ATTR_HTTPS_ENABLED, httpsEnabled); + } + + /** + * Returns the path to an optionally available Jetty. + * + * @return the path + * @throws CoreException on occasion + */ + public String getPathString() throws CoreException + { + return getAttribute(true, ATTR_JETTY_PATH, JettyPluginUtils.EMPTY); + } + + /** + * Sets the path to an optionally available Jetty. + * + * @param path the path + * @throws CoreException on occasion + */ + public void setPathString(String path) throws CoreException + { + setAttribute(true, ATTR_JETTY_PATH, path); + } + + /** + * Tries to determine the path to an optionally available Jetty. + * + * @return the path, null if unable to determine + */ + public File getPath() + { + try + { + return JettyPluginUtils.resolveFolder(getProject(), getPathString()); + } + catch (CoreException e) + { + return null; + } + } + + /** + * Returns true, if the embedded Jetty should be used. + * + * @return true, if the embedded Jetty should be used. + * @throws CoreException on occasion + */ + public boolean isEmbedded() throws CoreException + { + return getAttribute(true, ATTR_JETTY_EMBEDDED, true); + } + + /** + * Set to true, if the embedded Jetty should be used. + * + * @param embedded true, if the embedded Jetty should be used + * @throws CoreException on occasion + */ + public void setEmbedded(boolean embedded) throws CoreException + { + setAttribute(true, ATTR_JETTY_EMBEDDED, embedded); + } + + /** + * Returns the version of the Jetty. + * + * @return the version of the Jetty + * @throws CoreException on occasion + */ + public JettyVersionType getVersion() throws CoreException + { + return JettyVersionType.valueOf(getAttribute(true, ATTR_JETTY_VERSION, JettyVersionType.JETTY_EMBEDDED.name())); + } + + /** + * Sets the version of the Jetty. + * + * @param jettyVersion the version + * @throws CoreException on occasion + */ + public void setVersion(JettyVersion jettyVersion) throws CoreException + { + setAttribute(true, ATTR_JETTY_VERSION, jettyVersion.getType().name()); + } + + /** + * Returns the major version of the Jetty. + * + * @return the major version of the Jetty + * @throws CoreException on occasion + */ + public int getMajorVersion() throws CoreException + { + return getAttribute(true, ATTR_JETTY_MAJOR_VERSION, -1); + } + + /** + * Sets the major version of the Jetty. + * + * @param jettyVersion the version + * @throws CoreException on occasion + */ + public void setMajorVersion(JettyVersion jettyVersion) throws CoreException + { + setAttribute(true, ATTR_JETTY_MAJOR_VERSION, (jettyVersion.getMajorVersion() != null) ? jettyVersion + .getMajorVersion().intValue() : -1); + } + + /** + * Returns the minor version of the Jetty. + * + * @return the minor version of the Jetty + * @throws CoreException on occasion + */ + public int getMinorVersion() throws CoreException + { + return getAttribute(true, ATTR_JETTY_MINOR_VERSION, -1); + } + + /** + * Sets the minor version of the Jetty. + * + * @param jettyVersion the version + * @throws CoreException on occasion + */ + public void setMinorVersion(JettyVersion jettyVersion) throws CoreException + { + setAttribute(true, ATTR_JETTY_MINOR_VERSION, (jettyVersion.getMinorVersion() != null) ? jettyVersion + .getMinorVersion().intValue() : -1); + } + + /** + * Returns the micro version of the Jetty. + * + * @return the micro version of the Jetty + * @throws CoreException on occasion + */ + public int getMicroVersion() throws CoreException + { + return getAttribute(true, ATTR_JETTY_MICRO_VERSION, -1); + } + + /** + * Sets the micro version of the Jetty. + * + * @param jettyVersion the version + * @throws CoreException on occasion + */ + public void setMicroVersion(JettyVersion jettyVersion) throws CoreException + { + setAttribute(true, ATTR_JETTY_MICRO_VERSION, (jettyVersion.getMicroVersion() != null) ? jettyVersion + .getMicroVersion().intValue() : -1); + } + + /** + * Returns the configuration context holders. + * + * @return a list of {@link JettyConfig}s + * @throws CoreException on occasion + */ + public List getConfigs() throws CoreException + { + List results = new ArrayList(); + int index = 0; + + while (true) + { + String path = getAttribute(false, ATTR_JETTY_CONFIG_PATH + index, (String) null); + + if (path == null) + { + break; + } + + JettyConfigType type = + JettyConfigType + .valueOf(getAttribute(false, ATTR_JETTY_CONFIG_TYPE + index, JettyConfigType.PATH.name())); + boolean active = getAttribute(false, ATTR_JETTY_CONFIG_ACTIVE + index, true); + + results.add(new JettyConfig(path, type, active)); + index += 1; + } + + if (results.size() == 0) + { + results.add(new JettyConfig(JettyPluginUtils.EMPTY, JettyConfigType.DEFAULT, true)); + } + + return results; + } + + /** + * Sets the configuration context holders. + * + * @param entries the entries + * @throws CoreException on occasion + */ + public void setConfigs(List entries) throws CoreException + { + int index = 0; + + for (JettyConfig entry : entries) + { + setAttribute(false, ATTR_JETTY_CONFIG_PATH + index, entry.getPath()); + setAttribute(false, ATTR_JETTY_CONFIG_TYPE + index, entry.getType().name()); + setAttribute(false, ATTR_JETTY_CONFIG_ACTIVE + index, entry.isActive()); + + index += 1; + } + + ILaunchConfigurationWorkingCopy configuration = getConfigurationWorkingCopy(); + + while (configuration.getAttribute(ATTR_JETTY_CONFIG_PATH + index, (String) null) != null) + { + configuration.removeAttribute(ATTR_JETTY_CONFIG_PATH + index); + configuration.removeAttribute(ATTR_JETTY_CONFIG_TYPE + index); + configuration.removeAttribute(ATTR_JETTY_CONFIG_ACTIVE + index); + + index += 1; + } + } + + /** + * Returns true, if annotations should be supported. + * + * @return true, if annotations should be supported + * @throws CoreException on occasion + */ + public boolean isAnnotationsSupport() throws CoreException + { + return !"false".equals(getAttribute(true, ATTR_ANNOTATIONS_ENABLED, "true")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Set to true, if JSPs should be supported. + * + * @param annotationsSupport true, if JSPs should be supported + * @throws CoreException on occasion + */ + public void setAnnotationsSupport(boolean annotationsSupport) throws CoreException + { + setAttribute(true, ATTR_ANNOTATIONS_ENABLED, String.valueOf(annotationsSupport)); // string for backward compatibility + } + + /** + * Returns true, if JSPs should be supported. + * + * @return true, if JSPs should be supported + * @throws CoreException on occasion + */ + public boolean isJspSupport() throws CoreException + { + return !"false".equals(getAttribute(true, ATTR_JSP_ENABLED, "true")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Set to true, if optimized class loader should be supported. + * + * @param jsoptimizedClassLoaderEnabledpSupport true, if optimized class loading should be supported + * @throws CoreException on occasion + */ + public void setOptimizedClassLoaderEnabled(boolean optimizedClassLoaderEnabled) throws CoreException + { + setAttribute(true, ATTR_OPTMIZED_CLASSLOADER_ENABLED, String.valueOf(optimizedClassLoaderEnabled)); // string for backward compatibility + } + + /** + * Returns true, if optimized class loading should be supported. + * + * @return true, if optimized class loading should be supported + * @throws CoreException on occasion + */ + public boolean isOptimizedClassLoaderEnabled() throws CoreException + { + return !"false".equals(getAttribute(true, ATTR_OPTMIZED_CLASSLOADER_ENABLED, "true")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ + } + + public void setOptimizedClassLoaderExclusionPattern(String value) throws CoreException { + setAttribute(false, ATTR_OPTMIZED_CLASSLOADER_EXCLUSION_PATTERN, value); + } + + public String getOptimizedClassLoaderExclusionPattern() throws CoreException { + return getAttribute(false, ATTR_OPTMIZED_CLASSLOADER_EXCLUSION_PATTERN, ".*assembly.*"); + } + + + /** + * Set to true, if JSPs should be supported. + * + * @param jspSupport true, if JSPs should be supported + * @throws CoreException on occasion + */ + public void setJspSupport(boolean jspSupport) throws CoreException + { + setAttribute(true, ATTR_JSP_ENABLED, String.valueOf(jspSupport)); // string for backward compatibility + } + + + /** + * Returns true, if JMX should be supported. + * + * @return true, if JMX should be supported + * @throws CoreException on occasion + */ + public boolean isJmxSupport() throws CoreException + { + return "true".equals(getAttribute(true, ATTR_JMX_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Set to true, if JMX should be supported. + * + * @param jmxSupport true, if JMX should be supported + * @throws CoreException on occasion + */ + public void setJmxSupport(boolean jmxSupport) throws CoreException + { + setAttribute(true, ATTR_JMX_ENABLED, String.valueOf(jmxSupport)); // string for backward compatibility + } + + /** + * Returns true, if JNDI should be supported. + * + * @return true, if JNDI should be supported + * @throws CoreException on occasion + */ + public boolean isJndiSupport() throws CoreException + { + return "true".equals(getAttribute(true, ATTR_JNDI_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Set to true, if JNDI should be supported. + * + * @param jndiSupport true, if JNDI should be supported + * @throws CoreException on occasion + */ + public void setJndiSupport(boolean jndiSupport) throws CoreException + { + setAttribute(true, ATTR_JNDI_ENABLED, String.valueOf(jndiSupport)); // string for backward compatibility + } + + /** + * Returns true, if an AJP connector should be supported. + * + * @return true, if an AJP connector should be supported + * @throws CoreException on occasion + */ + public boolean isAjpSupport() throws CoreException + { + return "true".equals(getAttribute(true, ATTR_AJP_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Set to true, if an AJP connector should be supported. + * + * @param ajpSupport true, if an AJP connector should be supported. + * @throws CoreException on occasion + */ + public void setAjpSupport(boolean ajpSupport) throws CoreException + { + setAttribute(true, ATTR_AJP_ENABLED, String.valueOf(ajpSupport)); // string for backward compatibility + } + + /** + * Returns true, if Websockets should be supported. + * + * @return true, if Websockets should be supported + * @throws CoreException on occasion + */ + public boolean isWebsocketSupport() throws CoreException + { + return "true".equals(getAttribute(true, ATTR_WEBSOCKET_ENABLED, "false")); // string for backward compatibility //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Set to true, if Websockets should be supported. + * + * @param websocketSupport true, if Websockets should be supported. + * @throws CoreException on occasion + */ + public void setWebsocketSupport(boolean websocketSupport) throws CoreException + { + setAttribute(true, ATTR_WEBSOCKET_ENABLED, String.valueOf(websocketSupport)); // string for backward compatibility + } + + /** + * Returns true, if the size of Jetty's thread pool is limited. + * + * @return true, if the size of Jetty's thread pool is limited + * @throws CoreException on occasion + */ + public boolean isThreadPoolLimitEnabled() throws CoreException + { + return getAttribute(true, ATTR_THREAD_POOL_LIMIT_ENABLED, false); + } + + /** + * Set to true, if the size of Jetty's thread pool is limited. + * + * @param value true, if the size of Jetty's thread pool is limited + * @throws CoreException on occasion + */ + public void setThreadPoolLimitEnabled(boolean value) throws CoreException + { + setAttribute(true, ATTR_THREAD_POOL_LIMIT_ENABLED, value); + } + + /** + * Returns the maximum size of Jetty's thead pool. + * + * @return the maximum size of Jetty's thead pool + * @throws CoreException on occasion + */ + public int getThreadPoolLimitCount() throws CoreException + { + return getAttribute(true, ATTR_THREAD_POOL_LIMIT_COUNT, 16); + } + + /** + * Sets the maximum size of Jetty's thead pool + * + * @param value the maximum size of Jetty's thead pool + * @throws CoreException on occasion + */ + public void setThreadPoolLimitCount(int value) throws CoreException + { + setAttribute(true, ATTR_THREAD_POOL_LIMIT_COUNT, value); + } + + /** + * Returns true, if the number of Jetty's acceptors is limited. + * + * @return true, if the number of Jetty's acceptors is limited + * @throws CoreException on occasion + */ + public boolean isAcceptorLimitEnabled() throws CoreException + { + return getAttribute(true, ATTR_ACCEPTOR_LIMIT_ENABLED, false); + } + + /** + * Set to true, if the number of Jetty's acceptors is limited + * + * @param value true, if the number of Jetty's acceptors is limited + * @throws CoreException on occasion + */ + public void setAcceptorLimitEnabled(boolean value) throws CoreException + { + setAttribute(true, ATTR_ACCEPTOR_LIMIT_ENABLED, value); + } + + /** + * Returns the maximum number of acceptors Jetty should use. + * + * @return the maximum number of acceptors Jetty should use + * @throws CoreException on occasion + */ + public int getAcceptorLimitCount() throws CoreException + { + return getAttribute(true, ATTR_ACCEPTOR_LIMIT_COUNT, 8); + } + + /** + * Sets the the maximum number of acceptors Jetty should use. + * + * @param value the maximum number of acceptors Jetty should use + * @throws CoreException on occasion + */ + public void setAcceptorLimitCount(int value) throws CoreException + { + setAttribute(true, ATTR_ACCEPTOR_LIMIT_COUNT, value); + } + + /** + * Return true, if the graceful shutdown override is enabled. + * + * @return true, if the graceful shutdown override is enabled + * @throws CoreException on occasion + */ + public boolean isGracefulShutdownOverrideEnabled() throws CoreException + { + return getAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_ENABLED, false); + } + + /** + * Set to true, if the graceful shutdown override is enabled. + * + * @param value true, if the graceful shutdown override is enabled + * @throws CoreException on occasion + */ + public void setGracefulShutdownOverrideEnabled(boolean value) throws CoreException + { + setAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_ENABLED, value); + } + + /** + * Returns the timeout for the graceful shutdown (in milliseconds). + * + * @return the timeout for the graceful shutdown (in milliseconds) + * @throws CoreException on occasion + */ + public int getGracefulShutdownOverrideTimeout() throws CoreException + { + return getAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_TIMEOUT, 1000); + } + + /** + * Sets the timeout for the graceful shutdown (in milliseconds) + * + * @param value the timeout for the graceful shutdown (in milliseconds) + * @throws CoreException on occasion + */ + public void setGracefulShutdownOverrideTimeout(int value) throws CoreException + { + setAttribute(true, ATTR_GRACEFUL_SHUTDOWN_OVERRIDE_TIMEOUT, value); + } + + /** + * Returns true, if Jetty's server cache is enabled. + * + * @return true, if Jetty's server cache is enabled + * @throws CoreException on occasion + */ + public boolean isServerCacheEnabled() throws CoreException + { + return getAttribute(true, ATTR_SERVER_CACHE_ENABLED, true); + } + + /** + * Set to true, if Jetty's server cache is enabled. + * + * @param enabled true, if Jetty's server cache is enabled + * @throws CoreException on occasion + */ + public void setServerCacheEnabled(boolean enabled) throws CoreException + { + setAttribute(true, ATTR_SERVER_CACHE_ENABLED, enabled); + } + + /** + * Returns true, if the cache pragma no cache should not be sent. + * + * @return true, if the cache pragma no cache should not be sent + * @throws CoreException on occasion + */ + public boolean isClientCacheEnabled() throws CoreException + { + return getAttribute(true, ATTR_CLIENT_CACHE_ENABLED, true); + } + + /** + * Set to true, if the cache pragma no cache should not be sent. + * + * @param enabled true, if the cache pragma no cache should not be sent + * @throws CoreException on occasion + */ + public void setClientCacheEnabled(boolean enabled) throws CoreException + { + setAttribute(true, ATTR_CLIENT_CACHE_ENABLED, enabled); + } + + /** + * Returns true, if a custom default web.xml should be used. + * + * @return true, if a custom default web.xml should be used + * @throws CoreException on occasion + */ + public boolean isCustomWebDefaultsEnabled() throws CoreException + { + return getAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_ENABLED, false); + } + + /** + * Set to true, if a custom default web.xml should be used + * + * @param value true, if a custom default web.xml should be used + * @throws CoreException on occasion + */ + public void setCustomWebDefaultsEnabled(boolean value) throws CoreException + { + setAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_ENABLED, value); + } + + /** + * Returns the custom default web.xml. + * + * @return the custom default web.xml + * @throws CoreException on occasion + */ + public String getCustomWebDefaultsResource() throws CoreException + { + return getAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_RESOURCE, JettyPluginUtils.EMPTY); + } + + /** + * Sets the custom default web.xml + * + * @param value the custom default web.xml + * @throws CoreException on occasion + */ + public void setCustomWebDefaultsResource(String value) throws CoreException + { + setAttribute(false, ATTR_CUSTOM_WEB_DEFAULTS_RESOURCE, value); + } + + /** + * Tries to determine the custom web.xml file from the resource. + * + * @return the custom web.xml file, null if not found or not enabled + */ + public File getCustomWebDefaultFile() + { + try + { + if (!isCustomWebDefaultsEnabled()) + { + return null; + } + + return JettyPluginUtils.resolveFile(getProject(), getCustomWebDefaultsResource()); + } + catch (CoreException e) + { + // ignore + } + + return null; + } + + /** + * Returns true, if Maven dependencies with the compile scope should be excluded. + * + * @return true, if Maven dependencies with the compile scope should be excluded + * @throws CoreException on occasion + */ + public boolean isScopeCompileExcluded() throws CoreException + { + return getAttribute(false, ATTR_EXCLUDE_SCOPE_COMPILE, false); + } + + /** + * Set to true, if Maven dependencies with the compile scope should be excluded. + * + * @param value true, if Maven dependencies with the compile scope should be excluded + * @throws CoreException on occasion + */ + public void setScopeCompileExcluded(boolean value) throws CoreException + { + setAttribute(false, ATTR_EXCLUDE_SCOPE_COMPILE, value); + } + + /** + * Returns true, if Maven dependencies with the provided scope should be excluded. + * + * @return true, if Maven dependencies with the provided scope should be excluded + * @throws CoreException on occasion + */ + public boolean isScopeProvidedExcluded() throws CoreException + { + return getAttribute(false, ATTR_EXCLUDE_SCOPE_PROVIDED, true); + } + + /** + * Set to true, if Maven dependencies with the provided scope should be excluded. + * + * @param value true, if Maven dependencies with the provided scope should be excluded + * @throws CoreException on occasion + */ + public void setScopeProvidedExcluded(boolean value) throws CoreException + { + setAttribute(false, ATTR_EXCLUDE_SCOPE_PROVIDED, value); + } + + /** + * Returns true, if Maven dependencies with the runtime scope should be excluded. + * + * @return true, if Maven dependencies with the runtime scope should be excluded + * @throws CoreException on occasion + */ + public boolean isScopeRuntimeExcluded() throws CoreException + { + return getAttribute(false, ATTR_EXCLUDE_SCOPE_RUNTIME, false); + } + + /** + * Set to true, if Maven dependencies with the runtime scope should be excluded. + * + * @param value true, if Maven dependencies with the runtime scope should be excluded + * @throws CoreException on occasion + */ + public void setScopeRuntimeExcluded(boolean value) throws CoreException + { + setAttribute(false, ATTR_EXCLUDE_SCOPE_RUNTIME, value); + } + + /** + * Returns true, if Maven dependencies with the test scope should be excluded. + * + * @return true, if Maven dependencies with the test scope should be excluded + * @throws CoreException on occasion + */ + public boolean isScopeTestExcluded() throws CoreException + { + return getAttribute(false, ATTR_EXCLUDE_SCOPE_TEST, true); + } + + /** + * Set to true, if Maven dependencies with the test scope should be excluded. + * + * @param value true, if Maven dependencies with the test scope should be excluded + * @throws CoreException on occasion + */ + public void setScopeTestExcluded(boolean value) throws CoreException + { + setAttribute(false, ATTR_EXCLUDE_SCOPE_TEST, value); + } + + /** + * Returns true, if Maven dependencies with the system scope should be excluded. + * + * @return true, if Maven dependencies with the system scope should be excluded + * @throws CoreException on occasion + */ + public boolean isScopeSystemExcluded() throws CoreException + { + return getAttribute(false, ATTR_EXCLUDE_SCOPE_SYSTEM, true); + } + + /** + * Set to true, if Maven dependencies with the system scope should be excluded. + * + * @param value true, if Maven dependencies with the system scope should be excluded + * @throws CoreException on occasion + */ + public void setScopeSystemExcluded(boolean value) throws CoreException + { + setAttribute(false, ATTR_EXCLUDE_SCOPE_SYSTEM, value); + } + + /** + * Returns true, if Maven dependencies with the import scope should be excluded. + * + * @return true, if Maven dependencies with the import scope should be excluded + * @throws CoreException on occasion + */ + public boolean isScopeImportExcluded() throws CoreException + { + return getAttribute(false, ATTR_EXCLUDE_SCOPE_IMPORT, true); + } + + /** + * Set to true, if Maven dependencies with the import scope should be excluded. + * + * @param value true, if Maven dependencies with the import scope should be excluded + * @throws CoreException on occasion + */ + public void setScopeImportExcluded(boolean value) throws CoreException + { + setAttribute(false, ATTR_EXCLUDE_SCOPE_IMPORT, value); + } + + /** + * Returns true, if dependencies unknown to Maven should be excluded. + * + * @return true, if dependencies unknown to Maven should be excluded + * @throws CoreException on occasion + */ + public boolean isScopeNoneExcluded() throws CoreException + { + if (!hasAttribute(ATTR_EXCLUDE_SCOPE_NONE)) + { + return JettyPluginM2EUtils.getMavenProjectFacade(this) != null; + } + + return getAttribute(false, ATTR_EXCLUDE_SCOPE_NONE, false); + } + + /** + * Set to true, if dependencies unknown to Maven should be excluded. + * + * @param value true, if dependencies unknown to Maven should be excluded + * @throws CoreException on occasion + */ + public void setScopeNoneExcluded(boolean value) throws CoreException + { + setAttribute(false, ATTR_EXCLUDE_SCOPE_NONE, value); + } + + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + public String getExcludedLibs() throws CoreException + { + return getAttribute(false, ATTR_EXCLUDED_LIBS, ".*servlet-api.*"); //$NON-NLS-1$ + } + + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + public void setExcludedLibs(String excludedLibs) throws CoreException + { + setAttribute(false, ATTR_EXCLUDED_LIBS, excludedLibs); + } + + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + public String getIncludedLibs() throws CoreException + { + return getAttribute(false, ATTR_INCLUDED_LIBS, JettyPluginUtils.EMPTY); + } + + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + public void setIncludedLibs(String includedLibs) throws CoreException + { + setAttribute(false, ATTR_INCLUDED_LIBS, includedLibs); + } + + /** + * Returns all generic ids of dependencies, that should be explicitly excluded. + * + * @return all generic ids of dependencies, that should be explicitly excluded + * @throws CoreException on occasion + */ + public Collection getExcludedGenericIds() throws CoreException + { + return JettyPluginUtils.fromCommaSeparatedString(getAttribute(false, ATTR_EXCLUDED_GENERIC_IDS, + JettyPluginUtils.EMPTY)); + } + + /** + * Sets all generic ids of dependencies, that should be explicitly excluded. + * + * @param excludedGenericIds all generic ids of dependencies, that should be explicitly excluded + * @throws CoreException on occasion + */ + public void setExcludedGenericIds(Collection excludedGenericIds) throws CoreException + { + setAttribute(false, ATTR_EXCLUDED_GENERIC_IDS, JettyPluginUtils.toCommaSeparatedString(excludedGenericIds)); + } + + /** + * Returns all generic ids of dependencies, that should be explicitly included. + * + * @return all generic ids of dependencies, that should be explicitly included + * @throws CoreException on occasion + */ + public Collection getIncludedGenericIds() throws CoreException + { + return JettyPluginUtils.fromCommaSeparatedString(getAttribute(false, ATTR_INCLUDED_GENERIC_IDS, + JettyPluginUtils.EMPTY)); + } + + /** + * Sets all generic ids of dependencies, that should be explicitly included. + * + * @param includedGenericIds all generic ids of dependencies, that should be explicitly included + * @throws CoreException on occasion + */ + public void setIncludedGenericIds(Collection includedGenericIds) throws CoreException + { + setAttribute(false, ATTR_INCLUDED_GENERIC_IDS, JettyPluginUtils.toCommaSeparatedString(includedGenericIds)); + } + + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + public String getGlobalLibs() throws CoreException + { + return getAttribute(false, ATTR_GLOBAL_LIBS, JettyPluginUtils.EMPTY); + } + + /** + * @deprecated Replaced by mechanism using generic ids + */ + @Deprecated + public void setGlobalLibs(String globalLibs) throws CoreException + { + setAttribute(false, ATTR_GLOBAL_LIBS, globalLibs); + } + + /** + * Returns all generic ids of dependencies, that should be part of the Jetty classpath, rather than the web + * application classpath. + * + * @return all generic ids of dependencies, that should be part of the Jetty classpath, rather than the web + * application classpath + * @throws CoreException on occasion + */ + public Collection getGlobalGenericIds() throws CoreException + { + return JettyPluginUtils.fromCommaSeparatedString(getAttribute(false, ATTR_GLOBAL_GENERIC_IDS, + JettyPluginUtils.EMPTY)); + } + + /** + * Sets all generic ids of dependencies, that should be part of the Jetty classpath, rather than the web application + * classpath. + * + * @param globalGenericIds all generic ids of dependencies, that should be part of the Jetty classpath, rather than + * the web application classpath + * @throws CoreException on occasion + */ + public void setGlobalGenericIds(Collection globalGenericIds) throws CoreException + { + setAttribute(false, ATTR_GLOBAL_GENERIC_IDS, JettyPluginUtils.toCommaSeparatedString(globalGenericIds)); + } + + /** + * Returns true, if the launch should display it's launch info. + * + * @return true, if the launch should display it's launch info + * @throws CoreException on occasion + */ + public boolean isShowLauncherInfo() throws CoreException + { + return getAttribute(true, ATTR_SHOW_LAUNCHER_INFO, true); + } + + /** + * Set to true, if the launch should display it's launch info + * + * @param value true, if the launch should display it's launch info + * @throws CoreException on occasion + */ + public void setShowLauncherInfo(boolean value) throws CoreException + { + setAttribute(true, ATTR_SHOW_LAUNCHER_INFO, value); + } + + /** + * Returns true, if the console of the launcher is available. + * + * @return true, if the console of the launcher is available + * @throws CoreException on occasion + */ + public boolean isConsoleEnabled() throws CoreException + { + return getAttribute(true, ATTR_CONSOLE_ENABLED, true); + } + + /** + * Set to true, if the console of the launcher is available + * + * @param value true, if the console of the launcher is available + * @throws CoreException on occasion + */ + public void setConsoleEnabled(boolean value) throws CoreException + { + setAttribute(true, ATTR_CONSOLE_ENABLED, value); + } + + /** + * Sets the default classpath provider for the Jetty plugin + * + * @param classpathProvider the classpath provider + * @throws CoreException on occasion + */ + public void setClasspathProvider(String classpathProvider) throws CoreException + { + setAttribute(false, IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, classpathProvider); + } + + /** + * Returns the main type name of the Jetty plugin. + * + * @return the main type name of the Jetty plugin + * @throws CoreException on occasion + */ + public String getMainTypeName() throws CoreException + { + return getAttribute(false, IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, JettyPluginUtils.EMPTY); + } + + /** + * Sets the main type name of the Jetty plugin. + * + * @param jettyVersion the version + * @throws CoreException on occasion + */ + public void setMainTypeName(JettyVersion jettyVersion) throws CoreException + { + setAttribute(false, IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, jettyVersion.getType() + .getMainClass()); + } + + /** + * Returns true if the generic id mechanis is available. + * + * @return true if the generic id mechanis is available + * @throws CoreException on occasion + */ + public boolean isGenericIdsSupported() throws CoreException + { + return getConfigVersion() >= 1; + } + + /** + * Returns the specified attribute. + * + * @param globalFallback true to fallback to the global definition + * @param name the name of the attribute + * @param defaultValue the default value + * @return the value of the attribute, the default one if not found. + * @throws CoreException on occasion + */ + protected boolean getAttribute(boolean globalFallback, String name, boolean defaultValue) throws CoreException + { + return configuration.getAttribute( + name, + (globalFallback) ? JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID) + .getBoolean(name, defaultValue) : defaultValue); + } + + /** + * Returns the specified attribute. + * + * @param globalFallback true to fallback to the global definition + * @param name the name of the attribute + * @param defaultValue the default value + * @return the value of the attribute, the default one if not found. + * @throws CoreException on occasion + */ + protected int getAttribute(boolean globalFallback, String name, int defaultValue) throws CoreException + { + return configuration.getAttribute(name, + (globalFallback) ? JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).getInt(name, defaultValue) + : defaultValue); + } + + /** + * Returns the specified attribute. + * + * @param globalFallback true to fallback to the global definition + * @param name the name of the attribute + * @param defaultValue the default value + * @return the value of the attribute, the default one if not found. + * @throws CoreException on occasion + */ + protected String getAttribute(boolean globalFallback, String name, String defaultValue) throws CoreException + { + return configuration.getAttribute(name, + (globalFallback) ? JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).get(name, defaultValue) + : defaultValue); + } + + /** + * Returns true if the specified attribute exists in the configuration. + * + * @param name the name of the attribute + * @return true if exists + * @throws CoreException on occasion + */ + protected boolean hasAttribute(String name) throws CoreException + { + try + { + configuration.getClass().getMethod("hasAttribute", String.class); //$NON-NLS-1$ + + return configuration.hasAttribute(name); + } + catch (SecurityException e) + { + JettyPlugin.error(Messages.adapter_noHasAttribute, e); + } + catch (NoSuchMethodException e) + { + JettyPlugin.warning(Messages.adapter_noDefaultScope, e); + } + + return configuration.getAttributes().containsKey(name); + } + + /** + * Sets the specified attribute. + * + * @param globalFallback true if the value should be written to the global configuration, too + * @param name the name of the attribute + * @param value the value + * @throws CoreException on occasion + */ + protected void setAttribute(boolean globalFallback, String name, boolean value) throws CoreException + { + getConfigurationWorkingCopy().setAttribute(name, value); + + if (!globalFallback) + { + return; + } + + JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).putBoolean(name, value); + + try + { + JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).flush(); + } + catch (BackingStoreException e) + { + // ignore + } + } + + /** + * Sets the specified attribute. + * + * @param globalFallback true if the value should be written to the global configuration, too + * @param name the name of the attribute + * @param value the value + * @throws CoreException on occasion + */ + protected void setAttribute(boolean globalFallback, String name, int value) throws CoreException + { + getConfigurationWorkingCopy().setAttribute(name, value); + + if (!globalFallback) + { + return; + } + + JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).putInt(name, value); + + try + { + JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).flush(); + } + catch (BackingStoreException e) + { + // ignore + } + } + + /** + * Sets the specified attribute. + * + * @param globalFallback true if the value should be written to the global configuration, too + * @param name the name of the attribute + * @param value the value + * @throws CoreException on occasion + */ + protected void setAttribute(boolean globalFallback, String name, String value) throws CoreException + { + getConfigurationWorkingCopy().setAttribute(name, value); + + if (!globalFallback) + { + return; + } + + JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).put(name, value); + + try + { + JettyPlugin.getDefaultScope().getNode(JettyPlugin.PLUGIN_ID).flush(); + } + catch (BackingStoreException e) + { + // ignore + } + } + +} diff --git a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationDelegate.java b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationDelegate.java index dad59ad..46cacb7 100644 --- a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationDelegate.java +++ b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/launch/util/JettyLaunchConfigurationDelegate.java @@ -653,6 +653,11 @@ private static IRuntimeClasspathEntry[] getJettyClasspath(JettyLaunchConfigurati entries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(FileLocator.toFileURL( FileLocator.find(JettyPlugin.getDefault().getBundle(), Path.fromOSString(jettyVersion.getJar()), null)) .getFile()))); + + //Add optimized webappclassloader + entries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(FileLocator.toFileURL( + FileLocator.find(JettyPlugin.getDefault().getBundle(), + Path.fromOSString("lib/eclipse-jetty-optimized-webappclassloader.jar"), null)).getFile()))); for (final File jettyLib : jettyVersion.getLibStrategy().find(jettyPath, jspSupport, jmxSupport, jndiSupport, annotationsSupport, ajpSupport, websocketSupport)) @@ -837,6 +842,9 @@ private File createJettyConfigurationFile(JettyLaunchConfigurationAdapter adapte serverConfiguration.setAnnotationsEnabled(adapter.isAnnotationsSupport()); serverConfiguration.setWebsocketEnabled(adapter.isWebsocketSupport()); serverConfiguration.setJmxEnabled(adapter.isJmxSupport()); + + serverConfiguration.setEnabledOptimizedClassloader(adapter.isOptimizedClassLoaderEnabled()); + serverConfiguration.setOptimizedClassloaderExclusionPattern(adapter.getOptimizedClassLoaderExclusionPattern()); if (adapter.isGracefulShutdownOverrideEnabled()) { diff --git a/plugins/eclipse-jetty-launcher/src/main/resources/net/sourceforge/eclipsejetty/messages.properties b/plugins/eclipse-jetty-launcher/src/main/resources/net/sourceforge/eclipsejetty/messages.properties index acda5df..3ac38d2 100644 --- a/plugins/eclipse-jetty-launcher/src/main/resources/net/sourceforge/eclipsejetty/messages.properties +++ b/plugins/eclipse-jetty-launcher/src/main/resources/net/sourceforge/eclipsejetty/messages.properties @@ -1,185 +1,190 @@ -adapter_configurationOnlyReadable=Configuration only readable -adapter_defaultConfigName=Jetty Webapp -adapter_noDefaultScope=No DefaultScope.INSTANCE (< Eclipse 3.4) -adapter_noHasAttribute=No hasAttribute (< Eclipse 3.4) -advConfigTab_acceptorLimitCountSpinnerTip=The number of Jetty's acceptors, that simultaniously handle requests. -advConfigTab_acceptorLimitCountUnit=acceptors -advConfigTab_acceptorLimitEnabledButton=Limit Number of Acceptors: -advConfigTab_acceptorLimitEnabledButtonTip=Limit the number of Jetty's acceptors, that simultaniously handle requests. -advConfigTab_ajpPortSpinnerTip=The port for the AJP connector. -advConfigTab_ajpSupportButton=Enable AJP Connector on Port: -advConfigTab_ajpSupportButtonTip=Enable an AJP connector on the specified port for your HTTP server. -advConfigTab_clientCacheDisabledButton=Disable Client Cache -advConfigTab_clientCacheDisabledButtonTip=If disabled, Jetty sends a "Cache-Control: max-age=0" with each servlet response. -advConfigTab_consoleEnabledButton=Enable Jetty Plugin Console -advConfigTab_consoleEnabledButtonTip=Enable the powerful console. Type "help" in your Eclipse console. -advConfigTab_contextAddButton=Add... -advConfigTab_contextAddButtonTip=Add a Jetty configuration XML file from the workspace. -advConfigTab_contextAddExternalButton=Add External... -advConfigTab_contextAddExternalButtonTip=Add a Jetty configuration XML file from the file system. -advConfigTab_contextAddExternalTitle=Select Jetty Context File -advConfigTab_contextAddMessage=Select a resource as Jetty Context file: -advConfigTab_contextAddTitle=Resource Selection -advConfigTab_contextCreateFailed=Failed to create default context file -advConfigTab_contextDownButton=Down -advConfigTab_contextDownButtonTip=Move the selected configuration down. -advConfigTab_contextEditButton=Edit... -advConfigTab_contextEditButtonTip=Edit the path of the Jetty configuration XML file. -advConfigTab_contextGroupTitle=Jetty Context Configuration: -advConfigTab_contextInvalid=The Jetty context file %s does not exist. -advConfigTab_contextOpenButton=Open... -advConfigTab_contextOpenButtonTip=Open the selected configuration in an editor. -advConfigTab_contextOpenFailed=Failed to open -advConfigTab_contextRemoveButton=Remove -advConfigTab_contextRemoveButtonTip=Remove the Jetty configuration XML file. -advConfigTab_contextTableFile=Jetty Context File -advConfigTab_contextTableInclude=Include -advConfigTab_contextUpButton=Up -advConfigTab_contextUpButtonTip=Move the selected configuration up. -advConfigTab_customWebDefaultsEnabledButton=Custom Web Defaults XML: -advConfigTab_customWebDefaultsEnabledButtonTip=Define a web.xml that is executed before the web.xml of the web application. -advConfigTab_customWebDefaultsFileSystemButton=File System... -advConfigTab_customWebDefaultsFileSystemButtonTip=Search the file system for a custom web defaults XML file. -advConfigTab_customWebDefaultsFileSystemTitle=Select Custom Web Defaults XML -advConfigTab_customWebDefaultsInvalid=The custom web defaults XML %s does not exist. -advConfigTab_customWebDefaultsMissing=The custom web defaults XML is missing. -advConfigTab_customWebDefaultsResourceTextTip=The path to an web.xml that is executed before the web.xml of the web application. -advConfigTab_customWebDefaultsVariablesButton=Variables... -advConfigTab_customWebDefaultsVariablesButtonTip=Add variables to the path of the custom web defaults XML file. -advConfigTab_customWebDefaultsWorkspaceButton=Workspace... -advConfigTab_customWebDefaultsWorkspaceButtonTip=Search the workspace for a custom web defaults XML file. -advConfigTab_customWebDefaultsWorkspaceMessage=Select a resource as Jetty Context file: -advConfigTab_customWebDefaultsWorkspaceTitle=Resource Selection -advConfigTab_embeddedButton=Use Jetty provided by launcher plugin (Jetty 8.x) -advConfigTab_embeddedButtonTip=The Eclipse Jetty Plugin comes with a tested default Jetty. Use it\! -advConfigTab_externalButton=External... -advConfigTab_externalButtonTip=Search for a Jetty installation in your file system. -advConfigTab_externalMessage=Choose the installation directory of your Jetty. Currenty, the versions 6 to 9 are supported. -advConfigTab_externalTitle=Select Jetty Home Directory -advConfigTab_externButton=Use Jetty at path: -advConfigTab_externButtonTip=Specify a path containing a default Jetty installation. -advConfigTab_gracefulShutdownTimeoutEnabledButton=Override Graceful Shutdown Timeout: -advConfigTab_gracefulShutdownTimeoutEnabledTip=If enabled, the default graceful shutdown timeout of Jetty is overridden. -advConfigTab_gracefulShutdownTimeoutLabel=Graceful Shutdown Timeout: -advConfigTab_gracefulShutdownTimeoutTip=Adjust the timeout for the graceful shutdown when you stop or restart the server. -advConfigTab_gracefulShutdownTimeoutUnit=seconds -advConfigTab_homepageLink=Confused? Get help on the Eclipse Jetty Plugin homepage. -advConfigTab_initializeFailed=Failed to initialize advanced configuration tab -advConfigTab_jettyConfigurationGroupTitle=Jetty Configuration: -advConfigTab_jettyFeaturesGroupTitle=Jetty Features: -advConfigTab_jettyGroupTitle=Jetty: -advConfigTab_jmxSupportButton=Enable JMX Support -advConfigTab_jmxSupportButtonTip=Add JMX beans and enable JMX support for the JVM. -advConfigTab_jndiSupportButton=Enable JNDI Support -advConfigTab_jndiSupportButtonTip=Enable JNDI support. You will need to specify a context file, too. -advConfigTab_jspSupportButton=Enable JSP Support -advConfigTab_jspSupportButtonTip=Enable support and compilation of JSPs. -advConfigTab_websocketSupportButton=Enable Websocket Support -advConfigTab_websocketSupportButtonTip=Add support for websockets (only works in Jetty 9.x) -advConfigTab_message=Configure advanced settings of Jetty. -advConfigTab_pathInvalid=The path %s is not a valid directory. -advConfigTab_pathMissing=Jetty path is not set -advConfigTab_pathTextTip=The path to your Jetty installation folder. -advConfigTab_pathVariablesButton=Variables... -advConfigTab_pathVariablesButtonTip=Add variables to the path. -advConfigTab_performApplyFailed=Failed to update configuration -advConfigTab_pluginFeaturesGroupTitle=Plugin Features: -advConfigTab_serverCacheDisabledButton=Disable Server Cache -advConfigTab_serverCacheDisabledButtonTip=Disables Jetty's server cache for static resources. -advConfigTab_showLauncherInfoButton=Enable Jetty Launch Info -advConfigTab_showLauncherInfoButtonTip=Show the most important configuration options and the classpath before starting Jetty. -advConfigTab_threadPoolLimitCountSpinnerTip=The size of Jetty's thread pool. Be aware that this includes waiting connections. -advConfigTab_threadPoolLimitCountUnit=threads -advConfigTab_threadPoolLimitEnabledButton=Limit Size of Thread Pool: -advConfigTab_threadPoolLimitEnabledButtonTip=Limit the size of Jetty's thread pool. Be aware that this includes waiting connections. -advConfigTab_title=Options -advConfigTab_updateTableFailed=Failed to update table in configuration tab -advConfigTab_versionDetectionFailed=Failed to find and detect Jetty version at path "%s" -configEntry_default=Eclipse Jetty Launcher Context -configTab_contextPathLabel=Context Path: -configTab_contextPathTextTip=The base path of the URL to your application. -configTab_defaultsFailed=Failed to initialize project -configTab_homepageLink=Visit the Eclipse Jetty Plugin homepage. -configTab_httpProtSpinnerTip=The port for the HTTPs connector. -configTab_httpsEnableButton=Enable HTTPs -configTab_httpsEnableButtonTip=Enable HTTPs support on the specified port. -configTab_initializeFailed=Failed to initialize form in configuration tab -configTab_message=Create a configuration to launch a web application with Jetty. -configTab_name=WebApp -configTab_noProjectSelected=No project selected -configTab_performApplyFailed=Failed to update configuration -configTab_portLabel=HTTP / HTTPs Port: -configTab_portSpinnerTip=The port for HTTP connector. -configTab_projectBrowseButton=Browse... -configTab_projectBrowseButtonTip=Select the project from the list of projects in the workspace. -configTab_projectBrowseFailed=Failed to detect Java projects -configTab_projectBrowseMessage=Select a project to constrain your search. -configTab_projectBrowseTitle=Project Selection -configTab_projectClosed=Project %s is closed -configTab_projectGroupTitle=Project: -configTab_projectNameInvalid=Illegal project name: %s -configTab_projectNotExisting=Project %s does not exist -configTab_projectTextTip=The project that contains the web application and all necessary dependencies. -configTab_serverHTTPLink=Your server will be available at %s. -configTab_serverHTTPsLink=There will be a secure connection available at %s, too. -configTab_webAppBrowseButton=Browse... -configTab_webAppBrowseButtonTip=Search the project for the web application folder. -configTab_webAppBrowseMessage=Select your web application root folder. That't the one,\nthat contains the WEB-INF directory with the web.xml. -configTab_webAppBrowseTitle=WebApp Folder -configTab_webAppInvalid=Directoy %s does not contain WEB-INF/web.xml; it is not a valid web application directory -configTab_webAppLabel=WebApp Folder: -configTab_webAppNotExisting=Folder %s does not exist in project %s -configTab_webAppScanButton=Scan... -configTab_webAppScanButtonTip=Automatically scan the project for the WEB-INF/web.xml file. -configTab_webAppScanFailedMessage=Could not to find the file "WEB-INF/web.xml" in project %s.\n\nPlease locate the WebApp Directory manually. -configTab_webAppScanFailedTitle=WebApp Directory not found -configTab_webAppTextTip=The path the web applcation folder. -delegate_keystoreFailed=Failed to store tmp file with keystore -delegate_launchConfigurationFailed=Failed to store tmp file with Jetty launch configuration -delegate_webDefaultsFailed=Failed to store tmp file with Jetty web defaults -depConfigTab_dependencyFilterDefault=type filter text -depConfigTab_dependencyFilterTip=Filters the entries in the dependency table. -depConfigTab_dependencyTableGlobal=Global -depConfigTab_dependencyTableInclude=Include -depConfigTab_dependencyTableName=Name -depConfigTab_dependencyTablePath=Path -depConfigTab_dependencyTableResetButton=Reset Dependency Overrides -depConfigTab_dependencyTableResetButtonTip=Resets all include/exclude overrides and all global overrides. -depConfigTab_dependencyTableScope=Scope -depConfigTab_dependencyTableUpdateFailed=Failed to update table in advanced configuration tab -depConfigTab_homepageLink=ClassNotFoundException? Get help on the Eclipse Jetty Plugin homepage. -depConfigTab_initializeFailed=Failed to initialize dependency tab -depConfigTab_m2eNotAvailable=(m2e not available, no scope info) -depConfigTab_mavenGroupTitle=Include Maven Dependencies: -depConfigTab_mavenIncludeCompileButton=Compile Scope -depConfigTab_mavenIncludeCompileButtonTip=Include all dependencies with the compile scope, by default. -depConfigTab_mavenIncludeImportButton=Import Scope -depConfigTab_mavenIncludeImportButtonTip=Include all dependencies with the mystical and uncommon import scope, by default. -depConfigTab_mavenIncludeNoneButton=Without Scope -depConfigTab_mavenIncludeNoneButtonTip=Include all dependencies that lack a scope definition, by default. -depConfigTab_mavenIncludeProvidedButton=Provided Scope -depConfigTab_mavenIncludeProvidedButtonTip=Include all dependencies with the provided scope, by default. -depConfigTab_mavenIncludeRuntimeButton=Runtime Scope -depConfigTab_mavenIncludeRuntimeButtonTip=Include all dependencies with the runtime scope, by default. -depConfigTab_mavenIncludeSystemButton=System Scope -depConfigTab_mavenIncludeSystemButtonTip=Include all dependencies with the system scope, by default. -depConfigTab_mavenIncludeTestButton=Test Scope -depConfigTab_mavenIncludeTestButtonTip=Include all dependencies with the test scope, by default. -depConfigTab_message=Configure dependencies of Jetty. -depConfigTab_noM2ENature=(no m2e nature, no scope info) -depConfigTab_otherGroupTitle=Include Other Dependencies: -depConfigTab_performApplyFailed=Failed to update configuration -depConfigTab_title=Dependencies -dependencyMap_fixedScope=Fixed scope for dependency %s: changed %s to %s -mavenScope_unknown=Unknown scope: %s -shortcut_createFailed=Failed to create and launch configuration -shortcut_invalidEditorInput=Cannot determine editor input -shortcut_invalidEditorInputFile=Cannot determine file of editor input -shortcut_unsupportedLaunchSelection=Unsupported launch selection: %s -shortcut_unsupportedLaunchSelectionElement=Unsupported launch selection first element: %s -shortcut_webAppDirNotFoundMessage=Could not to find the file "WEB-INF/web.xml" in project %s.\n\nPlease locate the WebApp Directory manually. -shortcut_webAppDirNotFoundTitle=WebApp Directory not found -shortcut_webAppNotFound=Could not find WebApp path -shortcut_webAppSelectMessage=Select your web application root folder. That't the one,\nthat contains the WEB-INF directory with the web.xml. -shortcut_webAppSelectTitle=WebApp Folder -utils_scanFailed=Failed to scan project +adapter_configurationOnlyReadable=Configuration only readable +adapter_defaultConfigName=Jetty Webapp +adapter_noDefaultScope=No DefaultScope.INSTANCE (< Eclipse 3.4) +adapter_noHasAttribute=No hasAttribute (< Eclipse 3.4) +advConfigTab_acceptorLimitCountSpinnerTip=The number of Jetty's acceptors, that simultaniously handle requests. +advConfigTab_acceptorLimitCountUnit=acceptors +advConfigTab_acceptorLimitEnabledButton=Limit Number of Acceptors: +advConfigTab_acceptorLimitEnabledButtonTip=Limit the number of Jetty's acceptors, that simultaniously handle requests. +advConfigTab_ajpPortSpinnerTip=The port for the AJP connector. +advConfigTab_ajpSupportButton=Enable AJP Connector on Port: +advConfigTab_ajpSupportButtonTip=Enable an AJP connector on the specified port for your HTTP server. +advConfigTab_clientCacheDisabledButton=Disable Client Cache +advConfigTab_clientCacheDisabledButtonTip=If disabled, Jetty sends a "Cache-Control: max-age=0" with each servlet response. +advConfigTab_consoleEnabledButton=Enable Jetty Plugin Console +advConfigTab_consoleEnabledButtonTip=Enable the powerful console. Type "help" in your Eclipse console. +advConfigTab_contextAddButton=Add... +advConfigTab_contextAddButtonTip=Add a Jetty configuration XML file from the workspace. +advConfigTab_contextAddExternalButton=Add External... +advConfigTab_contextAddExternalButtonTip=Add a Jetty configuration XML file from the file system. +advConfigTab_contextAddExternalTitle=Select Jetty Context File +advConfigTab_contextAddMessage=Select a resource as Jetty Context file: +advConfigTab_contextAddTitle=Resource Selection +advConfigTab_contextCreateFailed=Failed to create default context file +advConfigTab_contextDownButton=Down +advConfigTab_contextDownButtonTip=Move the selected configuration down. +advConfigTab_contextEditButton=Edit... +advConfigTab_contextEditButtonTip=Edit the path of the Jetty configuration XML file. +advConfigTab_contextGroupTitle=Jetty Context Configuration: +advConfigTab_contextInvalid=The Jetty context file %s does not exist. +advConfigTab_contextOpenButton=Open... +advConfigTab_contextOpenButtonTip=Open the selected configuration in an editor. +advConfigTab_contextOpenFailed=Failed to open +advConfigTab_contextRemoveButton=Remove +advConfigTab_contextRemoveButtonTip=Remove the Jetty configuration XML file. +advConfigTab_contextTableFile=Jetty Context File +advConfigTab_contextTableInclude=Include +advConfigTab_contextUpButton=Up +advConfigTab_contextUpButtonTip=Move the selected configuration up. +advConfigTab_customWebDefaultsEnabledButton=Custom Web Defaults XML: +advConfigTab_customWebDefaultsEnabledButtonTip=Define a web.xml that is executed before the web.xml of the web application. +advConfigTab_customWebDefaultsFileSystemButton=File System... +advConfigTab_customWebDefaultsFileSystemButtonTip=Search the file system for a custom web defaults XML file. +advConfigTab_customWebDefaultsFileSystemTitle=Select Custom Web Defaults XML +advConfigTab_customWebDefaultsInvalid=The custom web defaults XML %s does not exist. +advConfigTab_customWebDefaultsMissing=The custom web defaults XML is missing. +advConfigTab_customWebDefaultsResourceTextTip=The path to an web.xml that is executed before the web.xml of the web application. +advConfigTab_customWebDefaultsVariablesButton=Variables... +advConfigTab_customWebDefaultsVariablesButtonTip=Add variables to the path of the custom web defaults XML file. +advConfigTab_customWebDefaultsWorkspaceButton=Workspace... +advConfigTab_customWebDefaultsWorkspaceButtonTip=Search the workspace for a custom web defaults XML file. +advConfigTab_customWebDefaultsWorkspaceMessage=Select a resource as Jetty Context file: +advConfigTab_customWebDefaultsWorkspaceTitle=Resource Selection +advConfigTab_embeddedButton=Use Jetty provided by launcher plugin (Jetty 8.x) +advConfigTab_embeddedButtonTip=The Eclipse Jetty Plugin comes with a tested default Jetty. Use it\! +advConfigTab_externalButton=External... +advConfigTab_externalButtonTip=Search for a Jetty installation in your file system. +advConfigTab_externalMessage=Choose the installation directory of your Jetty. Currenty, the versions 6 to 9 are supported. +advConfigTab_externalTitle=Select Jetty Home Directory +advConfigTab_externButton=Use Jetty at path: +advConfigTab_externButtonTip=Specify a path containing a default Jetty installation. +advConfigTab_gracefulShutdownTimeoutEnabledButton=Override Graceful Shutdown Timeout: +advConfigTab_gracefulShutdownTimeoutEnabledTip=If enabled, the default graceful shutdown timeout of Jetty is overridden. +advConfigTab_gracefulShutdownTimeoutLabel=Graceful Shutdown Timeout: +advConfigTab_gracefulShutdownTimeoutTip=Adjust the timeout for the graceful shutdown when you stop or restart the server. +advConfigTab_gracefulShutdownTimeoutUnit=seconds +advConfigTab_homepageLink=Confused? Get help on the Eclipse Jetty Plugin homepage. +advConfigTab_initializeFailed=Failed to initialize advanced configuration tab +advConfigTab_jettyConfigurationGroupTitle=Jetty Configuration: +advConfigTab_jettyFeaturesGroupTitle=Jetty Features: +advConfigTab_jettyGroupTitle=Jetty: +advConfigTab_jmxSupportButton=Enable JMX Support +advConfigTab_jmxSupportButtonTip=Add JMX beans and enable JMX support for the JVM. +advConfigTab_jndiSupportButton=Enable JNDI Support +advConfigTab_jndiSupportButtonTip=Enable JNDI support. You will need to specify a context file, too. +advConfigTab_jspSupportButton=Enable JSP Support +advConfigTab_jspSupportButtonTip=Enable support and compilation of JSPs. +advConfigTab_websocketSupportButton=Enable Websocket Support +advConfigTab_websocketSupportButtonTip=Add support for websockets (only works in Jetty 9.x) +advConfigTab_message=Configure advanced settings of Jetty. +advConfigTab_pathInvalid=The path %s is not a valid directory. +advConfigTab_pathMissing=Jetty path is not set +advConfigTab_pathTextTip=The path to your Jetty installation folder. +advConfigTab_pathVariablesButton=Variables... +advConfigTab_pathVariablesButtonTip=Add variables to the path. +advConfigTab_performApplyFailed=Failed to update configuration +advConfigTab_pluginFeaturesGroupTitle=Plugin Features: +advConfigTab_serverCacheDisabledButton=Disable Server Cache +advConfigTab_serverCacheDisabledButtonTip=Disables Jetty's server cache for static resources. +advConfigTab_showLauncherInfoButton=Enable Jetty Launch Info +advConfigTab_showLauncherInfoButtonTip=Show the most important configuration options and the classpath before starting Jetty. +advConfigTab_threadPoolLimitCountSpinnerTip=The size of Jetty's thread pool. Be aware that this includes waiting connections. +advConfigTab_threadPoolLimitCountUnit=threads +advConfigTab_threadPoolLimitEnabledButton=Limit Size of Thread Pool: +advConfigTab_threadPoolLimitEnabledButtonTip=Limit the size of Jetty's thread pool. Be aware that this includes waiting connections. +advConfigTab_title=Options +advConfigTab_updateTableFailed=Failed to update table in configuration tab +advConfigTab_versionDetectionFailed=Failed to find and detect Jetty version at path "%s" +configEntry_default=Eclipse Jetty Launcher Context +configTab_contextPathLabel=Context Path: +configTab_contextPathTextTip=The base path of the URL to your application. +configTab_defaultsFailed=Failed to initialize project +configTab_homepageLink=Visit the Eclipse Jetty Plugin homepage. +configTab_httpProtSpinnerTip=The port for the HTTPs connector. +configTab_httpsEnableButton=Enable HTTPs +configTab_httpsEnableButtonTip=Enable HTTPs support on the specified port. +configTab_initializeFailed=Failed to initialize form in configuration tab +configTab_message=Create a configuration to launch a web application with Jetty. +configTab_name=WebApp +configTab_noProjectSelected=No project selected +configTab_performApplyFailed=Failed to update configuration +configTab_portLabel=HTTP / HTTPs Port: +configTab_portSpinnerTip=The port for HTTP connector. +configTab_projectBrowseButton=Browse... +configTab_projectBrowseButtonTip=Select the project from the list of projects in the workspace. +configTab_projectBrowseFailed=Failed to detect Java projects +configTab_projectBrowseMessage=Select a project to constrain your search. +configTab_projectBrowseTitle=Project Selection +configTab_projectClosed=Project %s is closed +configTab_projectGroupTitle=Project: +configTab_projectNameInvalid=Illegal project name: %s +configTab_projectNotExisting=Project %s does not exist +configTab_projectTextTip=The project that contains the web application and all necessary dependencies. +configTab_serverHTTPLink=Your server will be available at %s. +configTab_serverHTTPsLink=There will be a secure connection available at %s, too. +configTab_webAppBrowseButton=Browse... +configTab_webAppBrowseButtonTip=Search the project for the web application folder. +configTab_webAppBrowseMessage=Select your web application root folder. That't the one,\nthat contains the WEB-INF directory with the web.xml. +configTab_webAppBrowseTitle=WebApp Folder +configTab_webAppInvalid=Directoy %s does not contain WEB-INF/web.xml; it is not a valid web application directory +configTab_webAppLabel=WebApp Folder: +configTab_webAppNotExisting=Folder %s does not exist in project %s +configTab_webAppScanButton=Scan... +configTab_webAppScanButtonTip=Automatically scan the project for the WEB-INF/web.xml file. +configTab_webAppScanFailedMessage=Could not to find the file "WEB-INF/web.xml" in project %s.\n\nPlease locate the WebApp Directory manually. +configTab_webAppScanFailedTitle=WebApp Directory not found +configTab_webAppTextTip=The path the web applcation folder. +delegate_keystoreFailed=Failed to store tmp file with keystore +delegate_launchConfigurationFailed=Failed to store tmp file with Jetty launch configuration +delegate_webDefaultsFailed=Failed to store tmp file with Jetty web defaults +depConfigTab_dependencyFilterDefault=type filter text +depConfigTab_dependencyFilterTip=Filters the entries in the dependency table. +depConfigTab_dependencyTableGlobal=Global +depConfigTab_dependencyTableInclude=Include +depConfigTab_dependencyTableName=Name +depConfigTab_dependencyTablePath=Path +depConfigTab_dependencyTableResetButton=Reset Dependency Overrides +depConfigTab_dependencyTableResetButtonTip=Resets all include/exclude overrides and all global overrides. +depConfigTab_dependencyTableScope=Scope +depConfigTab_dependencyTableUpdateFailed=Failed to update table in advanced configuration tab +depConfigTab_homepageLink=ClassNotFoundException? Get help on the Eclipse Jetty Plugin homepage. +depConfigTab_initializeFailed=Failed to initialize dependency tab +depConfigTab_m2eNotAvailable=(m2e not available, no scope info) +depConfigTab_mavenGroupTitle=Include Maven Dependencies: +depConfigTab_mavenIncludeCompileButton=Compile Scope +depConfigTab_mavenIncludeCompileButtonTip=Include all dependencies with the compile scope, by default. +depConfigTab_mavenIncludeImportButton=Import Scope +depConfigTab_mavenIncludeImportButtonTip=Include all dependencies with the mystical and uncommon import scope, by default. +depConfigTab_mavenIncludeNoneButton=Without Scope +depConfigTab_mavenIncludeNoneButtonTip=Include all dependencies that lack a scope definition, by default. +depConfigTab_mavenIncludeProvidedButton=Provided Scope +depConfigTab_mavenIncludeProvidedButtonTip=Include all dependencies with the provided scope, by default. +depConfigTab_mavenIncludeRuntimeButton=Runtime Scope +depConfigTab_mavenIncludeRuntimeButtonTip=Include all dependencies with the runtime scope, by default. +depConfigTab_mavenIncludeSystemButton=System Scope +depConfigTab_mavenIncludeSystemButtonTip=Include all dependencies with the system scope, by default. +depConfigTab_mavenIncludeTestButton=Test Scope +depConfigTab_mavenIncludeTestButtonTip=Include all dependencies with the test scope, by default. +depConfigTab_message=Configure dependencies of Jetty. +depConfigTab_noM2ENature=(no m2e nature, no scope info) +depConfigTab_otherGroupTitle=Include Other Dependencies: +depConfigTab_performApplyFailed=Failed to update configuration +depConfigTab_title=Dependencies +dependencyMap_fixedScope=Fixed scope for dependency %s: changed %s to %s +mavenScope_unknown=Unknown scope: %s +shortcut_createFailed=Failed to create and launch configuration +shortcut_invalidEditorInput=Cannot determine editor input +shortcut_invalidEditorInputFile=Cannot determine file of editor input +shortcut_unsupportedLaunchSelection=Unsupported launch selection: %s +shortcut_unsupportedLaunchSelectionElement=Unsupported launch selection first element: %s +shortcut_webAppDirNotFoundMessage=Could not to find the file "WEB-INF/web.xml" in project %s.\n\nPlease locate the WebApp Directory manually. +shortcut_webAppDirNotFoundTitle=WebApp Directory not found +shortcut_webAppNotFound=Could not find WebApp path +shortcut_webAppSelectMessage=Select your web application root folder. That't the one,\nthat contains the WEB-INF directory with the web.xml. +shortcut_webAppSelectTitle=WebApp Folder +utils_scanFailed=Failed to scan project +advConfigTab_jettyWebappClassLoaderFeatureGroupTitle=Jetty Speed Settings: +advConfigTab_enableOptimizedWebAppClassLoaderButtonButton=Enable faster startup (package all open projects into java archives) +advConfigTab_enableOptimizedWebAppClassLoaderButtonButtonTip=This button enables faster jetty startup by using an optimized web app classloader +advConfigTab_advancedClassLoaderExclusionTitle=Exclusion pattern to prevent packaging of certain projects: +advConfigTab_advancedClassLoaderExclusionPatternTip=Exclusion pattern (regex, comma separated) for the optimized classloader. Default: ".*assembly.*". Be as precise as possible for max. speed. \ No newline at end of file diff --git a/pom.xml b/pom.xml index be6d816..ce18588 100644 --- a/pom.xml +++ b/pom.xml @@ -1,169 +1,169 @@ - - 4.0.0 - net.sourceforge.eclipsejetty - parent - pom - Eclipse Jetty Integration - 3.9.0-SNAPSHOT - Provides integration for Jetty server as launch configurations in Eclipse. - http://eclipse-jetty.github.io/ - 2009 - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - GitHub - https://github.com/eclipse-jetty/eclipse-jetty-plugin/issues/ - - - - - ckoeberl - Christian Köberl - christian.koeberl at gmail com - http://derkoe.wordpress.com/ - - - thred - Manfred Hantschel - - - - - UTF-8 - 0.20.0 - - - - scm:git:https://github.com/eclipse-jetty/eclipse-jetty-plugin.git - scm:git:https://github.com/eclipse-jetty/eclipse-jetty-plugin.git - HEAD - https://github.com/eclipse-jetty/eclipse-jetty-plugin - - - - plugins/eclipse-jetty-launcher - features/eclipse-jetty - site - starters - - - - - - - org.eclipse.tycho - tycho-maven-plugin - ${tycho-version} - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.5 - 1.5 - - - - - org.apache.maven.plugins - maven-site-plugin - 3.4 - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - [2.4,) - - copy-dependencies - - - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.8.1 - - true - false - false - - - - - project-team - issue-tracking - license - scm - - - - - - org.apache.maven.plugins - maven-changes-plugin - 2.11 - - - SourceForge - - - http://sourceforge.net/p/eclipse-jetty/feature-requests/%ISSUE% - - - - - - changes-report - - - - - - - - - - eclipse-indigo - http://download.eclipse.org/releases/indigo - p2 - - + + 4.0.0 + net.sourceforge.eclipsejetty + parent + pom + Eclipse Jetty Integration + 3.9.0-SNAPSHOT + Provides integration for Jetty server as launch configurations in Eclipse. + http://eclipse-jetty.github.io/ + 2009 + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + GitHub + https://github.com/eclipse-jetty/eclipse-jetty-plugin/issues/ + + + + + ckoeberl + Christian Köberl + christian.koeberl at gmail com + http://derkoe.wordpress.com/ + + + thred + Manfred Hantschel + + + + + UTF-8 + 0.20.0 + + + + scm:git:https://github.com/eclipse-jetty/eclipse-jetty-plugin.git + scm:git:https://github.com/eclipse-jetty/eclipse-jetty-plugin.git + HEAD + https://github.com/eclipse-jetty/eclipse-jetty-plugin + + + + plugins/eclipse-jetty-launcher + features/eclipse-jetty + site + starters + + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-site-plugin + 3.4 + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.4,) + + copy-dependencies + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.8.1 + + true + false + false + + + + + project-team + issue-tracking + license + scm + + + + + + org.apache.maven.plugins + maven-changes-plugin + 2.11 + + + SourceForge + + + http://sourceforge.net/p/eclipse-jetty/feature-requests/%ISSUE% + + + + + + changes-report + + + + + + + + + + eclipse-indigo + http://download.eclipse.org/releases/indigo + p2 + + \ No newline at end of file diff --git a/samples/quickstart/pom.xml b/samples/quickstart/pom.xml index da1826d..7d0be71 100644 --- a/samples/quickstart/pom.xml +++ b/samples/quickstart/pom.xml @@ -110,8 +110,8 @@ maven-compiler-plugin 2.3.2 - 1.5 - 1.5 + 1.8 + 1.8 true diff --git a/starters/common/.settings/org.eclipse.jdt.core.prefs b/starters/common/.settings/org.eclipse.jdt.core.prefs index 8626026..714351a 100644 --- a/starters/common/.settings/org.eclipse.jdt.core.prefs +++ b/starters/common/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,5 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/starters/common/pom.xml b/starters/common/pom.xml index ee42c78..a231952 100644 --- a/starters/common/pom.xml +++ b/starters/common/pom.xml @@ -1,43 +1,43 @@ - - - 4.0.0 - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters - 3.9.0-SNAPSHOT - - - eclipse-jetty-starters-common - Eclipse Jetty Launcher Starters Common - - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters-console - ${project.version} - true - - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters-util - ${project.version} - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - + + + 4.0.0 + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters + 3.9.0-SNAPSHOT + + + eclipse-jetty-starters-common + Eclipse Jetty Launcher Starters Common + + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters-console + ${project.version} + true + + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters-util + ${project.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/starters/console/pom.xml b/starters/console/pom.xml index dcd77b3..60dd5fe 100644 --- a/starters/console/pom.xml +++ b/starters/console/pom.xml @@ -1,36 +1,36 @@ - - - 4.0.0 - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters - 3.9.0-SNAPSHOT - - - eclipse-jetty-starters-console - Eclipse Jetty Launcher Starters Console - - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters-util - ${project.version} - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - + + + 4.0.0 + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters + 3.9.0-SNAPSHOT + + + eclipse-jetty-starters-console + Eclipse Jetty Launcher Starters Console + + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters-util + ${project.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/starters/jetty6/pom.xml b/starters/jetty6/pom.xml index 403dcf9..e4b3262 100644 --- a/starters/jetty6/pom.xml +++ b/starters/jetty6/pom.xml @@ -1,44 +1,44 @@ - - - 4.0.0 - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters - 3.9.0-SNAPSHOT - - - eclipse-jetty-starters-jetty6 - - Eclipse Jetty Launcher Starters Jetty 6 - - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters-common - ${project.version} - - - - org.mortbay.jetty - jetty - ${version.jetty6} - provided - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - + + + 4.0.0 + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters + 3.9.0-SNAPSHOT + + + eclipse-jetty-starters-jetty6 + + Eclipse Jetty Launcher Starters Jetty 6 + + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters-common + ${project.version} + + + + org.mortbay.jetty + jetty + ${version.jetty6} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/starters/jetty7/pom.xml b/starters/jetty7/pom.xml index fb6f2ce..5e68705 100644 --- a/starters/jetty7/pom.xml +++ b/starters/jetty7/pom.xml @@ -1,58 +1,58 @@ - - - 4.0.0 - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters - 3.9.0-SNAPSHOT - - - eclipse-jetty-starters-jetty7 - - Eclipse Jetty Launcher Starters Jetty 7 - - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters-common - ${project.version} - - - - org.eclipse.jetty - jetty-server - ${version.jetty7} - provided - - - - org.eclipse.jetty - jetty-webapp - ${version.jetty7} - provided - - - - org.eclipse.jetty - jetty-xml - ${version.jetty7} - provided - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - + + + 4.0.0 + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters + 3.9.0-SNAPSHOT + + + eclipse-jetty-starters-jetty7 + + Eclipse Jetty Launcher Starters Jetty 7 + + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters-common + ${project.version} + + + + org.eclipse.jetty + jetty-server + ${version.jetty7} + provided + + + + org.eclipse.jetty + jetty-webapp + ${version.jetty7} + provided + + + + org.eclipse.jetty + jetty-xml + ${version.jetty7} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/starters/optimizedwebappclassloader/pom.xml b/starters/optimizedwebappclassloader/pom.xml new file mode 100644 index 0000000..68f998e --- /dev/null +++ b/starters/optimizedwebappclassloader/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters + 3.9.0-SNAPSHOT + + + eclipse-jetty-optimized-webappclassloader + Eclipse Jetty Optimized WebAppClassLoader + Optimized Jetty WebAppClassLoader + + + Robert Schmelzer + robert.schmelzer@catalysts.cc + + + Stefan Starke + stefan.starke@catalysts.cc + + + + + 1.8 + 1.8 + + + + + + org.eclipse.jetty + jetty-webapp + 9.4.6.v20170531 + + + + diff --git a/starters/optimizedwebappclassloader/src/main/java/jetty/classloader/OptimizedWebAppClassLoader.java b/starters/optimizedwebappclassloader/src/main/java/jetty/classloader/OptimizedWebAppClassLoader.java new file mode 100644 index 0000000..877e7be --- /dev/null +++ b/starters/optimizedwebappclassloader/src/main/java/jetty/classloader/OptimizedWebAppClassLoader.java @@ -0,0 +1,231 @@ +package jetty.classloader; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Date; +import java.util.StringTokenizer; +import java.util.UUID; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipOutputStream; + +import org.eclipse.jetty.server.handler.ContextHandler; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.util.resource.Resource; +import org.eclipse.jetty.util.resource.ResourceCollection; +import org.eclipse.jetty.webapp.WebAppClassLoader; +import org.eclipse.jetty.webapp.WebAppContext; + +/** + * Optimized class loader for Jetty
+ * Useful in case you have a lot of open (exploded) projects on your classpath + * and keep wondering why your server start (class-loading) is so slow.
+ * It turns out, that class loading is much faster with *.jar on the classpath + * as then the classloader can easily evaluate if a class is present in a *.jar + * or not. When dealing with exploded target/classes folders it turned out that + * every class being loaded is check for existance in every directory which + * takes forever.
+ * Therefore this class loader does the following: + *
    + *
  • Override addClassPath() from + * org.eclipse.jetty.webapp.WebAppClassLoader
  • + *
  • If a class path entry is in fact a directory -> create a JAR-file for it + * and append the JAR-file not the directory to the classpath
  • + *
  • Exclude some special directories - for example the web assembly must be + * exploded
  • + *
  • Moreover tapestry web-modules need to be kept exploded otherwise + * tapestry's live reloading does not work.
  • + *
+ * This class used a highly optimized version of String.replace which is more + * than 4-times faster, resulting in 10sec JAR-file generation instead of ~60. + * (for CrossNG SWP)
+ * With this optimized class loader the server starts as fast as when only the + * web assembly project is opened. Independent of the amount of open projects in + * your eclipse workspace.
+ * Tests resulted in 8min5sec with the default class loader and 3min48sec with + * the optimized version. >50% improvement.
+ * Debugging works, Tapestry live reloading only with excluded web-directories. + * (so that they are kept exploded and not packaged.) + * + * @author Robert Schmelzer (ext.rschmelzer) + * @author Stefan Starke (ext.stas) + */ +public class OptimizedWebAppClassLoader extends WebAppClassLoader { + private static final Logger LOG = Log.getLogger(OptimizedWebAppClassLoader.class); + + // Directory path to store and reference the package JAR-files to + private static String TEMP_JAR_DIR = System.getProperty("java.io.tmpdir") + "jetty9JarCache" + File.separatorChar; + // Comma separated list of resources (regex) that are not package but left + // exploded + // Always add assembly. Add ".*assembly.*,.*web.*" do enable tapestry live + // reloading. + private static String EXCLUDED_RESOURCES = ".*assembly.*"; + + public OptimizedWebAppClassLoader(WebAppContext context, String exclusionPattern) throws IOException { + super(context); + EXCLUDED_RESOURCES = exclusionPattern; + LOG.debug("constructor OptimizedWebAppClassLoader(context)"); + if (context.getExtraClasspath() != null) + addClassPathInternal(context.getExtraClasspath()); + } + + // Called by super constructor, implemented empty so that nothing happens + // We want to call addClassPath manually once the exclusion pattern is set + // See -> addClassPathInternal() + @Override + public void addClassPath(String classPath) throws IOException { + } + + public void addClassPathInternal(String classPath) throws IOException { + LOG.debug(String.format("addClassPath: {}", classPath)); + + if (classPath == null) + return; + + // Correct path to include the context name + TEMP_JAR_DIR = TEMP_JAR_DIR + + ((ContextHandler) super.getContext()).getContextPath().replace("/", "").replace("\\", "") + + File.separatorChar; + LOG.warn( + "Start melting open projects into strong java archives (Exclusion Pattern: '{}'. Temporary archive storage: {})", + EXCLUDED_RESOURCES, TEMP_JAR_DIR); + + long start = new Date().getTime(); + int jarCnt = 0; + int excludedJarCnt = 0; + + // Create temp jar file directory. If it already exists, clear it + if (Files.exists(Paths.get(TEMP_JAR_DIR))) { + for (File file : Paths.get(TEMP_JAR_DIR).toFile().listFiles()) + if (!file.isDirectory()) + file.delete(); + } else { + Files.createDirectories(Paths.get(TEMP_JAR_DIR)); + } + + String[] excludedResources = EXCLUDED_RESOURCES.split(","); + + StringTokenizer tokenizer = new StringTokenizer(classPath, ",;"); + while (tokenizer.hasMoreTokens()) { + Resource resource = getContext().newResource(tokenizer.nextToken().trim()); + + // Add the resource + if (resource.isDirectory() && resource instanceof ResourceCollection) + addClassPath(resource); + else { + // Resolve file path if possible + File file = resource.getFile(); + if (file != null && !resource.isDirectory()) { + URL url = resource.getURI().toURL(); + addURL(url); + LOG.debug("Left {} untouched as it is not a directory.", file.getPath()); + } else if (resource.isDirectory()) { + jarCnt++; + boolean doNotPackage = false; + for (String excludedResource : excludedResources) { + if (resource.getName().toLowerCase().matches(excludedResource)) { + doNotPackage = true; + LOG.debug("Excluded {} from packaging as it matches regex {}.", resource.getName(), + excludedResource); + } + } + if (doNotPackage) { + addURL(resource.getURI().toURL()); + excludedJarCnt++; + } else { + Path tmpJar = Files.createFile(Paths.get(TEMP_JAR_DIR + UUID.randomUUID() + ".jar")); + // Manifest m = new Manifest(); + JarOutputStream zs = new JarOutputStream(Files.newOutputStream(tmpJar)); + createJAR(resource.getFile().getAbsolutePath(), zs); + zs.close(); + addURL(tmpJar.toUri().toURL()); + LOG.debug("Packaged {} to {}.", resource.getName(), tmpJar.toAbsolutePath().toString()); + } + } else { + LOG.debug("Check file exists and is not nested jar: " + resource); + throw new IllegalArgumentException( + "File not resolvable or incompatible with URLClassloader: " + resource); + } + } + + } + long timeInMs = new Date().getTime() - start; + LOG.warn( + "Finished melting open projects into strong java archives within {} seconds. (Found {} open projects, Created {} JARs, Excluded {} JARs)", + getTimeString(timeInMs), jarCnt, jarCnt - excludedJarCnt, excludedJarCnt); + } + + /** return time in format 23.456 */ + private String getTimeString(long millis) { + int seconds = (int) ((millis / 1000) % 60); + int milliseconds = (int) (millis % 1000); + return String.format("%02d.%03d", seconds, milliseconds); + } + + private void createJAR(String sourceDirPath, ZipOutputStream zs) throws IOException { + Path pp = Paths.get(sourceDirPath); + Files.walk(pp).forEach(path -> { + // Do not use String.replace. It is four times slower (45secs + // slower) than this implementation. + // You do not believe it? Try it. ;) + String name = replace(pp.relativize(path).toString(), "\\", "/"); + if (Files.isDirectory(path)) { + name = name + "/"; + } + JarEntry zipEntry = new JarEntry(name); + try { + zs.putNextEntry(zipEntry); + if (!Files.isDirectory(path)) { + zs.write(Files.readAllBytes(path)); + } + zs.closeEntry(); + } catch (Exception e) { + System.err.println(e); + } + }); + } + + /** + * Super hyper fast String.replace - thx to stackoverflow
+ * https://stackoverflow.com/questions/16228992/commons-lang-stringutils-replace-performance-vs-string-replace + * + * @param source + * . + * @param os + * . + * @param ns + * . + * @return . + */ + private String replace(String source, String os, String ns) { + if (source == null) { + return null; + } + int i = 0; + if ((i = source.indexOf(os, i)) >= 0) { + char[] sourceArray = source.toCharArray(); + char[] nsArray = ns.toCharArray(); + int oLength = os.length(); + StringBuilder buf = new StringBuilder(sourceArray.length); + buf.append(sourceArray, 0, i).append(nsArray); + i += oLength; + int j = i; + // Replace all remaining instances of oldString with newString. + while ((i = source.indexOf(os, i)) > 0) { + buf.append(sourceArray, j, i - j).append(nsArray); + i += oLength; + j = i; + } + buf.append(sourceArray, j, sourceArray.length - j); + source = buf.toString(); + buf.setLength(0); + } + return source; + } + +} diff --git a/starters/pom.xml b/starters/pom.xml index b4dc331..2060330 100644 --- a/starters/pom.xml +++ b/starters/pom.xml @@ -1,35 +1,36 @@ - - - 4.0.0 - - - net.sourceforge.eclipsejetty - parent - 3.9.0-SNAPSHOT - - - eclipse-jetty-starters - pom - - Eclipse Jetty Launcher Starters - - - 6.1.26 - 7.6.12.v20130726 - 8.1.14.v20131031 - 9.0.5.v20130815 - - - - common - embedded - jetty6 - jetty7 - jetty8 - jetty9 - console - util - - + + + 4.0.0 + + + net.sourceforge.eclipsejetty + parent + 3.9.0-SNAPSHOT + + + eclipse-jetty-starters + pom + + Eclipse Jetty Launcher Starters + + + 6.1.26 + 7.6.12.v20130726 + 8.1.14.v20131031 + 9.0.5.v20130815 + + + + common + embedded + jetty6 + jetty7 + jetty8 + jetty9 + console + util + optimizedwebappclassloader + + \ No newline at end of file diff --git a/starters/util/pom.xml b/starters/util/pom.xml index 8e33738..b2db2a8 100644 --- a/starters/util/pom.xml +++ b/starters/util/pom.xml @@ -1,28 +1,28 @@ - - - 4.0.0 - - - net.sourceforge.eclipsejetty - eclipse-jetty-starters - 3.9.0-SNAPSHOT - - - eclipse-jetty-starters-util - Eclipse Jetty Launcher Starters Util - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - + + + 4.0.0 + + + net.sourceforge.eclipsejetty + eclipse-jetty-starters + 3.9.0-SNAPSHOT + + + eclipse-jetty-starters-util + Eclipse Jetty Launcher Starters Util + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + \ No newline at end of file