You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by antalk <na...@vankalleveen.net> on 2013/02/28 09:52:22 UTC

Add a getServiceById method to Registry ?

Is it an idea to add a 'getServiceById' method to the Registry ?

The reason:

We are calling Tapestry service methods from a declarative view. We have
some file , say an XML file with a element that says:
action="serviceid$method"

The method is invoked through reflection and the service is looked up by its
'id' because we dont want to specify the full classpath of the matching
interface in the XML part.

Now i have the following solution: ( which i dont know is a good / correct
one )

final List<ServiceActivity> services =
TapestryFilter.getRegistry().getService(ServiceActivityScoreboard.class).getServiceActivity();
				for (ServiceActivity service:services) {
					if (service.getServiceId().equals(serviceid) {
						final Object o =
TapestryFilter.getRegistry().getService(service.getServiceInterface());
						return o.getClass().getMethod(method, null).invoke(o, null);
					}
				}


It would be much easier to just have a method 'getServiceByID' which i think
can be used in other situations as well.

Thx



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Add-a-getServiceById-method-to-Registry-tp5720273.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: Add a getServiceById method to Registry ?

Posted by antalk <na...@vankalleveen.net>.
Just tested and it works ! , hmm never thought of this.

Thx !



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Add-a-getServiceById-method-to-Registry-tp5720273p5720278.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: Add a getServiceById method to Registry ?

Posted by Ivan Khalopik <ik...@gmail.com>.
registry.getService("serviceId", Object.class)



On Thu, Feb 28, 2013 at 12:30 PM, antalk <na...@vankalleveen.net> wrote:

> Not really, i still have to specify the full class of the interface.
>
> I just want to get a service by it's ID without specifying any class or
> interface.
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Add-a-getServiceById-method-to-Registry-tp5720273p5720275.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
>
>


-- 
BR
Ivan

Re: Add a getServiceById method to Registry ?

Posted by antalk <na...@vankalleveen.net>.
Not really, i still have to specify the full class of the interface.

I just want to get a service by it's ID without specifying any class or
interface.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Add-a-getServiceById-method-to-Registry-tp5720273p5720275.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: Add a getServiceById method to Registry ?

Posted by Ivan Khalopik <ik...@gmail.com>.
You can use registry.getService(serviceId, serviceInterface)


On Thu, Feb 28, 2013 at 11:52 AM, antalk <na...@vankalleveen.net> wrote:

> Is it an idea to add a 'getServiceById' method to the Registry ?
>
> The reason:
>
> We are calling Tapestry service methods from a declarative view. We have
> some file , say an XML file with a element that says:
> action="serviceid$method"
>
> The method is invoked through reflection and the service is looked up by
> its
> 'id' because we dont want to specify the full classpath of the matching
> interface in the XML part.
>
> Now i have the following solution: ( which i dont know is a good / correct
> one )
>
> final List<ServiceActivity> services =
>
> TapestryFilter.getRegistry().getService(ServiceActivityScoreboard.class).getServiceActivity();
>                                 for (ServiceActivity service:services) {
>                                         if
> (service.getServiceId().equals(serviceid) {
>                                                 final Object o =
> TapestryFilter.getRegistry().getService(service.getServiceInterface());
>                                                 return
> o.getClass().getMethod(method, null).invoke(o, null);
>                                         }
>                                 }
>
>
> It would be much easier to just have a method 'getServiceByID' which i
> think
> can be used in other situations as well.
>
> Thx
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Add-a-getServiceById-method-to-Registry-tp5720273.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
>
>


-- 
BR
Ivan