File tree Expand file tree Collapse file tree
jetty-ee-common/src/main/java/org/eclipse/jetty/ee/common
jetty-ee-osgi/jetty-ee-osgi-boot/src/main/java/org/eclipse/jetty/ee/osgi/boot
jetty-ee-servlet/src/main/java
org/eclipse/jetty/ee/servlet
jetty-ee-webapp/src/main/java/org/eclipse/jetty/ee/webapp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //
2+ // ========================================================================
3+ // Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
4+ //
5+ // This program and the accompanying materials are made available under the
6+ // terms of the Eclipse Public License v. 2.0 which is available at
7+ // https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
8+ // which is available at https://www.apache.org/licenses/LICENSE-2.0.
9+ //
10+ // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
11+ // ========================================================================
12+ //
13+
14+ package org .eclipse .jetty .ee .common ;
15+
16+ public enum EnterpriseEditionVersion
17+ {
18+ ee10 (10 ),
19+ ee11 (11 );
20+
21+ public static final EnterpriseEditionVersion currentVersion = initEnterpriseEditionVersion ();
22+
23+ public static EnterpriseEditionVersion getEnterpriseEditionVersion ()
24+ {
25+ return currentVersion ;
26+ }
27+
28+ private final int version ;
29+
30+ EnterpriseEditionVersion (int version )
31+ {
32+ this .version = version ;
33+ }
34+
35+ public int version ()
36+ {
37+ return version ;
38+ }
39+
40+ private static EnterpriseEditionVersion initEnterpriseEditionVersion ()
41+ {
42+ try
43+ {
44+ return switch (ServletApiVersion .getServletApiVersion ())
45+ {
46+ case v6_0 -> ee10 ;
47+ case v6_1 -> ee11 ;
48+ default -> null ;
49+ };
50+ }
51+ catch (Throwable e )
52+ {
53+ throw new RuntimeException (e );
54+ }
55+ }
56+ }
Original file line number Diff line number Diff line change @@ -27,9 +27,8 @@ public enum ServletApiVersion
2727 v6_0 ("6.0" ),
2828 v6_1 ("6.1" );
2929
30- public static ServletApiVersion currentVersion = initServletApiVersion ();
30+ public static final ServletApiVersion currentVersion = initServletApiVersion ();
3131
32- private static Logger LOG = LoggerFactory .getLogger (ServletApiVersion .class );
3332 private final String version ;
3433 private final int major ;
3534 private final int minor ;
@@ -85,7 +84,7 @@ public static ServletApiVersion initServletApiVersion()
8584 }
8685 return ServletApiVersion .from (specificationVersion );
8786 }
88- catch (ClassNotFoundException e )
87+ catch (ClassNotFoundException | NoClassDefFoundError e )
8988 {
9089 throw new IllegalStateException ("Cannot detect servlet API version" , e );
9190 }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public enum WebsocketApiVersion
2626 v2_1 ("2.1" ),
2727 v2_2 ("2.2" );
2828
29- public static WebsocketApiVersion currentVersion = initWebsocketApiVersion ();
29+ public static final WebsocketApiVersion currentVersion = initWebsocketApiVersion ();
3030
3131 private static Logger LOG = LoggerFactory .getLogger (WebsocketApiVersion .class );
3232 private final String version ;
@@ -84,7 +84,7 @@ public static WebsocketApiVersion initWebsocketApiVersion()
8484 }
8585 return WebsocketApiVersion .from (specificationVersion );
8686 }
87- catch (ClassNotFoundException e )
87+ catch (ClassNotFoundException | NoClassDefFoundError e )
8888 {
8989 throw new IllegalStateException ("Cannot detect websocket API version" , e );
9090 }
Original file line number Diff line number Diff line change 2121import java .util .List ;
2222import java .util .Map ;
2323
24+ import org .eclipse .jetty .ee .common .EnterpriseEditionVersion ;
2425import org .eclipse .jetty .ee .common .ServletApiVersion ;
2526import org .eclipse .jetty .ee .common .WebAppClassLoader ;
2627import org .eclipse .jetty .ee .webapp .Configuration ;
@@ -55,11 +56,7 @@ public class EEActivator extends AbstractEEActivator
5556{
5657 private static final Logger LOG = LoggerFactory .getLogger (EEActivator .class );
5758
58- public static final String ENVIRONMENT = switch (ServletApiVersion .getServletApiVersion ()){
59- case v6_0 -> "ee10" ;
60- case v6_1 -> "ee11" ;
61- default -> null ;
62- };
59+ public static final String ENVIRONMENT = EnterpriseEditionVersion .getEnterpriseEditionVersion ().name ();
6360
6461 @ Override
6562 public String getEnvironment ()
Original file line number Diff line number Diff line change 3333 requires static java .security .jgss ;
3434 // Only required if using JDBCLoginService.
3535 requires static java .sql ;
36+ requires org .eclipse .jetty .ee .common ;
3637
3738 exports org .eclipse .jetty .ee .servlet ;
3839 exports org .eclipse .jetty .ee .servlet .listener ;
Original file line number Diff line number Diff line change 6868import jakarta .servlet .http .HttpSessionBindingListener ;
6969import jakarta .servlet .http .HttpSessionIdListener ;
7070import jakarta .servlet .http .HttpSessionListener ;
71+ import org .eclipse .jetty .ee .common .EnterpriseEditionVersion ;
7172import org .eclipse .jetty .ee .servlet .ServletContextResponse .EncodingFrom ;
7273import org .eclipse .jetty .ee .servlet .ServletContextResponse .OutputType ;
7374import org .eclipse .jetty .ee .servlet .security .ConstraintAware ;
132133public class ServletContextHandler extends ContextHandler
133134{
134135 private static final Logger LOG = LoggerFactory .getLogger (ServletContextHandler .class );
135- public static final Environment ENVIRONMENT = Environment .ensure ("ee" , ServletContextHandler .class );
136+ public static final Environment ENVIRONMENT = Environment .ensure (EnterpriseEditionVersion . getEnterpriseEditionVersion (). name () , ServletContextHandler .class );
136137 /**
137138 * @deprecated Use {@link ServletContextHandler#ENVIRONMENT} instead.
138139 */
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ public static XmlParser newParser(boolean validating)
9797
9898 protected static void addDescriptorCatalog (XmlParser xmlParser ) throws IllegalStateException
9999 {
100- String catalogName = "catalog-%s .xml" . formatted ( ServletContextHandler . ENVIRONMENT . getName ()) ;
100+ String catalogName = "catalog-ee .xml" ;
101101 URL url = WebDescriptor .class .getResource (catalogName );
102102 if (url == null )
103103 throw new IllegalStateException ("Catalog not found: %s/%s" .formatted (WebDescriptor .class .getPackageName (), catalogName ));
You can’t perform that action at this time.
0 commit comments