[cdi-dev] [JBoss JIRA] (CDI-686) Could InterceptionFactory accept an interface as type parameter
Romain Manni-Bucau (JIRA)
issues at jboss.org
Thu Feb 23 03:54:00 EST 2017
[ https://issues.jboss.org/browse/CDI-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13367912#comment-13367912 ]
Romain Manni-Bucau commented on CDI-686:
----------------------------------------
Hmm, isnt one of the goals of this factory to make custom beans (Bean<>) easily integrated with CDI interceptors? If so it is common to have java.lang.reflect based proxies there (see deltaspike ones for instance) and it is very nice and smooth to be able to reuse cdi there.
Here a trivial but obvious example: take a repository like proxy based implementation, don't you want to integrate it with jcache which has its own interceptor without coding more than the factory itself? Today it requires to either be bound to a jcache implementation or reimplement the interceptor chain logic from the container which is a pain.
> Could InterceptionFactory accept an interface as type parameter
> ---------------------------------------------------------------
>
> Key: CDI-686
> URL: https://issues.jboss.org/browse/CDI-686
> Project: CDI Specification Issues
> Issue Type: Clarification
> Affects Versions: 2.0 .Final
> Reporter: Antoine Sabot-Durand
>
> If you take this code:
> {code:java}
> @Produces
> public List<Object> produceList(InterceptionFactory<List<Object>> interceptionFactory) {
> interceptionFactory.ignoreFinalMethods().configure().filterMethods((m) -> {
> if (m.getJavaMember().getName().equals("add")
> && m.getJavaMember().getParameterCount() == 1) {
> return true;
> }
> return false;
> }).findFirst().get().add(Monitor.Literal.INSTANCE);
> return interceptionFactory.createInterceptedInstance(new ArrayList<>());
> }
> {code}
> Parameterized type for injected {{InterceptionFactory}} is an interface {{List<Object>}}, so when calling {{configure()}}, user will work with an {{AnnotatedTypeConfigurator<List<Object>>}} to apply interceptor binding.
> In a standard interceptor usage, interceptor binding on interface are ignored (even if they have {{@Inherited}} annotation), so doing it with {{InterceptionFactory}} could be confusing for some user.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the cdi-dev
mailing list