[JBoss JIRA] (CDI-535) cdi instance injection ordering
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
George Gastaldi commented on CDI-535:
-------------------------------------
[~marembo2008], I agree, so in order to avoid instantiating the objects and comparing against each other, I think using {{@Priority}} or another kind of comparison (eg. annotation) in the type declaration would be a better choice.
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-535) cdi instance injection ordering
by Ochieng Marembo (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
Ochieng Marembo commented on CDI-535:
-------------------------------------
I think using the ```@OrderBy``` qualifier would be more suited to situations where you have no control of all possible interface implementations.
Depending on when the OrderBy is executed, it could be called the first time the instance list is actually requested for iteration, hence delaying instantiating expensive implementationd.
Strictly the OrderBy cannot be a normal qualifier as it will force all instances to be so qualified, which for purposes of considering 3rd party implementations, would simply not work.
We could have as an implicit qualifier.
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-535) cdi instance injection ordering
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
George Gastaldi edited comment on CDI-535 at 10/5/16 2:34 AM:
--------------------------------------------------------------
I think {{@Priority}} must be extended to support producer methods and fields, but for now I believe it´s fine to support it in a type-level usage only, WDYT?. For example, how different would a bean be from an interceptor (or an Alternative) that uses this same approach?
was (Author: gastaldi):
I think {{@Priority}} must be extended to support producer methods and fields, but for now I believe it´s fine to support it in a type-level usage only, WDYT?. For example, how different would a bean be from an interceptor that uses this same approach?
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-535) cdi instance injection ordering
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
George Gastaldi commented on CDI-535:
-------------------------------------
OTOH maybe we could look into a different approach by asking for ordering in the injection point itself (eg. {{@Inject @OrderBy(SOMETHING GOES HERE) Instance<Bean>}}), but I´m not sure how would that work.
Something to keep in the back of your mind :)
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-535) cdi instance injection ordering
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
George Gastaldi commented on CDI-535:
-------------------------------------
I think {{@Priority}} must be extended to support producer methods and fields, but for now I believe it´s fine to support it in a type-level usage only, WDYT?. For example, how different would a bean be from an interceptor that uses this same approach?
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-535) cdi instance injection ordering
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-535:
----------------------------------
[~meetoblivion] [~gastaldi] With priority annotation (or similar stuff) you could order the eligible beans even without instantiation. This might be useful in case of bean creation is rather expensive. But I'm not sure it's worth standardizing, esp. if {{@Priority}} currently cannot be used for all cases.
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-535) cdi instance injection ordering
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
George Gastaldi commented on CDI-535:
-------------------------------------
Why? Isn't that what priority is for? Or are you referring to implementing Comparable in this object?
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-636) Add Instance.stream()
by John Ament (JIRA)
John Ament created CDI-636:
------------------------------
Summary: Add Instance.stream()
Key: CDI-636
URL: https://issues.jboss.org/browse/CDI-636
Project: CDI Specification Issues
Issue Type: Feature Request
Affects Versions: 1.2.Final
Reporter: John Ament
Add the ability to stream all bean instances from an Instance.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
[JBoss JIRA] (CDI-535) cdi instance injection ordering
by John Ament (JIRA)
[ https://issues.jboss.org/browse/CDI-535?page=com.atlassian.jira.plugin.sy... ]
John Ament commented on CDI-535:
--------------------------------
If you want sorting, shouldn't {{MyBeanInstance}} have some ordering capability?
> cdi instance injection ordering
> -------------------------------
>
> Key: CDI-535
> URL: https://issues.jboss.org/browse/CDI-535
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Beans
> Affects Versions: 2.0 (discussion)
> Reporter: Ochieng Marembo
> Priority: Optional
>
> We should allow ordering of bean instance injection using the ```Instance<MyBeanInterface>``` when an instance injection is used.
> h3. Use case:
> Developer always define a kind of chain of processor beans, which may need to run in specific order.
> h3. Current scenario:
> Using the Instance injection mechanism, a developer can inject multiple beans implementing the same interface and iterate of them. In order to ensure ordering, the developer could do one of the following:
> #1
> {code}
> private Iterable<MyBeanInterface> myBeans;
> @Inject
> void injectBeans(@Any Instance<MyBeanInterface> myBeans) {
> //the create order does some kind of ordering on the beans.
> this.myBeans = createOrder(myBeans);
> }
> {code}
> #2
> This second option may be expensive if we have to order the beans everytime we execute the logic, and if this bean is applicationscoped, it wont make sense to do the ordering in the method call.
> {code}
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> public void doSomething() {
> Iterable<MyBeanInterface> orderedbeans = createOrder(myBeans.select(someQualifier));
> }
> {code}
> h3. Our Proposal
> We already have {code}javax.annotation.Priority{code} or any cdi specific annotation which we can add to {code}MyBeanInterfaceImpl{code} so that on injection of an {code}Instance<MyBeanInterface>{code}, all possible injection values are sorted based on the {code}Priority.value(){code} and if no annotation is defined, defaults to {code}Priority.value = Integer.MAX_VALUE{code}
> {code}
> public interface MyBeanInterface {}
> @MyQualifier
> @Priority(0)
> public class MyFirstBean implements MyBeanInterface{
> }
> @MyQualifier
> @Priority(2)
> public class MySecondBean implements MyBeanInterface{
> }
> @ApplicationScoped
> public class MyBeanProcessor {
> //We expect that this injected instances shall be in order based on the @Priority annotation
> @Any
> @Inject
> private Instance<MyBeanInterface> myBeans;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 2 months
CDI-30 - Request Context management
by John Ament
After discussions from last week where it was decided to split session and request context management, I've raised a PR https://github.com/cdi-spec/cdi/pull/305/files to introduce new controller, and entered a JIRA ticket https://issues.jboss.org/browse/CDI-635 to handle session context management
John
________________________________
NOTICE: This e-mail message and any attachments may contain confidential, proprietary, and/or privileged information which should be treated accordingly. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this message, and destroy all physical and electronic copies. Thank you.
8 years, 2 months