Interceptor bindings from interceptor when using 2.0 interception factory
by arjan tijms
Hi,
Normally a workaround to get the interceptor bindings from within an
Interceptor is to inspect the target and/or the injected intercepted bean.
However, when adding an interceptor via the new CDI 2.0 interception
factory, things become a bit more muddy.
See e.g.
https://github.com/javaee-samples/javaee8-samples/blob/master/cdi/interce...
Weld has the following method to get the bindings from the
InvocationContext:
Set<Annotation> bindings = (Set<Annotation>)
invocationContext.getContextData().get("org.jboss.weld.interceptor.bindings");
But this is obviously non-standard.
Is there a standard way to get the bindings? Perhaps getting hold of the
Bean<T> that represents the current Interceptor?
Kind regards,
Arjan Tijms
7 years, 2 months
Moving build-in bean for Principal to Java EE Security?
by arjan tijms
Hi,
I wonder, wouldn't it be a good idea to let JSR 375 take ownership of
the build-in
bean in the Java EE part of CDI for Principal?
The CDI spec proposed to the servlet spec to take ownership of the build-in
beans for the Servlet owned artefacts (such as HttpServletRequest) before.
Kind regards
Arjan Tijms
7 years, 2 months
[JBoss JIRA] (CDI-718) Bean creation and dependency injection should not be performed before AfterDeploymentValidation
by Martin Kouba (JIRA)
Martin Kouba created CDI-718:
--------------------------------
Summary: Bean creation and dependency injection should not be performed before AfterDeploymentValidation
Key: CDI-718
URL: https://issues.jboss.org/browse/CDI-718
Project: CDI Specification Issues
Issue Type: Clarification
Reporter: Martin Kouba
Fix For: 2.1 (Discussion)
The spec is clear that it is not allowed to invoke {{BeanManager.getReference()}}, {{BeanManager.getInjectableReference()}} and {{BeanManager.createInstance()}} before {{AfterDeploymentValidation}}. I.e. it could be safely used during {{AfterDeploymentValidation}} and after the application initialization finished. The reason is that before ADV the set of beans/interceptors/decorators may not be complete and extensions can still affect the resolution.
However, using {{InjectionTarget}}, {{UnmanagedInstance}} and {{Contextual.create()}} has the same risks. I think we should clarify the usage so that the spec is consistent.
WRT backward compatibility - note that the container is permitted to define a non-portable mode to overcome problems with legacy applications not using CDI SPI properly.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 2 months
[JBoss JIRA] (CDI-610) Add API to obtain current injection point from Bean#create
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-610?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba edited comment on CDI-610 at 9/20/17 2:58 AM:
-----------------------------------------------------------
Maybe we don't need to extend the API but instead clarify that for a {{@Dependent}} bean it should be possible to obtain {{InjectionPoint}} from within {{Contextual.create()}} (e.g. using [BeanManager.createInstance().select(InjectionPoint.class).get()|https://g...]) and during invocation of a callback specified by {{BeanConfigurator.produceWith()}} (e.g. https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/o...).
Note that {{CreationalContext}} is currently bound to a bean instance, not an injection point, e.g. an instance might be reused when resolving all injection points of a bean instance. (of course this is just an impl detail)
was (Author: mkouba):
Maybe we don't need to extend the API but instead clarify that for a {{@Dependent}} bean it should be possible to obtain {{InjectionPoint}} from within {{Contextual.create()}} (e.g. using {{BeanManager.createInstance().select(InjectionPoint.class).get()}}) and during invocation of a callback specified by {{BeanConfigurator.produceWith()}} (https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/o...).
Note that {{CreationalContext}} is currently bound to a bean instance, not an injection point, e.g. an instance might be reused when resolving all injection points of a bean instance. (of course this is just an impl detail)
> Add API to obtain current injection point from Bean#create
> ----------------------------------------------------------
>
> Key: CDI-610
> URL: https://issues.jboss.org/browse/CDI-610
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Portable Extensions
> Reporter: arjan tijms
>
> There's currently not a clear way on how to obtain the *current* injection point (if any) from {{Bean<T>#create}}.
> A previously somewhat accepted way (though not specified) was:
> {code}
> Bean<? extends Object> bean = beanManager.resolve(beanManager.getBeans(InjectionPoint.class));
> InjectionPoint injectionPoint = (InjectionPoint) beanManager.getReference(bean, InjectionPoint.class, creationalContext);
> {code}
> This however broke in some version of Weld.
> Since getting the injection point is an often used feature in producers, I'd like to propose to introduce an easy API for this, so {{Bean<T>}} implementations can use this just as easily. E.g. something like: {{BeanManager#getCurrentInjectionPoint()}}.
> Also see: http://cdi-development-mailing-list.1064426.n5.nabble.com/Getting-injecti...
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 3 months
[JBoss JIRA] (CDI-610) Add API to obtain current injection point from Bean#create
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-610?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-610:
----------------------------------
Maybe we don't need to extend the API but instead clarify that for a {{@Dependent}} bean it should be possible to obtain {{InjectionPoint}} from within {{Contextual.create()}} (e.g. using {{BeanManager.createInstance().select(InjectionPoint.class).get()}}) and during invocation of a callback specified by {{BeanConfigurator.produceWith()}} (https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/o...).
Note that {{CreationalContext}} is currently bound to a bean instance, not an injection point, e.g. an instance might be reused when resolving all injection points of a bean instance. (of course this is just an impl detail)
> Add API to obtain current injection point from Bean#create
> ----------------------------------------------------------
>
> Key: CDI-610
> URL: https://issues.jboss.org/browse/CDI-610
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Portable Extensions
> Reporter: arjan tijms
>
> There's currently not a clear way on how to obtain the *current* injection point (if any) from {{Bean<T>#create}}.
> A previously somewhat accepted way (though not specified) was:
> {code}
> Bean<? extends Object> bean = beanManager.resolve(beanManager.getBeans(InjectionPoint.class));
> InjectionPoint injectionPoint = (InjectionPoint) beanManager.getReference(bean, InjectionPoint.class, creationalContext);
> {code}
> This however broke in some version of Weld.
> Since getting the injection point is an often used feature in producers, I'd like to propose to introduce an easy API for this, so {{Bean<T>}} implementations can use this just as easily. E.g. something like: {{BeanManager#getCurrentInjectionPoint()}}.
> Also see: http://cdi-development-mailing-list.1064426.n5.nabble.com/Getting-injecti...
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 3 months
[JBoss JIRA] (CDI-610) Add API to obtain current injection point from Bean#create
by arjan tijms (JIRA)
[ https://issues.jboss.org/browse/CDI-610?page=com.atlassian.jira.plugin.sy... ]
arjan tijms commented on CDI-610:
---------------------------------
Just wondering, any updates for this? Would this be in scope for CDI 2.1 perhaps?
> Add API to obtain current injection point from Bean#create
> ----------------------------------------------------------
>
> Key: CDI-610
> URL: https://issues.jboss.org/browse/CDI-610
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Portable Extensions
> Reporter: arjan tijms
>
> There's currently not a clear way on how to obtain the *current* injection point (if any) from {{Bean<T>#create}}.
> A previously somewhat accepted way (though not specified) was:
> {code}
> Bean<? extends Object> bean = beanManager.resolve(beanManager.getBeans(InjectionPoint.class));
> InjectionPoint injectionPoint = (InjectionPoint) beanManager.getReference(bean, InjectionPoint.class, creationalContext);
> {code}
> This however broke in some version of Weld.
> Since getting the injection point is an often used feature in producers, I'd like to propose to introduce an easy API for this, so {{Bean<T>}} implementations can use this just as easily. E.g. something like: {{BeanManager#getCurrentInjectionPoint()}}.
> Also see: http://cdi-development-mailing-list.1064426.n5.nabble.com/Getting-injecti...
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
7 years, 3 months