You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/12/08 18:20:45 UTC

[GitHub] [netbeans] mbien commented on a diff in pull request #4822: Add Jakarta EE/Java EE support for Tomcat and TomEE

mbien commented on code in PR #4822:
URL: https://github.com/apache/netbeans/pull/4822#discussion_r1043669528


##########
enterprise/tomcat5/src/org/netbeans/modules/tomcat5/j2ee/TomcatPlatformImpl.java:
##########
@@ -456,43 +456,220 @@ public Set<J2eeModule.Type> getSupportedTypes() {
 
     @Override
     public Set<Profile> getSupportedProfiles() {
-        Set<Profile> profiles = new HashSet<>(5);
-        //if (!manager.isTomEE()) {
-            // TomEE is new and it actually does not support older specs (classloading separation etc).
-            // we will see if that's a problem for anybody
-            profiles.add(Profile.J2EE_13);
-            profiles.add(Profile.J2EE_14);
-            if (manager.isTomcat60() || manager.isAboveTomcat70()) {
-                profiles.add(Profile.JAVA_EE_5);
+        Set<Profile> profiles = new HashSet<Profile>(10);
+
+        if (manager.isTomEE()) {
+            // Only TomEE versions 8/9 of type Plus/PluME support full profile
+            if (manager.getTomEEType().ordinal() >= 3 ) {
+                switch (manager.getTomEEVersion()) {
+                    case TOMEE_90:
+                        profiles.add(Profile.JAKARTA_EE_9_1_FULL);
+                        break;
+                    case TOMEE_80:
+                        profiles.add(Profile.JAKARTA_EE_8_FULL);
+                        profiles.add(Profile.JAVA_EE_8_FULL);
+                        profiles.add(Profile.JAVA_EE_7_FULL);
+                        profiles.add(Profile.JAVA_EE_6_FULL);
+                        break;
+                    default:
+                        break;
+                }
+            }
+            switch (manager.getTomEEVersion()) {
+                case TOMEE_90:
+                    profiles.add(Profile.JAKARTA_EE_9_1_WEB);
+                    break;
+                case TOMEE_80:
+                    profiles.add(Profile.JAKARTA_EE_8_WEB);
+                    profiles.add(Profile.JAVA_EE_8_WEB);
+                    profiles.add(Profile.JAVA_EE_7_WEB);
+                    profiles.add(Profile.JAVA_EE_6_WEB);
+                    profiles.add(Profile.JAVA_EE_5);
+                    break;
+                case TOMEE_71:
+                case TOMEE_70:
+                    profiles.add(Profile.JAVA_EE_7_WEB);
+                    profiles.add(Profile.JAVA_EE_6_WEB);
+                    profiles.add(Profile.JAVA_EE_5);
+                    break;
+                case TOMEE_17:
+                case TOMEE_16:
+                case TOMEE_15:
+                    profiles.add(Profile.JAVA_EE_6_WEB);
+                    profiles.add(Profile.JAVA_EE_5);
+                    break;
+                default:
+                    break;
+            }
+        } else {
+            switch (manager.getTomcatVersion()) {
+//                case TOMCAT_101:
+//                    TODO: Add suport for Jakarta EE 10
+//                    profiles.add(Profile.JAKARTA_EE_10_WEB);
+//                    break;
+                case TOMCAT_100:
+                    profiles.add(Profile.JAKARTA_EE_9_1_WEB);
+                    profiles.add(Profile.JAKARTA_EE_9_WEB);
+                    break;
+                case TOMCAT_90:
+                    profiles.add(Profile.JAKARTA_EE_8_WEB);
+                    profiles.add(Profile.JAVA_EE_8_WEB);
+                    profiles.add(Profile.JAVA_EE_7_WEB);
+                    profiles.add(Profile.JAVA_EE_6_WEB);
+                    profiles.add(Profile.JAVA_EE_5);
+                case TOMCAT_80:
+                    profiles.add(Profile.JAVA_EE_7_WEB);
+                    profiles.add(Profile.JAVA_EE_6_WEB);
+                    profiles.add(Profile.JAVA_EE_5);
+                    break;
+                case TOMCAT_70:
+                    profiles.add(Profile.JAVA_EE_6_WEB);
+                    profiles.add(Profile.JAVA_EE_5);
+                    break;
+                case TOMCAT_60:
+                    profiles.add(Profile.JAVA_EE_5);
+                    break;
+                case TOMCAT_55:
+                case TOMCAT_50:
+                    profiles.add(Profile.J2EE_14);
+                    break;
+                default:
+                    break;
             }
-        //}
-        if (manager.isAboveTomcat70()) {
-            profiles.add(Profile.JAVA_EE_6_WEB);
-        }
-        if (manager.isTomcat80() || manager.isTomcat90()) {
-            profiles.add(Profile.JAVA_EE_7_WEB);
         }
         return profiles;
     }
     
     @Override
     public Set<String> getSupportedJavaPlatformVersions() {
-        Set<String> versions = new HashSet<>(6);
+        Set<String> versions = new HashSet<String>(14);
 
-        if (!manager.isTomcat90()) {
-            if (!manager.isTomcat80()) {
-                if (!manager.isTomcat70()) {
-                    if (!manager.isTomcat60()) {
-                        versions.add("1.4"); // NOI18N
-                        versions.add("1.5"); // NOI18N
-                    }
+        // TomEE has different supported Java versions
+        if (manager.isTomEE()) {
+            switch (manager.getTomEEVersion()) {
+                case TOMEE_90:
+                    versions.add("11"); // NOI18N
+                    versions.add("12"); // NOI18N
+                    versions.add("13"); // NOI18N
+                    versions.add("14"); // NOI18N
+                    versions.add("15"); // NOI18N
+                    versions.add("16"); // NOI18N
+                    versions.add("17"); // NOI18N
+                    versions.add("18"); // NOI18N
+                    versions.add("19"); // NOI18N
+                    versions.add("20"); // NOI18N

Review Comment:
   i would extract this to a utility method
   ```java
       private static Set<String> versionRange(int min, int max) {
           return IntStream.range(min, max+1)
                       .mapToObj((v) ->  v > 8 ? Integer.toString(v) : "1."+v)
                       .collect(Collectors.toSet());
       }
   ```
   this would make this easier to maintain since the upper version can be simply adjusted via a variable in one place. It is also significantly less code.



##########
enterprise/tomcat5/test/unit/src/org/netbeans/modules/tomcat5/TomcatFactoryTest.java:
##########
@@ -33,4 +35,34 @@ public TomcatFactoryTest(String name) {
     public void testOldCreate50MethodForAutoupdateModule() {
         assertNotNull(TomcatFactory.create50());
     }
+    
+    public void testTomEEtype() {
+        
+        Pattern TOMEE_JAR_PATTERN = Pattern.compile("tomee-common-(\\d+(\\.\\d+)*).*\\.jar"); // NOI18N
+        Pattern TOMEE_JAXRS_JAR_PATTERN = Pattern.compile("jettison-(\\d+(\\.\\d+)*).*\\.jar"); // NOI18N
+        Pattern TOMEE_WEBPROFILE_JAR_PATTERN = Pattern.compile("openejb-api-(\\d+(\\.\\d+)*).*\\.jar"); // NOI18N
+        Pattern TOMEE_MICROPROFILE_JAR_PATTERN = Pattern.compile("microprofile-config-api-(\\d+(\\.\\d+)*).*\\.jar"); // NOI18N
+        Pattern TOMEE_PLUS_JAR_PATTERN = Pattern.compile("activemq-protobuf-(\\d+(\\.\\d+)*).*\\.jar"); // NOI18N
+        Pattern TOMEE_PLUME_JAR_PATTERN = Pattern.compile("eclipselink-(\\d+(\\.\\d+)*).*\\.jar"); // NOI18N

Review Comment:
   Someone could update the factory without updating the copy in the tests. Can't the patterns be made package-private? If not I would still prefer using reflection in the test to grab their values over copy and paste.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists