forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
170 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
import org.objectweb.asm.Opcodes; | ||
|
||
/** | ||
* | ||
* | ||
* @author Martin Kouba | ||
* @author Michal Szynkiewicz, [email protected] | ||
*/ | ||
|
@@ -186,6 +186,13 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str | |
classLevelBindings, bytecodeTransformerConsumer, transformUnproxyableClasses)); | ||
} | ||
} | ||
for (DotName i : classInfo.interfaceNames()) { | ||
ClassInfo interfaceInfo = getClassByName(beanDeployment.getIndex(), i); | ||
if (interfaceInfo != null) { | ||
finalMethodsFoundAndNotChanged.addAll(addInterceptedMethodCandidates(beanDeployment, interfaceInfo, candidates, | ||
classLevelBindings, bytecodeTransformerConsumer, transformUnproxyableClasses)); | ||
} | ||
} | ||
return finalMethodsFoundAndNotChanged; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/defaultmethod/ABinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.quarkus.arc.test.interceptors.defaultmethod; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import javax.interceptor.InterceptorBinding; | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
public @interface ABinding { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...tests/src/test/java/io/quarkus/arc/test/interceptors/defaultmethod/DefaultMethodBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.quarkus.arc.test.interceptors.defaultmethod; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
@ABinding | ||
public class DefaultMethodBean implements DefaultMethodInterface { | ||
|
||
public String hello() { | ||
return "hello"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...est/java/io/quarkus/arc/test/interceptors/defaultmethod/DefaultMethodInterceptorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.arc.test.interceptors.defaultmethod; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.ArcContainer; | ||
import io.quarkus.arc.InstanceHandle; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class DefaultMethodInterceptorTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(ABinding.class, DefaultMethodBean.class, | ||
DefaultMethodInterface.class, MessageInterceptor.class); | ||
|
||
@Test | ||
public void testInterception() { | ||
ArcContainer arc = Arc.container(); | ||
|
||
InstanceHandle<DefaultMethodBean> handle = arc.instance(DefaultMethodBean.class); | ||
DefaultMethodBean simpleBean = handle.get(); | ||
Assertions.assertEquals("intercepted:hello", simpleBean.hello()); | ||
Assertions.assertEquals("intercepted:default method", simpleBean.defaultMethod()); | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
.../src/test/java/io/quarkus/arc/test/interceptors/defaultmethod/DefaultMethodInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.arc.test.interceptors.defaultmethod; | ||
|
||
public interface DefaultMethodInterface { | ||
|
||
default String defaultMethod() { | ||
return "default method"; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ests/src/test/java/io/quarkus/arc/test/interceptors/defaultmethod/MessageInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.quarkus.arc.test.interceptors.defaultmethod; | ||
|
||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
@ABinding | ||
@Interceptor | ||
public class MessageInterceptor { | ||
|
||
@AroundInvoke | ||
public Object invoke(InvocationContext context) throws Exception { | ||
return "intercepted:" + context.proceed(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/Beer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.quarkus.it.panache; | ||
|
||
import javax.persistence.Entity; | ||
|
||
import io.quarkus.hibernate.orm.panache.PanacheEntity; | ||
|
||
@Entity | ||
public class Beer extends PanacheEntity { | ||
|
||
public String name; | ||
} |
16 changes: 16 additions & 0 deletions
16
...ation-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/BeerRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.it.panache; | ||
|
||
import java.util.List; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.transaction.Transactional; | ||
|
||
import io.quarkus.hibernate.orm.panache.PanacheRepository; | ||
|
||
@ApplicationScoped | ||
@Transactional | ||
public class BeerRepository implements PanacheRepository<Beer> { | ||
public List<Beer> findOrdered() { | ||
return find("ORDER BY name").list(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ibernate-orm-panache/src/test/java/io/quarkus/it/panache/TransactionalRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.quarkus.it.panache; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class TransactionalRepositoryTest { | ||
|
||
@Inject | ||
BeerRepository beerRepository; | ||
|
||
@Test | ||
public void testTransactionalRepository() { | ||
Beer b = new Beer(); | ||
b.name = "IPA"; | ||
beerRepository.persist(b); | ||
|
||
Assertions.assertEquals(1, beerRepository.count()); | ||
} | ||
|
||
} |