Skip to content

Commit 4e4b8ae

Browse files
committed
Support AOPTransactionScope for module path support
Feature toggle to use AOPTransactionScope rather than HelpScopeTrans for Ebean 14.9.0 and later
1 parent 7b96e7d commit 4e4b8ae

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

ebean-agent/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<groupId>io.ebean</groupId>
1111
<artifactId>ebean-agent</artifactId>
12-
<version>14.8.2</version>
12+
<version>14.9.0-RC1</version>
1313
<packaging>jar</packaging>
1414

1515
<name>ebean-agent</name>

ebean-agent/src/main/java/io/ebean/enhance/common/EnhanceConstants.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ interface Jakarta {
6565
String L_STRING = "Ljava/lang/String;";
6666
String L_OBJECT = "Ljava/lang/Object;";
6767
String L_INTERCEPT = "Lio/ebean/bean/EntityBeanIntercept;";
68-
String L_HELPSCOPETRANS = "Lio/ebeaninternal/api/HelpScopeTrans;";
68+
String HELPSCOPETRANS = "io/ebeaninternal/api/HelpScopeTrans";
69+
String AOPTRANSACTIONSCOPE = "io/ebean/plugin/AOPTransactionScope";
70+
6971
String L_DRAFT = "Lio/ebean/annotation/Draft;";
7072
String C_TXSCOPE = "io/ebean/TxScope";
7173
String C_TXTYPE = "io/ebean/annotation/TxType";

ebean-agent/src/main/java/io/ebean/enhance/common/EnhanceContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ public boolean fluidQueryBuilders() {
498498
return enhancementVersion >= 148;
499499
}
500500

501+
public boolean useAopTransactionScope() {
502+
return enhancementVersion >= 149;
503+
}
504+
501505
public ProfileLineNumberMode profileLineMode() {
502506
return profileLineNumberMode;
503507
}

ebean-agent/src/main/java/io/ebean/enhance/transactional/ClassAdapterTransactional.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ boolean isEnableProfileLocation() {
341341
return enhanceContext.isEnableProfileLocation();
342342
}
343343

344+
boolean useAopTransactionScope() {
345+
return enhanceContext.useAopTransactionScope();
346+
}
347+
344348
int nextQueryProfileLocation() {
345349
return queryProfileCount++;
346350
}

ebean-agent/src/main/java/io/ebean/enhance/transactional/MethodAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ class MethodAdapter extends FinallyAdapter implements EnhanceConstants, Opcodes
2525

2626
private static final String TX_FIELD_PREFIX = ClassAdapterTransactional.TX_FIELD_PREFIX;
2727
private static final Type txScopeType = Type.getType("L" + C_TXSCOPE + ";");
28-
private static final Type helpScopeTrans = Type.getType(L_HELPSCOPETRANS);
2928

3029
private final AnnotationInfo annotationInfo;
3130
private final ClassAdapterTransactional classAdapter;
3231
private final ProfileMethodInstruction profileMethod;
32+
private final String aopTransactionScope;
3333
private boolean transactional;
3434
private int posTxScope;
3535

3636
MethodAdapter(ClassAdapterTransactional classAdapter, final MethodVisitor mv, final int access, final String name, final String desc) {
3737
super(mv, access, name, desc);
3838
this.classAdapter = classAdapter;
39+
this.aopTransactionScope = classAdapter.useAopTransactionScope() ? AOPTRANSACTIONSCOPE : HELPSCOPETRANS;
3940
this.profileMethod = new ProfileMethodInstruction(classAdapter, mv, name);
4041
// inherit from class level Transactional annotation
4142
AnnotationInfo parentInfo = classAdapter.getClassAnnotationInfo();
@@ -314,11 +315,10 @@ protected void onMethodEnter() {
314315
}
315316

316317
mv.visitVarInsn(ALOAD, posTxScope);
317-
mv.visitMethodInsn(INVOKESTATIC, helpScopeTrans.getInternalName(), "enter", "("
318+
mv.visitMethodInsn(INVOKESTATIC, aopTransactionScope, "enter", "("
318319
+ txScopeType.getDescriptor() + ")V", false);
319320
}
320321

321-
322322
@Override
323323
protected void onFinally(int opcode) {
324324
if (!transactional) {
@@ -337,7 +337,7 @@ protected void onFinally(int opcode) {
337337
box(getReturnType());
338338
}
339339
visitIntInsn(SIPUSH, opcode);
340-
visitMethodInsn(INVOKESTATIC, helpScopeTrans.getInternalName(), "exit", "(Ljava/lang/Object;I)V", false);
340+
visitMethodInsn(INVOKESTATIC, aopTransactionScope, "exit", "(Ljava/lang/Object;I)V", false);
341341
}
342342

343343
}

0 commit comments

Comments
 (0)