You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Roberto Fasciolo <ro...@eget.fi> on 2007/03/08 15:10:43 UTC

Dynamically access services inside a service

Hello, I'm working now on a prototype for evaluating HiveMind in our company.
I need to do something like that:

1. One service receiving via configuration a list of other services (all
implementing the same interface)
2. That service at runtime (basing on its input parameters) chooses the
right service from that list and invokes it.

For doing that I've written something like this:

- configuration (hivemodule.xml):
	<service-point id="BarAction" interface="Action">
		<invoke-factory model="singleton">
			<construct class="actions.BarAction" />
		</invoke-factory>
	</service-point>
        (...)
	<contribution configuration-id="foo.FooActions">
		<action name="bar" action="foo.BarAction" />
	</contribution>

- service:
        Registry registry = RegistryBuilder.constructDefaultRegistry();
        (...)
            Action action = (Action)
registry.getService(configuration.getAction(),
                    Action.class);

Is that the only way for doing that? I would like not to use RegistryBuilder
inside my services, perhaps having in the configuration something as
(a-la-tapestry):
		<action name="bar" action="service:BarAction" />

Is it possible?

Thanks in advance
-- 
View this message in context: http://www.nabble.com/Dynamically-access-services-inside-a-service-tf3369117.html#a9374167
Sent from the Hivemind - User mailing list archive at Nabble.com.


Re: Dynamically access services inside a service

Posted by James Carman <jc...@carmanconsulting.com>.
I'd probably do it like this:

<action name="bar" object="service:foo.Bar" />


On 3/8/07, Roberto Fasciolo <ro...@eget.fi> wrote:
>
>
> Hello, I'm working now on a prototype for evaluating HiveMind in our
> company.
> I need to do something like that:
>
> 1. One service receiving via configuration a list of other services (all
> implementing the same interface)
> 2. That service at runtime (basing on its input parameters) chooses the
> right service from that list and invokes it.
>
> For doing that I've written something like this:
>
> - configuration (hivemodule.xml):
>         <service-point id="BarAction" interface="Action">
>                 <invoke-factory model="singleton">
>                         <construct class="actions.BarAction" />
>                 </invoke-factory>
>         </service-point>
>         (...)
>         <contribution configuration-id="foo.FooActions">
>                 <action name="bar" action="foo.BarAction" />
>         </contribution>
>
> - service:
>         Registry registry = RegistryBuilder.constructDefaultRegistry();
>         (...)
>             Action action = (Action)
> registry.getService(configuration.getAction(),
>                     Action.class);
>
> Is that the only way for doing that? I would like not to use
> RegistryBuilder
> inside my services, perhaps having in the configuration something as
> (a-la-tapestry):
>                 <action name="bar" action="service:BarAction" />
>
> Is it possible?
>
> Thanks in advance
> --
> View this message in context:
> http://www.nabble.com/Dynamically-access-services-inside-a-service-tf3369117.html#a9374167
> Sent from the Hivemind - User mailing list archive at Nabble.com.
>
>