You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by eb...@apache.org on 2020/04/07 00:56:15 UTC
[tomcat-jakartaee-migration] 03/10: Moved EESpecProfile to the top
level
This is an automated email from the ASF dual-hosted git repository.
ebourg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
commit 703262fce1cf10af87715696e38d3e6328594f0d
Author: Emmanuel Bourg <eb...@apache.org>
AuthorDate: Mon Apr 6 23:13:00 2020 +0200
Moved EESpecProfile to the top level
---
.../org/apache/tomcat/jakartaee/EESpecProfile.java | 44 ++++++++++++++++++++++
.../java/org/apache/tomcat/jakartaee/Util.java | 18 +--------
2 files changed, 45 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java b/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
new file mode 100644
index 0000000..3d77867
--- /dev/null
+++ b/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.tomcat.jakartaee;
+
+import java.util.regex.Pattern;
+
+/**
+ * Specification profile defining the replacements performed.
+ */
+public enum EESpecProfile {
+
+ TOMCAT("javax([/\\.](annotation|ejb|el|mail|persistence|security[/\\.]auth[/\\.]message|servlet|transaction|websocket))"),
+
+ EE("javax([/\\.](activation|annotation|decorator|ejb|el|enterprise|json|interceptor|inject|mail|persistence|"
+ + "security[/\\.]auth[/\\.]message|servlet|transaction|validation|websocket|ws[/\\.]rs|"
+ + "xml[/\\.](bind|namespace|rpc|soap|stream|ws|XMLConstants)))");
+
+ private Pattern pattern;
+
+ EESpecProfile(String pattern) {
+ this.pattern = Pattern.compile(pattern);
+ }
+
+ /**
+ * Return the replacement pattern for this profile.
+ */
+ public Pattern getPattern() {
+ return pattern;
+ }
+}
diff --git a/src/main/java/org/apache/tomcat/jakartaee/Util.java b/src/main/java/org/apache/tomcat/jakartaee/Util.java
index 2a2ae81..b879e92 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/Util.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/Util.java
@@ -22,18 +22,7 @@ import java.util.regex.Pattern;
public class Util {
- public enum EESpecProfile { TOMCAT, EE };
-
- private static final Pattern TOMCAT_PATTERN = Pattern.compile(
- "javax([/\\.](annotation|ejb|el|mail|persistence|security[/\\.]auth[/\\.]message|servlet|transaction|websocket))");
-
- private static final Pattern EE_PATTERN = Pattern.compile(
- "javax([/\\.](activation|annotation|decorator|ejb|el|enterprise|json|interceptor|inject|mail|persistence|"
- + "security[/\\.]auth[/\\.]message|servlet|transaction|validation|websocket|ws[/\\.]rs|"
- + "xml[/\\.](bind|namespace|rpc|soap|stream|ws|XMLConstants)))");
-
private static EESpecProfile profile = EESpecProfile.TOMCAT;
- private static Pattern pattern = TOMCAT_PATTERN;
/**
* Set the Jakarta EE specifications that should be used.
@@ -49,11 +38,6 @@ public class Util {
*/
public static void setEESpecProfile(EESpecProfile profile) {
Util.profile = profile;
- if (profile == EESpecProfile.TOMCAT) {
- pattern = TOMCAT_PATTERN;
- } else if (profile == EESpecProfile.EE) {
- pattern = EE_PATTERN;
- }
}
/**
@@ -82,7 +66,7 @@ public class Util {
public static String convert(String name) {
- Matcher m = pattern.matcher(name);
+ Matcher m = profile.getPattern().matcher(name);
return m.replaceAll("jakarta$1");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org