use of org.jboss.weld.environment.se.ContainerLifecycleObserver.afterBeanDiscovery in project core by weld.
the class WeldBuilderTest method testInterceptorBuilder.
@Test
public void testInterceptorBuilder() {
try (WeldContainer container = new Weld().disableDiscovery().beanClasses(Coorge.class, BuilderInterceptorBinding.class).addContainerLifecycleObserver(ContainerLifecycleObserver.afterBeanDiscovery((e) -> e.addInterceptor().addBinding(new BuilderInterceptorBinding.BuilderInterceptorBindingLiteral()).priority(2500).intercept(InterceptionType.AROUND_INVOKE, invocationContext -> {
try {
Integer result = ((Integer) invocationContext.proceed());
return result + 10;
} catch (Exception exception) {
exception.printStackTrace();
}
return null;
}))).initialize()) {
Coorge coorge = container.select(Coorge.class).get();
assertEquals(coorge.ping(), 11);
}
}
Aggregations