Attributes on scope annotations

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Attributes on scope annotations

rinswind
Hello,

Is it against the CDI 2.0 specification to have attributes on a scope annotation? If not is this a corner case that may become forbidden or simply not be taken into account in future versions of the specification?

E.g. @ComponentScoped("my-component")

With Weld 3.0.0 I was able to successfully use such annotations.

Regards,
Todor


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes on scope annotations

Matej Novotny
Hello Todor,

>From CDI specification 2.0 section 2.4.2 Defining new scopes[1]:

"A scope type must not have any attributes. If a scope type has attributes non-portable behavior results."

Matej

___________________________________________________________________________-
[1] http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#defining_new_scope_type



----- Original Message -----

> From: "Todor Boev" <[hidden email]>
> To: [hidden email]
> Sent: Friday, September 1, 2017 9:51:47 AM
> Subject: [cdi-dev] Attributes on scope annotations
>
> Hello,
>
> Is it against the CDI 2.0 specification to have attributes on a scope
> annotation? If not is this a corner case that may become forbidden or simply
> not be taken into account in future versions of the specification?
>
> E.g. @ComponentScoped("my-component")
>
> With Weld 3.0.0 I was able to successfully use such annotations.
>
> Regards,
> Todor
>
>
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the code
> under the Apache License, Version 2
> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other intellectual
> property rights inherent in such information.
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes on scope annotations

Martin Kouba
In reply to this post by rinswind
Hi Todor,

it's not forbidden but defined as non-portable behavior, i.e. it depends
on implementation whether it will ignore the attributes, throw
DeploymentException, etc.

For Weld the attributes should be ignored. Just try OWB and if ok then
you're probably safe to go ;-)

Martin

Dne 1.9.2017 v 09:51 Todor Boev napsal(a):

> Hello,
>
> Is it against the CDI 2.0 specification to have attributes on a scope
> annotation? If not is this a corner case that may become forbidden or
> simply not be taken into account in future versions of the specification?
>
> E.g. @ComponentScoped("my-component")
>
> With Weld 3.0.0 I was able to successfully use such annotations.
>
> Regards,
> Todor
>
>
>
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
>

--
Martin Kouba
Senior Software Engineer
Red Hat, Czech Republic
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes on scope annotations

Matej Novotny
In reply to this post by Matej Novotny
Let's keep this conversation on CDI-dev list, please (adding back to CC).

Hmm, I think it is not forbidden to add another plain java annotation.
However, having it working as scope and cdi qualifier in the same time won't work.

Matej

----- Original Message -----

> From: "Todor Boev" <[hidden email]>
> To: "Matej Novotny" <[hidden email]>
> Sent: Friday, September 1, 2017 12:33:54 PM
> Subject: Re: [cdi-dev] Attributes on scope annotations
>
> Thank you for the timely replay,
>
> I need portable behavior, so the other option I am considering is to
> meta-annotate the scope annotation with the additional information I need.
> The issues are now: is this allowed, can in principle my custom
> meta-annotation be a qualifier. Probably a plain annotation will be
> sufficient, but I may need to have it do double-duty as a qualifier as well.
>
> Thanks in advance,
> Todor
>
> On Fri, Sep 1, 2017 at 11:49 AM, Matej Novotny <[hidden email]> wrote:
>
> > Hello Todor,
> >
> > From CDI specification 2.0 section 2.4.2 Defining new scopes[1]:
> >
> > "A scope type must not have any attributes. If a scope type has attributes
> > non-portable behavior results."
> >
> > Matej
> >
> > ____________________________________________________________
> > _______________-
> > [1] http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#
> > defining_new_scope_type
> >
> >
> >
> > ----- Original Message -----
> > > From: "Todor Boev" <[hidden email]>
> > > To: [hidden email]
> > > Sent: Friday, September 1, 2017 9:51:47 AM
> > > Subject: [cdi-dev] Attributes on scope annotations
> > >
> > > Hello,
> > >
> > > Is it against the CDI 2.0 specification to have attributes on a scope
> > > annotation? If not is this a corner case that may become forbidden or
> > simply
> > > not be taken into account in future versions of the specification?
> > >
> > > E.g. @ComponentScoped("my-component")
> > >
> > > With Weld 3.0.0 I was able to successfully use such annotations.
> > >
> > > Regards,
> > > Todor
> > >
> > >
> > > _______________________________________________
> > > cdi-dev mailing list
> > > [hidden email]
> > > https://lists.jboss.org/mailman/listinfo/cdi-dev
> > >
> > > Note that for all code provided on this list, the provider licenses the
> > code
> > > under the Apache License, Version 2
> > > (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> > > provided on this list, the provider waives all patent and other
> > intellectual
> > > property rights inherent in such information.
> >
>
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes on scope annotations

Xavier Dury
JSF [1] and Omnifaces [2] are doing it but it's against the spec.

If this was allowed, I suppose BeanManager.getContext() [3] would have taken an annotation parameter instead of an annotation type.

Xavier

----

[1] http://docs.oracle.com/javaee/7/api/javax/faces/flow/FlowScoped.html
[2] http://omnifaces.org/docs/javadoc/2.6/org/omnifaces/cdi/ViewScoped.html
[3] http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/spi/BeanManager.html#getContext-java.lang.Class-


From: [hidden email] <[hidden email]> on behalf of Matej Novotny <[hidden email]>
Sent: Friday, September 1, 2017 1:43 PM
To: Todor Boev
Cc: cdi-dev
Subject: Re: [cdi-dev] Attributes on scope annotations
   
Let's keep this conversation on CDI-dev list, please (adding back to CC).

Hmm, I think it is not forbidden to add another plain java annotation.
However, having it working as scope and cdi qualifier in the same time won't work.

Matej

----- Original Message -----

> From: "Todor Boev" <[hidden email]>
> To: "Matej Novotny" <[hidden email]>
> Sent: Friday, September 1, 2017 12:33:54 PM
> Subject: Re: [cdi-dev] Attributes on scope annotations
>
> Thank you for the timely replay,
>
> I need portable behavior, so the other option I am considering is to
> meta-annotate the scope annotation with the additional information I need.
> The issues are now: is this allowed, can in principle my custom
> meta-annotation be a qualifier. Probably a plain annotation will be
> sufficient, but I may need to have it do double-duty as a qualifier as well.
>
> Thanks in advance,
> Todor
>
> On Fri, Sep 1, 2017 at 11:49 AM, Matej Novotny <[hidden email]> wrote:
>
> > Hello Todor,
> >
> > From CDI specification 2.0 section 2.4.2 Defining new scopes[1]:
> >
> > "A scope type must not have any attributes. If a scope type has attributes
> > non-portable behavior results."
> >
> > Matej
> >
> > ____________________________________________________________
> > _______________-
> > [1] http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#


JSR 365: Contexts and Dependency Injection for Java 2.0
docs.jboss.org
Starting with version 2.0 CDI targets Java SE and Java EE platforms. CDI in Java SE and CDI in a Java EE container share the features defined in core CDI.

> > defining_new_scope_type
> >
> >
> >
> > ----- Original Message -----
> > > From: "Todor Boev" <[hidden email]>
> > > To: [hidden email]
> > > Sent: Friday, September 1, 2017 9:51:47 AM
> > > Subject: [cdi-dev] Attributes on scope annotations
> > >
> > > Hello,
> > >
> > > Is it against the CDI 2.0 specification to have attributes on a scope
> > > annotation? If not is this a corner case that may become forbidden or
> > simply
> > > not be taken into account in future versions of the specification?
> > >
> > > E.g. @ComponentScoped("my-component")
> > >
> > > With Weld 3.0.0 I was able to successfully use such annotations.
> > >
> > > Regards,
> > > Todor
> > >
> > >
> > > _______________________________________________
> > > cdi-dev mailing list
> > > [hidden email]
> > > https://lists.jboss.org/mailman/listinfo/cdi-dev


cdi-dev Info Page - lists.jboss.org Mailing Lists
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.

> > >
> > > Note that for all code provided on this list, the provider licenses the
> > code
> > > under the Apache License, Version 2
> > > (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas


Apache License, Version 2.0
www.apache.org
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION. 1. Definitions.

> > > provided on this list, the provider waives all patent and other
> > intellectual
> > > property rights inherent in such information.
> >
>
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev


cdi-dev Info Page - lists.jboss.org Mailing Lists
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.


Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on  this list, the provider waives all patent and other intellectual property rights inherent in such information.
   
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes on scope annotations

Xavier Dury
forwarding your mail to the mailing list

 
From: Todor Boev <[hidden email]>
Sent: Monday, September 4, 2017 11:03 AM
To: Xavier Dury
Subject: Re: [cdi-dev] Attributes on scope annotations
 

I did expect BeanManager.getScope() to return an annotation instance, when implementing my scope.


Similarly to JSF my use case that the type of applications I need to support do not have such a specific execution flow as to allow me to define a singleton scope. Instead the users must be able to define the scope at a particular place in the execution  flow. My workaround is to require that the users create a new scope annotation for each such scope and meta-annotate it with the data consumed by my extension. Then they can use their custom annotation for their custom scoped classes. This is however inconvenient  for the most common case of a single custom-scoped class.


Given however attributes on scopes are used in JSF should I open an issue for the CDI spec to support this use case?


Regards



On Sat, Sep 2, 2017 at 1:08 PM, Xavier Dury  <[hidden email]> wrote:
 JSF [1] and Omnifaces [2] are doing it but it's against the spec.

If this was allowed, I suppose BeanManager.getContext() [3] would have taken an annotation parameter instead of an annotation type.

Xavier

----

[1]  http://docs.oracle.com/javaee/7/api/javax/faces/flow/FlowScoped.html
[2]  http://omnifaces.org/docs/javadoc/2.6/org/omnifaces/cdi/ViewScoped.html
[3]  http://docs.oracle.com/javaee/7/api/javax/enterprise/inject/spi/BeanManager.html#getContext-java.lang.Class-


From: [hidden email] <[hidden email]> on behalf of Matej Novotny <[hidden email]>
Sent: Friday, September 1, 2017 1:43 PM
To: Todor Boev
Cc: cdi-dev


Subject: Re: [cdi-dev] Attributes on scope annotations
 
Let's keep this conversation on CDI-dev list, please (adding back to CC).

Hmm, I think it is not forbidden to add another plain java annotation.
However, having it working as scope and cdi qualifier in the same time won't work.

Matej

----- Original Message -----

> From: "Todor Boev" <[hidden email]>
> To: "Matej Novotny" <[hidden email]>
> Sent: Friday, September 1, 2017 12:33:54 PM
> Subject: Re: [cdi-dev] Attributes on scope annotations
>
> Thank you for the timely replay,
>
> I need portable behavior, so the other option I am considering is to
> meta-annotate the scope annotation with the additional information I need.
> The issues are now: is this allowed, can in principle my custom
> meta-annotation be a qualifier. Probably a plain annotation will be
> sufficient, but I may need to have it do double-duty as a qualifier as well.
>
> Thanks in advance,
> Todor
>
> On Fri, Sep 1, 2017 at 11:49 AM, Matej Novotny <[hidden email]> wrote:
>
> > Hello Todor,
> >
> > From CDI specification 2.0 section 2.4.2 Defining new scopes[1]:
> >
> > "A scope type must not have any attributes. If a scope type has attributes
> > non-portable behavior results."
> >
> > Matej
> >
> > ____________________________________________________________
> > _______________-
> > [1]  http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#


  JSR 365: Contexts and Dependency Injection for Java 2.0
docs.jboss.org
Starting with version 2.0 CDI targets Java SE and Java EE platforms. CDI in Java SE and CDI in a Java EE container share the features defined in core CDI.

> > defining_new_scope_type
> >
> >
> >
> > ----- Original Message -----
> > > From: "Todor Boev" <[hidden email]>
> > > To: [hidden email]
> > > Sent: Friday, September 1, 2017 9:51:47 AM
> > > Subject: [cdi-dev] Attributes on scope annotations
> > >
> > > Hello,
> > >
> > > Is it against the CDI 2.0 specification to have attributes on a scope
> > > annotation? If not is this a corner case that may become forbidden or
> > simply
> > > not be taken into account in future versions of the specification?
> > >
> > > E.g. @ComponentScoped("my-component")
> > >
> > > With Weld 3.0.0 I was able to successfully use such annotations.
> > >
> > > Regards,
> > > Todor
> > >
> > >
> > > _______________________________________________
> > > cdi-dev mailing list
> > > [hidden email]
> > >  https://lists.jboss.org/mailman/listinfo/cdi-dev


cdi-dev Info Page -  lists.jboss.org Mailing Lists
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.

> > >
> > > Note that for all code provided on this list, the provider licenses the
> > code
> > > under the Apache License, Version 2
> > > (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas


Apache License, Version 2.0
www.apache.org
Apache License Version 2.0, January 2004  http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION. 1. Definitions.

> > > provided on this list, the provider waives all patent and other
> > intellectual
> > > property rights inherent in such information.
> >
>
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev


cdi-dev Info Page -  lists.jboss.org Mailing Lists
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.




Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html).  For all other ideas provided on  this list, the provider waives all patent and other intellectual property rights inherent in such information.

_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html).  For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
   
       
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.