[
https://issues.jboss.org/browse/CDI-686?page=com.atlassian.jira.plugin.sy...
]
Martin Kouba commented on CDI-686:
----------------------------------
I think I understand the use case described by [~rmannibucau] and [~tandraschko], e.g.
somethig like:
{code:java}
interface MyService {}
class MyServiceProducer {
@Produces
MyService produce(InterceptionFactory<MyService> factory, ServiceLocator locator)
{
factory.configure().add(Monitor.Literal.INSTANCE);
// Lookup a MyService implementation...
return factory.createInterceptedInstance(locator.lookup(MyService.class));
}
}
{code}
However, I'm afraid it's too late for this kind of discussions. Since we would
have to carefully adapt the inheritance rules (as defined in "4. Inheritance and
specialization") for this particular use case. Note that _"Type-level metadata
is never inherited from interfaces implemented by a bean."_.
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)