<create-instance
> class="com.estudiowebs.CMS.DAO.GlobalMenu">
> <!-- set-service not allowed here -->
> <set-service property="entityService"
> service-id="EntityService" />
> </create-instance>
Instead of create-instance, have you tried
invoke-factory ?
<invoke-factory>
<construct
class="com.estudiowebs.CMS.DAO.GlobalMenu">
<set-service property="entityService"
service-id="EntityService" />
</construct>
</invoke-factory>
Shing
--- Raul Raja Martinez <[EMAIL PROTECTED]>
wrote:
> Here is a little bit more code about my problem:
>
> I'm trying to inject a service in one of mi POJO
> that is an application
> scope object in my Tapestry App.
>
> I tried many things and now I'm trying the following
> but it doesn't work
> either.
>
> <contribution
>
configuration-id="tapestry.state.ApplicationObjects">
> <state-object name="GlobalMenu"
> scope="application">
> <create-instance
> class="com.estudiowebs.CMS.DAO.GlobalMenu">
> <!-- set-service not allowed here -->
> <set-service property="entityService"
> service-id="EntityService" />
> </create-instance>
> </state-object>
> </contribution>
>
>
> public class GlobalMenu extends Menu implements
> IGlobalMenuDAO {
>
> private static final long serialVersionUID = 1L;
>
> private EntityService entityService;
>
> public void setEntityService(EntityService
> entityService) {
> this.entityService = entityService;
> }
>
> public GlobalMenu() {
> Menu m = null;
> m = (Menu) entityService.load(Menu.class, new
> Integer(1));
> }
>
> }
>
> I'd like to know what would be the right way to
> inject a service in a pojo.
>
>
> Thanks
>
> Raul.
>
>
>
> Raul Raja Martinez wrote:
> > I am using the hivemind utilities Hibernate3
> session as in
> >
>
http://hivetranse.sourceforge.net/quickstart.html#start.config.hibernate3
> >
> > I can inject it in my regular servlets using the
> following:
> >
> >
> > EntityService service =
> (EntityService)HiveMindFilter
> > .getRegistry(request)
> >
>
.getService(com.estudiowebs.CMS.services.EntityService.class);
> >
> >
> > I can aslo inject it into components and pages
> using annotations such as
> > @InjectObject(service:...).
> >
> > but when it comes to Pojos I didn't know what
> would be the right
> > approach, I'll try your method, thanks.
> >
> > Raul.
> >
> >
> >
> >
> >
> > Jesse Kuhnert wrote:
> >> Ummm....You can get access to the Registry
> object, but it's not easy, and
> >> for a good reason.
> >>
> >> ~Anything~ in tapestry can have a hivemind
> service injected into it.
> >> Esp a
> >> hivemind service, or a DAO, which is what you are
> doing right? I
> >> don't know
> >> what all of your crazy configs are doing, but I
> have a hibernate hivemind
> >> service point that looks sort of like:
> >>
> >> <service-point id="SessionProxy"
> interface="org.hibernate.Session">
> >> ...//threaded
> >> </service>
> >>
> >> I then take this hibernate session, bound to my
> web thread(or POJO
> >> service
> >> thread, or JMS queue thread, or whatever other
> fun threads I want to
> >> use :)
> >> ), and use it without thinking. Sometimes it's
> in pages/components, but
> >> most often I create a simple DAO that might look
> like:
> >>
> >> <service-point id="SomeDAO" >
> >> <construct class="com.foo.SomeDAOImpl">
> >> <set-service id="SessionProxy" property="session"
> />
> >> </construct>
> >> </service>
> >>
> >> Something like that.. Is this what you're doing?
> >> On 12/4/05, Raul Raja Martinez
> <[EMAIL PROTECTED]> wrote:
> >>> 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"
> />
>
=== message truncated ===
Home page :
http://uk.geocities.com/matmsh/index.html
___________________________________________________________
How much free photo storage do you get? Store your holiday
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]