diff --git a/bundles/org.eclipse.rap.tools.launch.rwt/META-INF/MANIFEST.MF b/bundles/org.eclipse.rap.tools.launch.rwt/META-INF/MANIFEST.MF index 53eef1c5..61969f0b 100644 --- a/bundles/org.eclipse.rap.tools.launch.rwt/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.rap.tools.launch.rwt/META-INF/MANIFEST.MF @@ -17,6 +17,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)", org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)", org.eclipse.jetty.ee10.servlet;bundle-version="[12.0.0,13.0.0)", org.eclipse.jetty.ee10.webapp;bundle-version="[12.0.0,13.0.0)", + org.eclipse.jetty.ee8.server;bundle-version="[12.0.0,13.0.0)", + org.eclipse.jetty.ee8.servlet;bundle-version="[12.0.0,13.0.0)", + org.eclipse.jetty.ee8.webapp;bundle-version="[12.0.0,13.0.0)", org.eclipse.jetty.http;bundle-version="[12.0.0,13.0.0)", org.eclipse.jetty.io;bundle-version="[12.0.0,13.0.0)", org.eclipse.jetty.security;bundle-version="[12.0.0,13.0.0)", diff --git a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/config/RWTLaunchConfig.java b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/config/RWTLaunchConfig.java index 3fe2c114..f7566e18 100644 --- a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/config/RWTLaunchConfig.java +++ b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/config/RWTLaunchConfig.java @@ -31,6 +31,11 @@ public static enum LaunchTarget { ENTRY_POINT, WEB_XML, } + + public static enum JakartaVersion { + EE8, + EE10, + } // Attribute names from JDT's Java Launcher private static final String PROJECT_NAME @@ -57,6 +62,7 @@ public static enum LaunchTarget { private static final String OPEN_BROWSER = PREFIX + "openBrowser"; //$NON-NLS-1$ private static final String BROWSER_MODE = PREFIX + "browserMode"; //$NON-NLS-1$ private static final String DEVELOPMENT_MODE = PREFIX + "developmentMode"; //$NON-NLS-1$ + public static final String JAKARTA_VERSION = PREFIX + "jakartaVersion"; //$NON-NLS-1$ // Default values for attributes private static final LaunchTarget DEFAULT_LAUNCH_TARGET = LaunchTarget.ENTRY_POINT; @@ -77,6 +83,7 @@ public static enum LaunchTarget { private static final boolean DEFAULT_OPEN_BROWSER = true; private static final String DEFAULT_BROWSER_MODE = BrowserMode.INTERNAL.toString(); private static final boolean DEFAULT_DEVELOPMENT_MODE = true; + public static final JakartaVersion DEFAULT_JAKARTA_VERSION = JakartaVersion.EE10; public static ILaunchConfigurationType getType() { @@ -102,6 +109,7 @@ public static void setDefaults( ILaunchConfigurationWorkingCopy config ) { config.setAttribute( SESSION_TIMEOUT, DEFAULT_SESSION_TIMEOUT ); config.setAttribute( OPEN_BROWSER, DEFAULT_OPEN_BROWSER ); config.setAttribute( BROWSER_MODE, DEFAULT_BROWSER_MODE ); + config.setAttribute( JAKARTA_VERSION, DEFAULT_JAKARTA_VERSION.toString() ); } private final ILaunchConfiguration config; @@ -291,6 +299,17 @@ public void setDevelopmentMode( boolean developmentMode ) { checkWorkingCopy(); workingCopy.setAttribute( DEVELOPMENT_MODE, developmentMode ); } + + public JakartaVersion getJakartaVersion() { + String attribute = getAttribute( JAKARTA_VERSION, DEFAULT_JAKARTA_VERSION.name() ); + return Enum.valueOf( JakartaVersion.class, attribute ); + } + + public void setJakartaVersion( JakartaVersion jakartaVersion ) { + checkNotNull( jakartaVersion, "jakartaVersion" ); //$NON-NLS-1$ + checkWorkingCopy(); + workingCopy.setAttribute( JAKARTA_VERSION, jakartaVersion.name() ); + } private static void checkNotNull( Object argument, String argumentName ) { if( argument == null ) { diff --git a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/delegate/RWTLaunchDelegate.java b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/delegate/RWTLaunchDelegate.java index a3006524..3d4342e7 100644 --- a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/delegate/RWTLaunchDelegate.java +++ b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/delegate/RWTLaunchDelegate.java @@ -22,10 +22,13 @@ import org.eclipse.rap.tools.launch.rwt.internal.config.RWTLaunchConfig; import org.eclipse.rap.tools.launch.rwt.internal.util.BundleFileLocator; import org.eclipse.rap.tools.launch.rwt.internal.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RWTLaunchDelegate extends JavaLaunchDelegate { + private static final Logger LOG = LoggerFactory.getLogger( RWTLaunchDelegate.class ); private static final String VMARG_JETTY_HOME = " -Djetty.home="; //$NON-NLS-1$ private static final String VMARG_DEVELOPMENT_MODE = " -Dorg.eclipse.rap.rwt.developmentMode="; //$NON-NLS-1$ @@ -72,6 +75,10 @@ public String[] getClasspath( ILaunchConfiguration configuration ) throws CoreEx list.add( BundleFileLocator.locate( "jakarta.servlet-api" ) ); //$NON-NLS-1$ list.add( BundleFileLocator.locate( "org.eclipse.jetty.ee10.servlet" ) ); //$NON-NLS-1$ list.add( BundleFileLocator.locate( "org.eclipse.jetty.ee10.webapp" ) ); //$NON-NLS-1$ + list.add( BundleFileLocator.locate( "org.eclipse.jetty.ee8.server" ) ); //$NON-NLS-1$ + list.add( BundleFileLocator.locate( "org.eclipse.jetty.ee8.security" ) ); //$NON-NLS-1$ + list.add( BundleFileLocator.locate( "org.eclipse.jetty.ee8.servlet" ) ); //$NON-NLS-1$ + list.add( BundleFileLocator.locate( "org.eclipse.jetty.ee8.webapp" ) ); //$NON-NLS-1$ list.add( BundleFileLocator.locate( "org.eclipse.jetty.server" ) ); //$NON-NLS-1$ list.add( BundleFileLocator.locate( "org.eclipse.jetty.security" ) ); //$NON-NLS-1$ list.add( BundleFileLocator.locate( "org.eclipse.jetty.http" ) ); //$NON-NLS-1$ @@ -93,8 +100,15 @@ public String getProgramArguments( ILaunchConfiguration configuration ) { String port = String.valueOf( launch.getPort() ); String contextPath = getContextPath(); String webAppDirectory = launch.getWebAppPath().getAbsolutePath(); - Object[] arguments = new Object[] { port, contextPath, webAppDirectory }; - return MessageFormat.format( "{0} {1} \"{2}\"", arguments ); //$NON-NLS-1$ + String jakartaVersion = RWTLaunchConfig.DEFAULT_JAKARTA_VERSION.name(); + try { + jakartaVersion = configuration.getAttribute( RWTLaunchConfig.JAKARTA_VERSION, + RWTLaunchConfig.DEFAULT_JAKARTA_VERSION.name() ); + } catch( CoreException exception ) { + LOG.error( exception.getLocalizedMessage(), exception ); + } + Object[] arguments = new Object[] { port, contextPath, webAppDirectory, jakartaVersion }; + return MessageFormat.format( "{0} {1} \"{2}\" \"{3}\"", arguments ); //$NON-NLS-1$ } @Override diff --git a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/jetty/JettyLauncher.java b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/jetty/JettyLauncher.java index d2e13973..c2da7074 100644 --- a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/jetty/JettyLauncher.java +++ b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/jetty/JettyLauncher.java @@ -10,8 +10,9 @@ ******************************************************************************/ package org.eclipse.rap.tools.launch.rwt.internal.jetty; -import org.eclipse.jetty.ee10.webapp.WebAppContext; + import org.eclipse.jetty.server.Server; +import org.eclipse.rap.tools.launch.rwt.internal.config.RWTLaunchConfig.JakartaVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,10 +24,18 @@ public class JettyLauncher { public static void main( String[] args ) { try { Server server = new Server( Integer.parseInt( args[ 0 ] ) ); - WebAppContext webapp = new WebAppContext(); - webapp.setContextPath( args[ 1 ] ); - webapp.setWar( args[ 2 ] ); - server.setHandler( webapp ); + JakartaVersion jakartaVersion = Enum.valueOf( JakartaVersion.class, args[ 3 ] ); + if( jakartaVersion == JakartaVersion.EE8 ) { + org.eclipse.jetty.ee8.webapp.WebAppContext webapp = new org.eclipse.jetty.ee8.webapp.WebAppContext(); + webapp.setContextPath( args[ 1 ] ); + webapp.setWar( args[ 2 ] ); + server.setHandler( webapp ); + } else { + org.eclipse.jetty.ee10.webapp.WebAppContext webapp = new org.eclipse.jetty.ee10.webapp.WebAppContext(); + webapp.setContextPath( args[ 1 ] ); + webapp.setWar( args[ 2 ] ); + server.setHandler( webapp ); + } server.start(); server.join(); } catch( Exception exception ) { diff --git a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/tab/ServerSettingsSection.java b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/tab/ServerSettingsSection.java index d7e67dc1..42405d8c 100644 --- a/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/tab/ServerSettingsSection.java +++ b/bundles/org.eclipse.rap.tools.launch.rwt/src/org/eclipse/rap/tools/launch/rwt/internal/tab/ServerSettingsSection.java @@ -13,6 +13,7 @@ import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.rap.tools.launch.rwt.internal.config.RWTLaunchConfig; +import org.eclipse.rap.tools.launch.rwt.internal.config.RWTLaunchConfig.JakartaVersion; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; import org.eclipse.swt.layout.GridData; @@ -28,6 +29,8 @@ public class ServerSettingsSection extends RWTLaunchTab { private Spinner spnSessionTimeout; private Button cbContextPath; private Text txtContextPath; + private Button rbEe8; + private Button rbEe10; public String getName() { return "Server Settings"; @@ -58,12 +61,28 @@ public void createControl( Composite parent ) { cbContextPath.setText( "Context pat&h:" ); cbContextPath.addSelectionListener( new UpdateConfigSelectionListener() ); txtContextPath = new Text( group, SWT.BORDER | SWT.SINGLE ); - GridDataFactory.fillDefaults().grab( true, false ).span( 3, 1 ).applyTo( txtContextPath ); + GridDataFactory.fillDefaults().grab( true, false ).applyTo( txtContextPath ); txtContextPath.addModifyListener( new UpdateConfigModifyListener() ); + Composite cJakartaVersion = createJakartaVersionPart( group ); + GridDataFactory.fillDefaults().grab( true, false ).span( 2, 1 ).indent( 25, 0 ).applyTo( cJakartaVersion ); updateEnablement(); setControl( group ); HelpContextIds.assign( getControl(), HelpContextIds.MAIN_TAB ); } + + private Composite createJakartaVersionPart( Composite parent ) { + Composite composite = new Composite( parent, SWT.NONE ); + composite.setLayout( new GridLayout( 3, false ) ); + Label lblServletPath = new Label( composite, SWT.NONE ); + lblServletPath.setText( "Jakarta Version:" ); + rbEe8 = new Button( composite, SWT.RADIO ); + rbEe8.setText( JakartaVersion.EE8.name() ); + rbEe8.addSelectionListener( new JakartaVersionSelectionListener() ); + rbEe10 = new Button( composite, SWT.RADIO ); + rbEe10.setText( JakartaVersion.EE10.name() ); + rbEe10.addSelectionListener( new JakartaVersionSelectionListener() ); + return composite; + } public void initializeFrom( RWTLaunchConfig launchConfig ) { cbManualPort.setSelection( launchConfig.getUseManualPort() ); @@ -72,6 +91,8 @@ public void initializeFrom( RWTLaunchConfig launchConfig ) { spnSessionTimeout.setSelection( launchConfig.getSessionTimeout() ); cbContextPath.setSelection( launchConfig.getUseManualContextPath() ); txtContextPath.setText( launchConfig.getContextPath() ); + rbEe8.setSelection( JakartaVersion.EE8.equals( launchConfig.getJakartaVersion() ) ); + rbEe10.setSelection( JakartaVersion.EE10.equals( launchConfig.getJakartaVersion() ) ); updateEnablement(); } @@ -82,6 +103,11 @@ public void performApply( RWTLaunchConfig launchConfig ) { launchConfig.setSessionTimeout( spnSessionTimeout.getSelection() ); launchConfig.setUseManualContextPath( cbContextPath.getSelection() ); launchConfig.setContextPath( txtContextPath.getText().trim() ); + if( rbEe8.getSelection() ) { + launchConfig.setJakartaVersion( JakartaVersion.EE8 ); + } else if( rbEe10.getSelection() ) { + launchConfig.setJakartaVersion( JakartaVersion.EE10 ); + } } private void updateEnablement() { @@ -102,5 +128,11 @@ public void modifyText( ModifyEvent event ) { updateLaunchConfigurationDialog(); } } + + private class JakartaVersionSelectionListener extends SelectionAdapter { + public void widgetSelected( SelectionEvent event ) { + updateLaunchConfigurationDialog(); + } + } }