Skip to content

Commit

Permalink
Rework DefaultMethodTest to use InterceptionFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn authored and Ladicek committed Jun 21, 2023
1 parent 38185b6 commit 57af00e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 208 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ public void rememberInterfaces(@Observes @WithAnnotations(RegisterInterfaceBased
}
}

@SuppressWarnings({ "rawtypes", "unchecked" })
public void registerBeans(@Observes AfterBeanDiscovery abd, BeanManager beanManager) {
for (Class<?> iface : interfaces) {
for (Class iface : interfaces) {
abd.addBean()
.beanClass(iface)
.types(iface)
.scope(Dependent.class)
.qualifiers(Default.Literal.INSTANCE, Any.Literal.INSTANCE, InterfaceBased.Literal.INSTANCE)
.createWith(ctx -> {
Object target = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
Object instance = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[] { iface }, InterfaceBasedExtension::invoke);
return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[] { iface }, new InterceptingInvocationHandler(iface, target, beanManager));
return beanManager.createInterceptionFactory(ctx, iface)
.createInterceptedInstance(instance);
});
LOG.info("Registered bean for " + iface);
}
Expand Down

0 comments on commit 57af00e

Please sign in to comment.