You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by "ryan@unrighteousdominion.com" <ry...@unrighteousdominion.com> on 2006/10/31 18:58:14 UTC

setting list parameters

I have a service that has method like "setMyCustomServices(List 
services)" but I can't figure out how to set this in the hivemind module 
descriptor. This is what I tried:

<service-point id="SomeService" interface="SomeServiceInterface">
        <invoke-factory>
            <construct class="SomeServiceImpl" >
                <set-service property="myCustomServices">
                    <list>
                        <service-id>service.MyCustomServiceX</service-id>
                        <service-id>service.MyCustomServiceY</service-id>
                        <service-id>service.MyCustomServiceZ</service-id>
                    </list>
                </set-service>
            </construct>
        </invoke-factory>
    </service-point>

I looked at using configuration points, but that seems like more 
complexity than is necessary.

Anyone know the best way to do this?

Thanks

Re: setting list parameters

Posted by "ryan@unrighteousdominion.com" <ry...@unrighteousdominion.com>.
$25 Amazon Gift Certificate to the person that helps me solve this.

I've got one right here.

ryan@unrighteousdominion.com wrote:
> I have a service that has method like "setMyCustomServices(List 
> services)" but I can't figure out how to set this in the hivemind 
> module descriptor. This is what I tried:
>
> <service-point id="SomeService" interface="SomeServiceInterface">
>        <invoke-factory>
>            <construct class="SomeServiceImpl" >
>                <set-service property="myCustomServices">
>                    <list>
>                        <service-id>service.MyCustomServiceX</service-id>
>                        <service-id>service.MyCustomServiceY</service-id>
>                        <service-id>service.MyCustomServiceZ</service-id>
>                    </list>
>                </set-service>
>            </construct>
>        </invoke-factory>
>    </service-point>
>
> I looked at using configuration points, but that seems like more 
> complexity than is necessary.
>
> Anyone know the best way to do this?
>
> Thanks
>
>


Re: setting list parameters

Posted by Knut Wannheden <kn...@gmail.com>.
Ryan,

Using a configuration point would probably be the most natural way to
do this. But if you prefer there are other possibilities. But these
would require you to write some Java code.

One alternative would be to implement an object provider. With that
(let's call it service-list) you'd set the property as follows:

<set-object property="myCustomServices"
value="service-list:service.MyCustomServiceX,service.MyCustomServiceY,service.MyCustomServiceZ"/>

You contribute this object provider as a service to the configuration
hivemind.ObjectProviders:

  <service-point id="ServiceListObjectProvider"
interface="org.apache.hivemind.service.ObjectProvider"
visibility="private">
    <create-instance class="service.impl.ServiceListObjectProvider"/>
  </service-point>

  <contribution configuration-id="hivemind.ObjectProviders">
    <provider prefix="service" service-id="ServiceListObjectProvider"/>
  </contribution>

Now it's just a matter of implementing the ServiceListObjectProvider
class which should be straight forward.

This is all of course more work than a simple configuration. But if
it's a common pattern in your code it might make sense.

HTH,

--knut

BTW Don't worry about the gift certificate :-)

On 10/31/06, ryan@unrighteousdominion.com <ry...@unrighteousdominion.com> wrote:
> I have a service that has method like "setMyCustomServices(List
> services)" but I can't figure out how to set this in the hivemind module
> descriptor. This is what I tried:
>
> <service-point id="SomeService" interface="SomeServiceInterface">
>         <invoke-factory>
>             <construct class="SomeServiceImpl" >
>                 <set-service property="myCustomServices">
>                     <list>
>                         <service-id>service.MyCustomServiceX</service-id>
>                         <service-id>service.MyCustomServiceY</service-id>
>                         <service-id>service.MyCustomServiceZ</service-id>
>                     </list>
>                 </set-service>
>             </construct>
>         </invoke-factory>
>     </service-point>
>
> I looked at using configuration points, but that seems like more
> complexity than is necessary.
>
> Anyone know the best way to do this?
>
> Thanks
>