Enabling programmatic/synthetic decorators added by extension
by arjan tijms
Hi,
I'm trying to add decorators and/or interceptors to a Bean<T> that's added
via an extension. There doesn't seem to be any way to add interceptors, but
decorators seem almost possible.
I've added a decorator in the following way:
AnnotatedType<AutoApplySessionDecorator> annotatedType =
beanManager.createAnnotatedType(AutoApplySessionDecorator.class);
BeanAttributes<AutoApplySessionDecorator> beanAttributes =
beanManager.createBeanAttributes(annotatedType);
Bean<AutoApplySessionDecorator> bean =
beanManager.createBean(beanAttributes, AutoApplySessionDecorator.class,
beanManager.getInjectionTargetFactory(annotatedType));
afterBeanDiscovery.addBean(bean);
Where the "AutoApplySessionDecorator" is an existing (non-scanned)
decorator just used as an example.
While this seems to work, the problem is with the enablement. @Priority is
not processed in this way, since it's only read from an AnnotatedType
that's been added to the deployment (see e.g. in
Weld org.jboss.weld.bootstrap.BeanDeployer.processPriority(AnnotatedType<?>)).
beans.xml is not really an option here due to the static nature of that and
the fact that the decorator needs to be enabled dynamically here, plus that
the implementation class of the decorator is a detail I would not like to
expose to the application.
Is there any other way to either enable a (synthetic) decorator
programmatically, or to add Interceptors to a programmatically added
Bean<T>?
Kind regards,
Arjan Tijms
8 years, 4 months
September F2F meeting Doodle
by Antoine Sabot-Durand
Hi all,
The meeting will take place on 2 days. I listed the choices for the
starting day in the following Doodle.
As we have the budget, we are sure to have it this time, we only have to
agree on the date.
http://doodle.com/poll/mby6vkkgdsyd2fg9
Sorry for the previous attempt and thank you for your feedback.
Antoine
8 years, 6 months
Looking for Feedback on PR #291
by John D. Ament
All,
As mentioned during Tuesday's meeting, I'm looking for more feedback on PR
#291 - the context control APIs. I think the current version is pretty
snazy, and thanks especially to Martin for his input on it thus far. I'm
looking for more input though, especially from the OWB team (Mark
Struberg??) on whether its realistic or not.
https://github.com/cdi-spec/cdi/pull/291
John
8 years, 6 months
Face to Face meeting approved (at last)
by Antoine Sabot-Durand
Hi All,
I received validation of our F2F meeting by Red Hat management.
I understand that it's a bit late, but I need to know if you make it next
week or should we postpone the meeting to late August early September ?
Give me you favorite choice. ASAP of course ;).
Antoine
8 years, 6 months
[JBoss JIRA] (CDI-610) Add API to obtain current injection point from Bean#create
by Arjan t (JIRA)
[ https://issues.jboss.org/browse/CDI-610?page=com.atlassian.jira.plugin.sy... ]
Arjan t commented on CDI-610:
-----------------------------
{quote}Which other cases do you have in mind?{quote}
Not really so much a wildly different usecase, just something like
{code}
public Object create(CreationalContext<T> creationalContext) {
someclass.somemethod();
}
[...]
public void somemethod() {
InjectionPoint point = beanManager.getCurrentInjectionPoint();
}
{code}
Utility code would often already have access to the bean manager (or it can pull it out of thin air), and the actual need for the injection point could be some levels deep and via utility code. Passing the {{CreationalContext}} around may be less convenient. Also, the existing (semi-official) methods to get the injection point used the {{BeanManager}} as well.
That all said, {{CreationalContext}} would be fine with me ;)
> 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
(v6.4.11#64026)
8 years, 6 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:
----------------------------------
bq. For the Bean<T> case this would surely work as well...
Which other cases do you have in mind? I wouldn't add this to the {{BeanManager}}. I think it's bound to the lifecycle of a {{@Dependent}} bean.
bq. It should be as much aligned with injecting the InjectionPoint in a producer method.
Not only producer methods but any {{@Dependent}} bean is allowed to obtain the injection point.
bq. I don't know from the top of my head...
Yes, it's a definition error.
> 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
(v6.4.11#64026)
8 years, 6 months
[JBoss JIRA] (CDI-610) Add API to obtain current injection point from Bean#create
by Arjan t (JIRA)
[ https://issues.jboss.org/browse/CDI-610?page=com.atlassian.jira.plugin.sy... ]
Arjan t commented on CDI-610:
-----------------------------
{quote}Maybe we could add getInjectionPoint() method to the CreationalContext?{quote}
For the {{Bean<T>}} case this would surely work as well. Maybe for some code deeper down {{BeanManager}} would still be more convenient, but principally {{CreationalContext}} should work too.
{quote}Also it should return null for beans which are not @Dependent.{quote}
Naturally, or perhaps even an exception. It should be as much aligned with injecting the {{InjectionPoint}} in a producer method. (I don't know from the top of my head, but does it throw an exception during startup if it concerns a non {{@Dependent}} bean?)
> 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
(v6.4.11#64026)
8 years, 6 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 could add {{getInjectionPoint()}} method to the {{CreationalContext}}? Also it should return null for beans which are not @Dependent.
> 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
(v6.4.11#64026)
8 years, 6 months
[JBoss JIRA] (CDI-610) Add API to obtain current injection point from Bean#create
by arjan tijms (JIRA)
arjan tijms created CDI-610:
-------------------------------
Summary: 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
(v6.4.11#64026)
8 years, 6 months
Fwd: [jsr366-experts] Common Annotations Maintenance Draft
by Antoine Sabot-Durand
Hi Guys,
I forward below, the mail Linda sent to Java EE EG ML last week regarding
MR of Commons annotations. For me it's fine but you may want to have a look.
Antoine
---------- Forwarded message ---------
From: Linda DeMichiel <linda.demichiel(a)oracle.com>
Date: jeu. 19 mai 2016 à 23:59
Subject: [jsr366-experts] Common Annotations Maintenance Draft
To: <jsr366-experts(a)javaee-spec.java.net>
I've uploaded drafts of the Common Annotation spec + javadocs
to https://java.net/projects/javaee-spec/downloads.
The functional changes are the addition of @Target(PARAMETER) to
the Priority annotation as requested by the CDI expert group
and making the Resource and DataSourceDefinition annotations
repeatable.
I've also corrected some minor inconsistencies between this spec and
the Interceptor spec on PostConstruct and PreDestroy, and replaced the
example in section 2.1 referencing WebService/WebMethod, which was
inconsistent with the JAX-WS and Web Services Metadata specs.
All other changes are intended as purely editorial.
If you catch anything amiss, please let me know as soon as
possible, as I am planning to submit these materials to the
JCP next week to initiate a Maintenance Review.
thanks,
-Linda
8 years, 6 months