[
https://issues.jboss.org/browse/CDI-686?page=com.atlassian.jira.plugin.sy...
]
Matej Novotny commented on CDI-686:
-----------------------------------
I have taken a stab at this with Weld 3.1.0.Final and managed to come up with a working
prototype that can base {{InterceptionFactory}} off an interface while providing even
unproxyable instance in the end. So it's definitely possible yet comes with many
question marks attached. Here are some from the top of my head with my thoughts on them:
* What about the interceptor binding(s) on the implementation class? Do you retain them or
toss them away?
** IMO toss away, since it can be unproxyable, there is no reason to have them there in
the first place
* What about binding on interface itself?
** There is a possibility that the interface has some bindings, but CDI disregards
annotations on interfaces in general, I would do the same here
** Accepting those would also introduce a problem of clashes in values if you try to
programatically add the same annotation that is already present on the interface
* What about hierarchies of interfaces - what if I add a class-level binding
programatically, does it apply to methods from this interface's predecessors that
weren't overriden?
** Here I honestly don't know, I went with _no_ in the first draft just because it
required extra magic to make that happen and it's a corner case
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
Assignee: Antoine Sabot-Durand
Priority: Major
Fix For: 2.0 .Final
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.12.1#712002)