Hi Raul,

I do not know Tapestry, but I know HiveUtils (I wrote it;-)), the
contribution you describe below seems OK to me (at first sight).

However it depends exactly on what you want to achieve.
In particular is your POJO a singleton in your application, or do you need
to inject a new instance every time? From your initial Tapestry example, I
believe it is a singleton, so when using HiveUtils, you should probably put
the "cache" attribute to true to make sure HiveUtils will not create more
than one instance:

<contribution configuration-id="hiveutils.ObjectBuilderObjects">
<object name="globalMenu" cached="true"
class="com.estudiowebs.CMS.DAO.GlobalMenu">
  <inject 
object="service:com.estudiowebs.CMS.services.EntityService" />           
  <inject-arg />
</object>
</contribution>

Please note however that according to the above config (independently of the
cache attribute), you need to use hiveutils.ObjectBuilder service to get the
instance of your object because, you have declared your POJO to require a
runtime argument in the constructor ("<inject-arg/>") which means the
constructor for it should look like:
        public GlobalMenu(com.estudiowebs.CMS.services.EntityService
service,
                                MyArgType myarg) {...
NB: MyArgType can be any type.

Then to get the instance of your POJO you need to do:

ObjectBuilder builder =...
GlobalMenu globaleMenu = builder.create("globalMenu", myArg);

where myArg is of type MyArgType.

Is this what you want to do?
Do you really need the extra runtime argument?
If not then it would make it easier to inject globalMenu into other objects,
services, or configurations by using:
        "object:globalMenu"

I hope it gives you a better view of what you can do and how you can do it,
now if you need further precisions or if you want to give more details about
what you want to do, you are welcome.

One last point: HiveUtils is part of the HiveMind Utilities project on
SourceForge (formarly known as "hivetranse"), which is independent of
HiveMind and Tapestry (by independent I talk about the involved persons and
the communication channels). So it might be better to proceed with this
discussion on the HiveMind Utilities forums, except if this is a common
Tapestry problem.

Cheers

        Jean-Francois

-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Raul Raja Martinez
Sent: Sunday, December 04, 2005 5:54 AM
To: [email protected]
Subject: Re: Injecting registry services to POJOS

I was trying to do that using hiveutils, sorry, but still very new to 
hivemind and IOC:

<contribution configuration-id="hiveutils.ObjectBuilderObjects">
 
<objectname="globalMenu"cached="false"class="com.estudiowebs.CMS.DAO.GlobalM
enu">
  <inject 
object="service:com.estudiowebs.CMS.services.EntityService" />           
<inject-arg />
  </object>

</contribution>

I just need and example on how to inject one of my services in one of my 
POJO so that I can access my hibernate session from my pojos.

Thanks.

Raul.


John Coleman wrote:
> HiveMind injects by interface automatically if you use its service builder
> (it will use setter methods of the declared interface type), in Tapestry
> pages you can also use the page to inject services. So you never have to
use
> annotations.
> 
> I don't think it matters about the order of instantiation, HM should
insure
> every service is set up with the references it needs.
> 
> John
> 
> ----- Original Message ----- 
> From: "Raul Raja Martinez" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Saturday, December 03, 2005 11:46 AM
> Subject: Injecting registry services to POJOS
> 
> 
>> Hi,
>>
>> I have a service in my hivemodule.xml that I'd like to inject in a Pojo
>> that at the same time gets loaded as a an application scope object at
>> startup:
>>
>> <contribution configuration-id="tapestry.state.ApplicationObjects">
>> <state-object name="globalMenu" scope="application">
>>   <create-instance class="com.estudiowebs.CMS.DAO.GlobalMenu" />
>> </state-object>
>> </contribution>
>>
>> This is an object that I load from the database once at startup and I
>> need to inject my Hivetranse Hibernate3 session service into it so that
>> I use that service for loading the object.
>> Since annotations like @InjectObject are not allowed in regular POJOS
>> and I don't have access to the Tapestry Registry, I don't really know
>> what would be the best way to solve this problem
>>
>> On the other side I have in the same application a couple of servlets
>> that serve as XML source for a Laszlo application, and I have the same
>> problem.
>>
>> Any help is appreciated.
>>
>>
>> I'd really love to be able to @InjectObject("service....") anywhere
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to