You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Muhammad Gelbana <m....@gmail.com> on 2012/10/10 00:08:25 UTC

Suggestion regarding service ID

One can use a service id to identify a specific implementation for an
interface. But sometimes one may have multiple interfaces for the same
purpose. Wouldn't it be easier to have specify the same service ID among
different interfaces ?

For exmaple:

InterfaceA (Implemented by ImplA, Id: "Users", ImplB, Id: "Managers",
ImplC, Id: "Offices")
InterfaceB (Implemented by ImplX, Id: "Users", ImplY, Id: "Managers",
ImplZ, Id: "Whatever")

So that the interfaces also has a role on pinning the implementation using
the services id, and not the service id only. I'm bringing that up because
I, sometimes, find it a bit messy to specify a unique service id for my
services while they don't even share the same interface.

Re: Suggestion regarding service ID

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 31 Oct 2012 19:25:06 -0200, Muhammad Gelbana <m....@gmail.com>  
wrote:

> Now I know why I have to do this. I'm very much willing to type few
> characters to make it easier for tapestry to do it's magic.

It surely does. :) Just a nitpick: in this case, it's about Tapestry-IoC,  
not Tapestry (which is the web framework). :D

> Thank you :)

It's a pleasure to help. :)

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Suggestion regarding service ID

Posted by Muhammad Gelbana <m....@gmail.com>.
Now I know why I have to do this. I'm very much willing to type few
characters to make it easier for tapestry to do it's magic. Thank you :)

On Wed, Oct 31, 2012 at 11:05 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Wed, 31 Oct 2012 18:53:49 -0200, Muhammad Gelbana <m....@gmail.com>
> wrote:
>
>  I can see the refactor-safe, auto complete and syntax check implied by
>> using marker annotations. I'm just wondering why should I specify unique
>> service IDs, because it's useless in that case. Don't you agree ?
>>
>
> Useless from the developer side, but very important for the Tapestry-IoC
> side. Having multiple services with a single id would be a mess. If you do
> an @InjectService("Id") and there are more than one service with that id,
> what should be injected? There's no good answer for that. ;) Yep, sometimes
> we have to do some stuff just to make the framework happy. In this case,
> it's just a matter of typing some characteres. :D
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Suggestion regarding service ID

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 31 Oct 2012 18:53:49 -0200, Muhammad Gelbana <m....@gmail.com>  
wrote:

> I can see the refactor-safe, auto complete and syntax check implied by
> using marker annotations. I'm just wondering why should I specify unique
> service IDs, because it's useless in that case. Don't you agree ?

Useless from the developer side, but very important for the Tapestry-IoC  
side. Having multiple services with a single id would be a mess. If you do  
an @InjectService("Id") and there are more than one service with that id,  
what should be injected? There's no good answer for that. ;) Yep,  
sometimes we have to do some stuff just to make the framework happy. In  
this case, it's just a matter of typing some characteres. :D

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Suggestion regarding service ID

Posted by Muhammad Gelbana <m....@gmail.com>.
I can see the refactor-safe, auto complete and syntax check implied by
using marker annotations. I'm just wondering why should I specify unique
service IDs, because it's useless in that case. Don't you agree ?

On Wed, Oct 31, 2012 at 10:46 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Wed, 31 Oct 2012 17:55:35 -0200, Muhammad Gelbana <m....@gmail.com>
> wrote:
>
>> It looks like markers aren't sufficient on their own and I still need *
>> unique* service IDs for each implementation to successfully define my
>> services.
>>
>
> That's correct..
>
>
>  The only good I can see here is that I do not need to specify the service
>> ID when injecting the service. So whats the benefit of specifying
>> one in the first place ?
>>
>
> You've answered yourself just before the question. :) And a marker
> annotation is way harder to type incorrectly than a service name (the
> compiler will catch that). Relying on strings for doing this kind of stuff
> is bad.
>
> --
> Thiago H. de Paula Figueiredo
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Suggestion regarding service ID

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 31 Oct 2012 17:55:35 -0200, Muhammad Gelbana <m....@gmail.com>  
wrote:
> It looks like markers aren't sufficient on their own and I still need *
> unique* service IDs for each implementation to successfully define my
> services.

That's correct..

> The only good I can see here is that I do not need to specify the  
> service ID when injecting the service. So whats the benefit of specifying
> one in the first place ?

You've answered yourself just before the question. :) And a marker  
annotation is way harder to type incorrectly than a service name (the  
compiler will catch that). Relying on strings for doing this kind of stuff  
is bad.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Suggestion regarding service ID

Posted by Muhammad Gelbana <m....@gmail.com>.
So now I'm trying this:

> binder.bind(ITestAgentModule.class,
> FTPTestModule.class).withMarker(FTP.class);
> binder.bind(ITestAgentModule.class,
> HTTPTestModule.class).withMarker(HTTP.class);
> binder.bind(ITestAgentModule.class,
> DNSTestModuleImpl.class).withMarker(DNS.class);
> binder.bind(ITestAgentModule.class,
> ICMPTestModuleImpl.class).withMarker(ICMP.class);
>

Which throws an exception message indicating that the
HTTPTestModuleservice (2nd defined) definition conflicts with the
FTPTestModule (1st defined) service definition.

It looks like markers aren't sufficient on their own and I still need *
unique* service IDs for each implementation to successfully define my
services. The only good I can see here is that I do not need to specify the
service ID when injecting the service. So whats the benefit of specifying
one in the first place ?


On Wed, Oct 10, 2012 at 7:26 PM, Muhammad Gelbana <m....@gmail.com>wrote:

> Actually the marker annotations would be the perfect solution. One should
> always take care not to dive so deep into the problem that he can't observe
> all possible solutions !
>
> Thanks.
>
> On Wed, Oct 10, 2012 at 9:35 AM, Lance Java <la...@googlemail.com>wrote:
>
>> Let's use a more concrete example. Let's say InterfaceA is Authorizer and
>> InterfaceB is Listener and you want to call both of them "Managers". I
>> don't
>> think you should do this and I think tapestry is forcing good practices
>> onto
>> you. Your service ID's don't seem very descriptive to me. I think it's
>> much
>> better to have service ID's of "ManagersAuthorizer" and a
>> "ManagersListener".
>>
>> On a slightly related topic, tapestry can use a service interface + marker
>> annotation to uniquely identify a service if more than two implementations
>> exist for a service interface
>> (http://tapestry.apache.org/injection-faq.html). Perhaps you could create
>> annotations for Users, Managers and Officers to do what you want?
>>
>>
>>
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/Suggestion-regarding-service-ID-tp5716740p5716752.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: Suggestion regarding service ID

Posted by Muhammad Gelbana <m....@gmail.com>.
Actually the marker annotations would be the perfect solution. One should
always take care not to dive so deep into the problem that he can't observe
all possible solutions !

Thanks.

On Wed, Oct 10, 2012 at 9:35 AM, Lance Java <la...@googlemail.com>wrote:

> Let's use a more concrete example. Let's say InterfaceA is Authorizer and
> InterfaceB is Listener and you want to call both of them "Managers". I
> don't
> think you should do this and I think tapestry is forcing good practices
> onto
> you. Your service ID's don't seem very descriptive to me. I think it's much
> better to have service ID's of "ManagersAuthorizer" and a
> "ManagersListener".
>
> On a slightly related topic, tapestry can use a service interface + marker
> annotation to uniquely identify a service if more than two implementations
> exist for a service interface
> (http://tapestry.apache.org/injection-faq.html). Perhaps you could create
> annotations for Users, Managers and Officers to do what you want?
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Suggestion-regarding-service-ID-tp5716740p5716752.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: Suggestion regarding service ID

Posted by Lance Java <la...@googlemail.com>.
Let's use a more concrete example. Let's say InterfaceA is Authorizer and
InterfaceB is Listener and you want to call both of them "Managers". I don't
think you should do this and I think tapestry is forcing good practices onto
you. Your service ID's don't seem very descriptive to me. I think it's much
better to have service ID's of "ManagersAuthorizer" and a
"ManagersListener".

On a slightly related topic, tapestry can use a service interface + marker
annotation to uniquely identify a service if more than two implementations
exist for a service interface
(http://tapestry.apache.org/injection-faq.html). Perhaps you could create
annotations for Users, Managers and Officers to do what you want?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Suggestion-regarding-service-ID-tp5716740p5716752.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