hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <>
Subject RE: Injecting java.util.Properties constructor argument type
Date Tue, 25 Apr 2006 10:16:42 GMT
Is a custom service implementation factory really that difficult to write?



From: Felix Sun [] 
Sent: Tuesday, April 25, 2006 5:28 AM
Subject: Re: Injecting java.util.Properties constructor argument type


I have tried to simulate to situation, It seems like the only works in mode
*primitive*, but It works, It may be useful to you.
Is this seems like your Legacy code? and I add exec() method and the
interface for test purpose. 

public class LegacyCode implements Executable{
    private Properties prop;
    public LegacyCode(Properties prop) {
        this.prop = prop;

    public void exec() {
        System.out.println ("This is your properties: " + prop);

write a MyProperties that extends Properties that can get pairs from

public class MyProperties extends Properties{ 
    public void setValues(Map values){

then the hivemind.xml

    <service-point id="LegacyService" interface="Executable">
            <construct class="LegacyCode">
    <service-point id="MyProperties" interface="java.util.Map">
        <invoke-factory model="primitive">
            <construct class="MyProperties"> 
                <set-configuration property="values"

though the MyProperties service 's interface is java.util.Map, but I can be
injected to LegacyService by constructor.
because the service mode is *primitive* I think.

- Felix Sun

On 4/20/06, Eduardo Sherington <> wrote:


I've just started using Hivemind inside of Tapestry 4.x and I have some nice
services defined. I am happy with simple configuration of those services
using constructor parameter injection and I am happy with services being 
injected with references to other services.

However, I'm really struggling with something that on the face of it is I'm
sure blindingly obvious to Hivemind veterans but for a newcomer to the
project it really isn't obvious at all... 

My problem is that I have a legacy class that I have no control over, but I
want to use this class as a service. That class has a single constructor
parameter of type java.util.Properties and this is the ONLY way to set the 
configuration for that class.

What I thought should be easy to do is to define in my hivemind xml
configuration file some key/attribute values that would get translated to a
Properties object and automatically injected for me. 

I just have no idea how to do this.

I've been googling for hours, trying to parse the hivemind examples and test
cases and to be honest I'm a bit lost!

I know that I could probably wrap that legacy object in one of my own, 
configure my own class and pass the configuration on but I didn't want to
admit defeat just yet, and I don't really want to duplicate the entire API
of that legacy object on my own class.

I'd appreciate any pointers or examples anyone could give. 


To unsubscribe, e-mail: 
For additional commands, e-mail:


View raw message