You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Niederwieser <pn...@gmail.com> on 2009/09/07 03:03:35 UTC
Why does Registry.get(Class, AnnotationProvider) ignore @Scope?
I'm using Registry.get(Class, AnnotationProvider) to find matching services
for fields of an object that is not under Tapestry's control. Everything
works fine, except that annotating a field with @Scope("myOwnScope") has no
effect. Is this a bug? If not, what can I do to obtain a service with the
requested scope? (Annotating the service builder method with
@Scope("myOwnScope") works as expected, but isn't appropriate in this case.)
Cheers,
Peter
--
View this message in context: http://www.nabble.com/Why-does-Registry.get%28Class%2C-AnnotationProvider%29-ignore-%40Scope--tp25323724p25323724.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Why does Registry.get(Class, AnnotationProvider) ignore @Scope?
Posted by Peter Niederwieser <pn...@gmail.com>.
Well, actually it does compile - if the class is written in Groovy. :-) Have
to investigate this further. Anyway, I now understand that @Scope is allowed
on a service implementation class, but not on its fields. Thanks for the
clarification!
Cheers,
Peter
Thiago H. de Paula Figueiredo wrote:
>
> Hi!
>
> The @Scope can't be used in fields: it wouldn't compile (@Scope is
> defined with @Target(value={TYPE,METHOD})). In addition, each service
> has only one scope, defined in its builder method. From
> http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html:
>
> "Each service has a lifecycle that controls when the service
> implementation is instantiated."
> "Service lifecycle is specified using the @Scope annotation, which is
> attached to a builder method." When this annotation is not present,
> the default scope, "singleton" is used."
>
> --
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Why-does-Registry.get%28Class%2C-AnnotationProvider%29-ignore-%40Scope--tp25323724p25323942.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Why does Registry.get(Class, AnnotationProvider) ignore @Scope?
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hi!
The @Scope can't be used in fields: it wouldn't compile (@Scope is
defined with @Target(value={TYPE,METHOD})). In addition, each service
has only one scope, defined in its builder method. From
http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html:
"Each service has a lifecycle that controls when the service
implementation is instantiated."
"Service lifecycle is specified using the @Scope annotation, which is
attached to a builder method." When this annotation is not present,
the default scope, "singleton" is used."
--
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org