Dynamically access services inside a service

View: New views
2 Messages — Rating Filter:   Alert me  

Dynamically access services inside a service

by Roberto Fasciolo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: Dynamically access services inside a service

by James Carman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd probably do it like this:

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


On 3/8/07, Roberto Fasciolo <roberto.fasciolo@...> 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.