[JBoss JIRA] (CDI-45) Optional Injection Points
by Renat Valeev (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Renat Valeev commented on CDI-45:
---------------------------------
Ok, then explain how we have now Instance<T> interface and it is not serializable.
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Romain Manni-Bucau (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Romain Manni-Bucau commented on CDI-45:
---------------------------------------
agree, was my point
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Anatole Tresch (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Anatole Tresch commented on CDI-45:
-----------------------------------
I do not think that this would be a feasible approach. This would require all vendors to customize serialization... additionally I would expect other side effects with code that the EE container maybe is not aware of, EE is still running on top of SE. You cannot change SE 8, it is given.
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Romain Manni-Bucau (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Romain Manni-Bucau commented on CDI-45:
---------------------------------------
Instance is handled by the containers so adding Optional means forcing the container to serialize it...which means force the container to get its value and ensure it is serializable
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Renat Valeev (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Renat Valeev commented on CDI-45:
---------------------------------
It should not. Instance<T> is not Serializable as well.
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Romain Manni-Bucau (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Romain Manni-Bucau commented on CDI-45:
---------------------------------------
But while Optional is not Serializable it would be a mess in EE/CDI context
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Thorben Janssen (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Thorben Janssen commented on CDI-45:
------------------------------------
{code}Instance<T> extends Iterable<T>{code} and therefore might contain more than one MyBean instances. It would not be possible to inject only one or no MyBean instances.
I like the Java8 Optional idea. It is similar to the existing Instance approach, avoids null checks and fits to the planned Java 8 enhancements.
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Antonin Stefanutti (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Antonin Stefanutti edited comment on CDI-45 at 9/1/14 11:35 AM:
----------------------------------------------------------------
>From my understanding, that need is met with [{{javax.enterprise.inject.Instance}}|http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/Instance.html]:
{code}
@Inject
Instance<MyBean> bean;
if (!bean.isUnsatisfied())
bean.get();
{code}
What would be the added value of the {{@Optional}} approach compared to the {{Instance}} concept? Besides, that approach would lead to having potential NPE or to check against nullity which is not very elegant.
That being said, with the CDI 2.0 / Java 8 enhancement stream, [{{java.util.Optional}}|http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html] could be automatically supported:
{code}
@Inject
Optional<MyBean> bean;
bean.isPresent();
bean.orElse(...);
{code}
was (Author: stefanutti):
>From my understanding, that need is met with [{{javax.enterprise.inject.Instance}}|http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/Instance.html]:
{code}
@Inject
Instance<MyBean> bean;
if (!bean.isUnsatisfied())
bean.get();
{code}
What would be the added value of the {{@Optional}} approach compared to the {{Instance}} concept. Besides, that approach would lead to having potential NPE or to check against nullity which is not very elegant.
That being said, with the CDI 2.0 / Java 8 enhancement stream, [{{java.util.Optional}}|http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html] could be automatically supported:
{code}
@Inject
Optional<MyBean> bean;
bean.isPresent();
bean.orElse(...);
{code}
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
[JBoss JIRA] (CDI-45) Optional Injection Points
by Antonin Stefanutti (JIRA)
[ https://issues.jboss.org/browse/CDI-45?page=com.atlassian.jira.plugin.sys... ]
Antonin Stefanutti commented on CDI-45:
---------------------------------------
>From my understanding, that need is met with [{{javax.enterprise.inject.Instance}}|http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/Instance.html]:
{code}
@Inject
Instance<MyBean> bean;
if (!bean.isUnsatisfied())
bean.get();
{code}
What would be the added value of the {{@Optional}} approach compared to the {{Instance}} concept. Besides, that approach would lead to having potential NPE or to check against nullity which is not very elegant.
That being said, with the CDI 2.0 / Java 8 enhancement stream, [{{java.util.Optional}}|http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html] could be automatically supported:
{code}
@Inject
Optional<MyBean> bean;
bean.isPresent();
bean.orElse(...);
{code}
> Optional Injection Points
> -------------------------
>
> Key: CDI-45
> URL: https://issues.jboss.org/browse/CDI-45
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Resolution
> Affects Versions: 1.0
> Reporter: Stuart Douglas
> Fix For: 2.0 (discussion)
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional
> MyBean bean;
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 6 months
Re: [cdi-dev] Writing about CDI 2.0 and work in EG
by Antoine Sabot-Durand
Hi Thorben,
I’m answering on the mailing list since others can be interested. Everything around the specification will be transparent end publicly available. On the JCP side this transparency is describe in version 2.9 of JCP process document : https://jcp.org/en/procedures/jcp2_9#1 <https://jcp.org/en/procedures/jcp2_9#1>. On our side (Red Hat) we treat this project as any other ASL2 open Source project. JSPA signature and legal mention added to the ML footer and IRC are only here to avoid future Intellectual Property dispute.
So if you want to describe what’s happening with CDI 2.0 EG, you’re very welcome, since it’ll help for the JSR communication.
Regards,
Antoine
> Le 1 sept. 2014 à 16:19, Thorben Janssen <thjanssen123(a)gmail.com> a écrit :
>
> Hey Antoine,
>
> are there any limitations on writing about our work in the expert group?
> Everything is open and published under a open source license. So from my point of view, there should be no limitations. Am I missing something?
>
> There are two things I am currently thinking about:
> - The start of the expert group would be an interesting topic for a blog post.
> - The ongoing work might be an interesting topic for an article in the german print magazine "Java Magazin". I got 4 month to write my current article and it will be published 1,5 month later. So I would submit the proposal next month and expect to get a deadline for beginning of next year.
>
> What do you think?
>
> Regards,
> Thorben
>
> --
> Thorben Janssen
>
> @thjanssen123 <https://twitter.com/thjanssen123>
> www.thoughts-on-java.org <http://www.thoughts-on-java.org/>
10 years, 6 months