You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by "karthik.nar" <ka...@gmail.com> on 2006/10/13 09:19:41 UTC
Re: Using Hivemind in an existing application
catalin,
were you able to figure a way to use a static method in point#2 below?
2. In point two, I meant some sort of <create-object> that uses a static
getInstance method instead of calling the constructor.
i have a requirement where i want to pass a new instance of an apache
commons Log object from the Logger in the
<invoke-factory>
<construct class=blah>
<set-object property="log"
value="instance:@org.apache.log4j.Logger@getLog()" />
</construct>
</invoke-factory>
I've not be able to figure out how to do it!
<set-object property="log"
value="instance:@org.apache.log4j.Logger@getLog()" />
or
<set-object property="log"
value="instance:org.apache.log4j.Logger.getLog()" />
or anything else?!
--
View this message in context: http://www.nabble.com/Using-Hivemind-in-an-existing-application-tf165498.html#a6790990
Sent from the Hivemind - User mailing list archive at Nabble.com.
RE: Using Hivemind in an existing application
Posted by James Carman <ja...@carmanconsulting.com>.
The idea Knut proposed was that you come up with a single place to ask for
your HiveMind registry...
public class HiveMindRegistry
{
private static final Regisry instance =
RegistryBuilder.constructDefaultRegistry();
public static Registry getInstance()
{
return instance;
}
}
Then, in your singleton service's getInstance() method:
public static MyService
{
public static MyService getInstance()
{
return ( MyService
)HiveMindRegistry.getInstance().getService(MyService.class);
}
}
Of course, in a real dependency injection-oriented system, you'd just
declare setters for the MyService and HiveMind would inject it for you
rather than looking up the singleton using a getInstance() method. But,
Catalin said that she wanted to gradually migrate to HiveMind, so I guess
that's not possible.
-----Original Message-----
From: karthik.nar [mailto:karthik.nar@gmail.com]
Sent: Friday, October 13, 2006 3:20 AM
To: user@hivemind.apache.org
Subject: Re: Using Hivemind in an existing application
catalin,
were you able to figure a way to use a static method in point#2 below?
2. In point two, I meant some sort of <create-object> that uses a static
getInstance method instead of calling the constructor.
i have a requirement where i want to pass a new instance of an apache
commons Log object from the Logger in the
<invoke-factory>
<construct class=blah>
<set-object property="log"
value="instance:@org.apache.log4j.Logger@getLog()" />
</construct>
</invoke-factory>
I've not be able to figure out how to do it!
<set-object property="log"
value="instance:@org.apache.log4j.Logger@getLog()" />
or
<set-object property="log"
value="instance:org.apache.log4j.Logger.getLog()" />
or anything else?!
--
View this message in context:
http://www.nabble.com/Using-Hivemind-in-an-existing-application-tf165498.htm
l#a6790990
Sent from the Hivemind - User mailing list archive at Nabble.com.