Skip to content

Commit

Permalink
Merge fbff5a4 into 34d7c72
Browse files Browse the repository at this point in the history
  • Loading branch information
blasss committed Jul 23, 2022
2 parents 34d7c72 + fbff5a4 commit fab3ebe
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ target
*.iml
*.ipr
*.iws
/bin/
10 changes: 5 additions & 5 deletions src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.security.ProtectionDomain;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.Constant;
import org.apache.bcel.classfile.ConstantUtf8;
Expand Down Expand Up @@ -100,10 +99,10 @@ protected void convertInternal(String path, InputStream src, OutputStream dest,
// Jakarta EE specification classes that exist in the container
String[] split = newString.split(";|<");
for (String current : split) {
int pos = current.indexOf("jakarta/");
int pos = current.indexOf(profile.getTarget() + "/");
boolean dotMode = false;
if (pos < 0) {
pos = current.indexOf("jakarta.");
pos = current.indexOf(profile.getTarget() + ".");
dotMode = true;
}
if (pos >= 0) {
Expand All @@ -115,14 +114,15 @@ protected void convertInternal(String path, InputStream src, OutputStream dest,
if (loader.getResource(resourceName) == null) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, sm.getString("classConverter.skipName",
profile.getSource(),
current.substring(pos).replace('/','.')));
}
// Cancel the replacement as the replacement does not exist
String originalFragment;
if (dotMode) {
originalFragment = current.replace("jakarta.", "javax.");
originalFragment = current.replace(profile.getTarget() + ".", profile.getSource() + ".");
} else {
originalFragment = current.replace("jakarta/", "javax/");
originalFragment = current.replace(profile.getTarget() + "/", profile.getSource() + "/");
}
newString = newString.replace(current, originalFragment);
}
Expand Down
49 changes: 45 additions & 4 deletions src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
*/
public enum EESpecProfile {

TOMCAT("javax([/\\.](annotation(?![/\\.]processing)" +
TOMCAT("javax", "jakarta",
"javax([/\\.](annotation(?![/\\.]processing)" +
"|ejb" +
"|el" +
"|mail" +
Expand All @@ -34,7 +35,33 @@ public enum EESpecProfile {
"|transaction(?![/\\.]xa)" +
"|websocket))"),

EE("javax([/\\.](activation" +
EE("javax", "jakarta",
"javax([/\\.](activation" +
"|annotation(?![/\\.]processing)" +
"|batch" +
"|decorator" +
"|ejb" +
"|el" +
"|enterprise" +
"|faces" +
"|jms" +
"|json" +
"|jws" +
"|interceptor" +
"|inject" +
"|mail" +
"|management[/\\.]j2ee" +
"|persistence" +
"|resource" +
"|security[/\\.](auth[/\\.]message|enterprise|jacc)" +
"|servlet" +
"|transaction(?![/\\.]xa)" +
"|validation" +
"|websocket" +
"|ws[/\\.]rs" +
"|xml[/\\.](bind|soap|ws)))"),
JEE8("jakarta", "javax",
"jakarta([/\\.](activation" +
"|annotation(?![/\\.]processing)" +
"|batch" +
"|decorator" +
Expand All @@ -59,14 +86,28 @@ public enum EESpecProfile {
"|ws[/\\.]rs" +
"|xml[/\\.](bind|soap|ws)))");

private String source;
private String target;
private Pattern pattern;

EESpecProfile(String pattern) {
EESpecProfile(String source, String target, String pattern) {
this.source = source;
this.target = target;
this.pattern = Pattern.compile(pattern);
}

public String convert(String name) {
Matcher m = pattern.matcher(name);
return m.replaceAll("jakarta$1");
return m.replaceAll(target + "$1");
}

public String getSource()
{
return source;
}

public String getTarget()
{
return target;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

classConverter.converted=Migrated class [{0}]
classConverter.noConversion=No conversion necessary for [{0}]
classConverter.skipName=Skip conversion of class usage from the javax namespace to [{0}] as it is not accessible to the classloader
classConverter.skipName=Skip conversion of class usage from the [{0}] namespace to [{1}] as it is not accessible to the classloader

migration.archive.complete=Migration finished for archive [{0}]
migration.archive.memory=Migration starting for archive [{0}] using in memory copy
Expand All @@ -39,6 +39,7 @@ where options includes:\n\
\ -profile=<profile name>\n\
\ TOMCAT (default) to convert Java EE APIs provided by Tomcat\n\
\ EE to convert all Java EE APIs\n\
\ JEE8 to convert back to old Java EE8 APIs\n\
\ -zipInMemory\n\
\ By default zip format archives (.zip, jar, .war, .ear, etc.)\n\
\ are processed as streams. This is more efficient but is not\n\
Expand Down

0 comments on commit fab3ebe

Please sign in to comment.