Hi Raul,
From what I saw in another of your emails, I guess what you have to do if
you want to use HiveUtils is a config like this:
<contribution configuration-id="hiveutils.ObjectBuilderObjects">
<object name="globalMenu" cached="true"
class="com.estudiowebs.CMS.DAO.GlobalMenu">
<inject name="EntityService"
object="service:com.estudiowebs.CMS.services.EntityService" />
</object>
</contribution>
This will call the default constructor of GlobalMenu and then inject the
EntityService through the setter method.
Now the problem still remains on the Tapestry side: how to inject the pojo
globalMenu to the tapestry.state.ApplicationObjects configuration?
Since I do not have Tapestry on hand I cannot check what is possible to do
in the contributions for this configuration, but I suppose there must be a
way (an attribute) to inject your POJO by using "object:globalMenu".
Now for your question about a HiveMind utilities newsgroup, unfortunately
not (or not yet). The only way currently is to use the online forums (I hate
that but I discovered that my provider's email server was not recognized by
SourceForge so that any mail sent to the SF newsgroup would fail because of
my own email address! Actually I plan to change this addres, but that is not
done yet). Hope to create a mailing list soon.
Cheers
Jean-Francois
<contribution configuration-id="tapestry.state.ApplicationObjects">
<state-object name="globalMenu" scope="application">
<create-instance class="com.estudiowebs.CMS.DAO.GlobalMenu" />
</state-object>
</contribution>
-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Raul Raja Martinez
Sent: Sunday, December 04, 2005 12:36 PM
To: [email protected]
Subject: Re: Injecting registry services to POJOS
Hi Jean-Francois, first of all thanks for your help,
My pojo is basicaly the menu of my webapp, since everybody will have the
same I thought that the best thing would be to make it an application
scope object and fetch the records at startup. since i have already
declared a Hibernate Session service I wanted to inject that service
into this object so that I could use it to query the objects.
I have also many webservices in the same webapp that are not tapestry
related and I'd like to use these services both in the tapestry and
servlets.
I think this is or would be a common problem for Tapestry 4 users.
Many have already asked how to access the Tapestry hivemind registry
from other objects that are not of type Component or Page. My problem is
that I don't even know if this is posible since someone mentioned in
this newsgroup that the Tapestry hivemind registry wasn't available
directly and also annotations like @InjectObject only work within pages
or components.
Anyway, I'll try your solution,
Is there a newsgroup for Hivemind utilities?
Thanks,
Raul.
Jean-Francois Poilpret wrote:
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]
---------------------------------------------------------------------
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]