You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Norman Franke <no...@myasd.com> on 2007/07/12 17:51:59 UTC

T4 Pre-Initialization?

I've been integrating Tapestry 4.0.x into my existing web application  
based on JSP and servlets. It's all been going quite well so far.

I've been using Hibernate for database access in Tapestry, but was  
using JDBC in the old servlet code. (Since it was developed pre- 
hibernate.) Anyway, I want to start using Hibernate (via HiveMind) in  
my servlet code. The question is, how do I get a reference to it?

I can do this via:

RegistryInfrastructure reg = (RegistryInfrastructure)  
ServiceSerializationHelper.getServiceSerializationSupport();

And then call getService(MyDesiredDAO.class, null). That seems to  
work. When Tomcat starts up, Tapestry doesn't initialize and  
getService throws exception stating that HiveMind has not been  
configured.

The question is, how can I force HiveMind to initialize or initialize  
it myself and not mess up Tapestry?

Norman Franke


Re: T4 Pre-Initialization?

Posted by Igor Drobiazko <ig...@gmail.com>.
Hi,

please look here to construct the Registry:
http://hivemind.apache.org/hivemind1/filter.html

Then create your DAO like this:

Registry registry = HiveMindFilter.getRegistry( request );
registry.getService(MyDesiredDAO.class);


On 7/12/07, Norman Franke <no...@myasd.com> wrote:
>
> My question was how to get a reference to a HiveMind service
> (Hibernate based here) from a non-Tapestry servlet prior to Tapestry
> initializing HiveMind.
>
> -Norman
>
> On Jul 12, 2007, at 12:14 PM, Renat Zubairov wrote:
>
> > Hi
> >
> > In hivemind you don't need (shouldnt) use singletons anymore since
> > they are hindering the unit testing.
> > Since you are using plain configuration (hivemind + tapestry) you
> > actually don't need to do anything at all :) (almost) you just need to
> > use hivemind + Tapestry + one of the hibernate integration module such
> > as honeycomb or tapernate.
> >
> > I can't say anything about tapernate because we are using honeycomb.
> >
> > If you need a session in your page you simply create an abstract
> > getter
> >
> > public abstract Session getSession()
> >
> > and declare that it should be populated with the hibernate session
> > from honeycomb (you can check exmaples in the sample application you
> > can easily generate with honeycomb archetype and maven).
> >
> > If you need more examples i can post some code fragments here.
> >
> > Renat
> >
> > P.S. Honeycomb author is actively participating in this mail list so I
> > think he would be glad to answer your questions
> >
> > On 12/07/07, Norman Franke <no...@myasd.com> wrote:
> >> I've been integrating Tapestry 4.0.x into my existing web application
> >> based on JSP and servlets. It's all been going quite well so far.
> >>
> >> I've been using Hibernate for database access in Tapestry, but was
> >> using JDBC in the old servlet code. (Since it was developed pre-
> >> hibernate.) Anyway, I want to start using Hibernate (via HiveMind) in
> >> my servlet code. The question is, how do I get a reference to it?
> >>
> >> I can do this via:
> >>
> >> RegistryInfrastructure reg = (RegistryInfrastructure)
> >> ServiceSerializationHelper.getServiceSerializationSupport();
> >>
> >> And then call getService(MyDesiredDAO.class, null). That seems to
> >> work. When Tomcat starts up, Tapestry doesn't initialize and
> >> getService throws exception stating that HiveMind has not been
> >> configured.
> >>
> >> The question is, how can I force HiveMind to initialize or initialize
> >> it myself and not mess up Tapestry?
> >>
> >> Norman Franke
> >>
> >>
> >
> >
> > --
> > Best regards,
> > Renat Zubairov
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T4 Pre-Initialization?

Posted by Renat Zubairov <re...@gmail.com>.
You can also consider rewriting your own ApplicationServlet
I mean craete a servlet which extends from tapestry ApplicationServlet.
Init method of your servlet will do anything you need and then call
tapestry ApplicationServlet.

Renat

On 13/07/07, Norman Franke <no...@myasd.com> wrote:
> I don't have an issue with Hibernate, I just want to use it before
> Tapestry initializes (since it initializes when first accessed, not
> on container start up despite load-on-startup, at least with Tomcat.)
>
> So, yes, I could initialize HiveMind myself and pass it to Tapestry,
> if I could find out how to do that.
>
> Using HiveMindFilter as Igor suggested seems to work, however.
>
> -Norman
>
> On Jul 12, 2007, at 5:08 PM, Renat Zubairov wrote:
>
> > Hi
> >
> > I'm a bit confused, you want to have a "reference to Hivemind service"
> > _before_ tapestry initalizing Hivemind? It means you want to initalize
> > hivemind your self and then give it to the tapestry?
> > May I ask you what is the issues you have with Hibernate that you want
> > to initialize it before it would be initalized by Honeycomb?
> >
> > Renat
> >
> > On 12/07/07, Norman Franke <no...@myasd.com> wrote:
> >> My question was how to get a reference to a HiveMind service
> >> (Hibernate based here) from a non-Tapestry servlet prior to Tapestry
> >> initializing HiveMind.
> >>
> >> -Norman
> >>
> >> On Jul 12, 2007, at 12:14 PM, Renat Zubairov wrote:
> >>
> >> > Hi
> >> >
> >> > In hivemind you don't need (shouldnt) use singletons anymore since
> >> > they are hindering the unit testing.
> >> > Since you are using plain configuration (hivemind + tapestry) you
> >> > actually don't need to do anything at all :) (almost) you just
> >> need to
> >> > use hivemind + Tapestry + one of the hibernate integration
> >> module such
> >> > as honeycomb or tapernate.
> >> >
> >> > I can't say anything about tapernate because we are using
> >> honeycomb.
> >> >
> >> > If you need a session in your page you simply create an abstract
> >> > getter
> >> >
> >> > public abstract Session getSession()
> >> >
> >> > and declare that it should be populated with the hibernate session
> >> > from honeycomb (you can check exmaples in the sample application
> >> you
> >> > can easily generate with honeycomb archetype and maven).
> >> >
> >> > If you need more examples i can post some code fragments here.
> >> >
> >> > Renat
> >> >
> >> > P.S. Honeycomb author is actively participating in this mail
> >> list so I
> >> > think he would be glad to answer your questions
> >> >
> >> > On 12/07/07, Norman Franke <no...@myasd.com> wrote:
> >> >> I've been integrating Tapestry 4.0.x into my existing web
> >> application
> >> >> based on JSP and servlets. It's all been going quite well so far.
> >> >>
> >> >> I've been using Hibernate for database access in Tapestry, but was
> >> >> using JDBC in the old servlet code. (Since it was developed pre-
> >> >> hibernate.) Anyway, I want to start using Hibernate (via
> >> HiveMind) in
> >> >> my servlet code. The question is, how do I get a reference to it?
> >> >>
> >> >> I can do this via:
> >> >>
> >> >> RegistryInfrastructure reg = (RegistryInfrastructure)
> >> >> ServiceSerializationHelper.getServiceSerializationSupport();
> >> >>
> >> >> And then call getService(MyDesiredDAO.class, null). That seems to
> >> >> work. When Tomcat starts up, Tapestry doesn't initialize and
> >> >> getService throws exception stating that HiveMind has not been
> >> >> configured.
> >> >>
> >> >> The question is, how can I force HiveMind to initialize or
> >> initialize
> >> >> it myself and not mess up Tapestry?
> >> >>
> >> >> Norman Franke
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Best regards,
> >> > Renat Zubairov
> >> >
> >> >
> >> ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > For additional commands, e-mail: users-help@tapestry.apache.org
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Best regards,
> > Renat Zubairov
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Best regards,
Renat Zubairov

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4 Pre-Initialization?

Posted by Norman Franke <no...@myasd.com>.
I don't have an issue with Hibernate, I just want to use it before  
Tapestry initializes (since it initializes when first accessed, not  
on container start up despite load-on-startup, at least with Tomcat.)

So, yes, I could initialize HiveMind myself and pass it to Tapestry,  
if I could find out how to do that.

Using HiveMindFilter as Igor suggested seems to work, however.

-Norman

On Jul 12, 2007, at 5:08 PM, Renat Zubairov wrote:

> Hi
>
> I'm a bit confused, you want to have a "reference to Hivemind service"
> _before_ tapestry initalizing Hivemind? It means you want to initalize
> hivemind your self and then give it to the tapestry?
> May I ask you what is the issues you have with Hibernate that you want
> to initialize it before it would be initalized by Honeycomb?
>
> Renat
>
> On 12/07/07, Norman Franke <no...@myasd.com> wrote:
>> My question was how to get a reference to a HiveMind service
>> (Hibernate based here) from a non-Tapestry servlet prior to Tapestry
>> initializing HiveMind.
>>
>> -Norman
>>
>> On Jul 12, 2007, at 12:14 PM, Renat Zubairov wrote:
>>
>> > Hi
>> >
>> > In hivemind you don't need (shouldnt) use singletons anymore since
>> > they are hindering the unit testing.
>> > Since you are using plain configuration (hivemind + tapestry) you
>> > actually don't need to do anything at all :) (almost) you just  
>> need to
>> > use hivemind + Tapestry + one of the hibernate integration  
>> module such
>> > as honeycomb or tapernate.
>> >
>> > I can't say anything about tapernate because we are using  
>> honeycomb.
>> >
>> > If you need a session in your page you simply create an abstract
>> > getter
>> >
>> > public abstract Session getSession()
>> >
>> > and declare that it should be populated with the hibernate session
>> > from honeycomb (you can check exmaples in the sample application  
>> you
>> > can easily generate with honeycomb archetype and maven).
>> >
>> > If you need more examples i can post some code fragments here.
>> >
>> > Renat
>> >
>> > P.S. Honeycomb author is actively participating in this mail  
>> list so I
>> > think he would be glad to answer your questions
>> >
>> > On 12/07/07, Norman Franke <no...@myasd.com> wrote:
>> >> I've been integrating Tapestry 4.0.x into my existing web  
>> application
>> >> based on JSP and servlets. It's all been going quite well so far.
>> >>
>> >> I've been using Hibernate for database access in Tapestry, but was
>> >> using JDBC in the old servlet code. (Since it was developed pre-
>> >> hibernate.) Anyway, I want to start using Hibernate (via  
>> HiveMind) in
>> >> my servlet code. The question is, how do I get a reference to it?
>> >>
>> >> I can do this via:
>> >>
>> >> RegistryInfrastructure reg = (RegistryInfrastructure)
>> >> ServiceSerializationHelper.getServiceSerializationSupport();
>> >>
>> >> And then call getService(MyDesiredDAO.class, null). That seems to
>> >> work. When Tomcat starts up, Tapestry doesn't initialize and
>> >> getService throws exception stating that HiveMind has not been
>> >> configured.
>> >>
>> >> The question is, how can I force HiveMind to initialize or  
>> initialize
>> >> it myself and not mess up Tapestry?
>> >>
>> >> Norman Franke
>> >>
>> >>
>> >
>> >
>> > --
>> > Best regards,
>> > Renat Zubairov
>> >
>> >  
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> -- 
> Best regards,
> Renat Zubairov
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4 Pre-Initialization?

Posted by Renat Zubairov <re...@gmail.com>.
Hi

I'm a bit confused, you want to have a "reference to Hivemind service"
_before_ tapestry initalizing Hivemind? It means you want to initalize
hivemind your self and then give it to the tapestry?
May I ask you what is the issues you have with Hibernate that you want
to initialize it before it would be initalized by Honeycomb?

Renat

On 12/07/07, Norman Franke <no...@myasd.com> wrote:
> My question was how to get a reference to a HiveMind service
> (Hibernate based here) from a non-Tapestry servlet prior to Tapestry
> initializing HiveMind.
>
> -Norman
>
> On Jul 12, 2007, at 12:14 PM, Renat Zubairov wrote:
>
> > Hi
> >
> > In hivemind you don't need (shouldnt) use singletons anymore since
> > they are hindering the unit testing.
> > Since you are using plain configuration (hivemind + tapestry) you
> > actually don't need to do anything at all :) (almost) you just need to
> > use hivemind + Tapestry + one of the hibernate integration module such
> > as honeycomb or tapernate.
> >
> > I can't say anything about tapernate because we are using honeycomb.
> >
> > If you need a session in your page you simply create an abstract
> > getter
> >
> > public abstract Session getSession()
> >
> > and declare that it should be populated with the hibernate session
> > from honeycomb (you can check exmaples in the sample application you
> > can easily generate with honeycomb archetype and maven).
> >
> > If you need more examples i can post some code fragments here.
> >
> > Renat
> >
> > P.S. Honeycomb author is actively participating in this mail list so I
> > think he would be glad to answer your questions
> >
> > On 12/07/07, Norman Franke <no...@myasd.com> wrote:
> >> I've been integrating Tapestry 4.0.x into my existing web application
> >> based on JSP and servlets. It's all been going quite well so far.
> >>
> >> I've been using Hibernate for database access in Tapestry, but was
> >> using JDBC in the old servlet code. (Since it was developed pre-
> >> hibernate.) Anyway, I want to start using Hibernate (via HiveMind) in
> >> my servlet code. The question is, how do I get a reference to it?
> >>
> >> I can do this via:
> >>
> >> RegistryInfrastructure reg = (RegistryInfrastructure)
> >> ServiceSerializationHelper.getServiceSerializationSupport();
> >>
> >> And then call getService(MyDesiredDAO.class, null). That seems to
> >> work. When Tomcat starts up, Tapestry doesn't initialize and
> >> getService throws exception stating that HiveMind has not been
> >> configured.
> >>
> >> The question is, how can I force HiveMind to initialize or initialize
> >> it myself and not mess up Tapestry?
> >>
> >> Norman Franke
> >>
> >>
> >
> >
> > --
> > Best regards,
> > Renat Zubairov
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Best regards,
Renat Zubairov

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4 Pre-Initialization?

Posted by Norman Franke <no...@myasd.com>.
My question was how to get a reference to a HiveMind service  
(Hibernate based here) from a non-Tapestry servlet prior to Tapestry  
initializing HiveMind.

-Norman

On Jul 12, 2007, at 12:14 PM, Renat Zubairov wrote:

> Hi
>
> In hivemind you don't need (shouldnt) use singletons anymore since
> they are hindering the unit testing.
> Since you are using plain configuration (hivemind + tapestry) you
> actually don't need to do anything at all :) (almost) you just need to
> use hivemind + Tapestry + one of the hibernate integration module such
> as honeycomb or tapernate.
>
> I can't say anything about tapernate because we are using honeycomb.
>
> If you need a session in your page you simply create an abstract  
> getter
>
> public abstract Session getSession()
>
> and declare that it should be populated with the hibernate session
> from honeycomb (you can check exmaples in the sample application you
> can easily generate with honeycomb archetype and maven).
>
> If you need more examples i can post some code fragments here.
>
> Renat
>
> P.S. Honeycomb author is actively participating in this mail list so I
> think he would be glad to answer your questions
>
> On 12/07/07, Norman Franke <no...@myasd.com> wrote:
>> I've been integrating Tapestry 4.0.x into my existing web application
>> based on JSP and servlets. It's all been going quite well so far.
>>
>> I've been using Hibernate for database access in Tapestry, but was
>> using JDBC in the old servlet code. (Since it was developed pre-
>> hibernate.) Anyway, I want to start using Hibernate (via HiveMind) in
>> my servlet code. The question is, how do I get a reference to it?
>>
>> I can do this via:
>>
>> RegistryInfrastructure reg = (RegistryInfrastructure)
>> ServiceSerializationHelper.getServiceSerializationSupport();
>>
>> And then call getService(MyDesiredDAO.class, null). That seems to
>> work. When Tomcat starts up, Tapestry doesn't initialize and
>> getService throws exception stating that HiveMind has not been
>> configured.
>>
>> The question is, how can I force HiveMind to initialize or initialize
>> it myself and not mess up Tapestry?
>>
>> Norman Franke
>>
>>
>
>
> -- 
> Best regards,
> Renat Zubairov
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4 Pre-Initialization?

Posted by Renat Zubairov <re...@gmail.com>.
Hi

In hivemind you don't need (shouldnt) use singletons anymore since
they are hindering the unit testing.
Since you are using plain configuration (hivemind + tapestry) you
actually don't need to do anything at all :) (almost) you just need to
use hivemind + Tapestry + one of the hibernate integration module such
as honeycomb or tapernate.

I can't say anything about tapernate because we are using honeycomb.

If you need a session in your page you simply create an abstract getter

public abstract Session getSession()

and declare that it should be populated with the hibernate session
from honeycomb (you can check exmaples in the sample application you
can easily generate with honeycomb archetype and maven).

If you need more examples i can post some code fragments here.

Renat

P.S. Honeycomb author is actively participating in this mail list so I
think he would be glad to answer your questions

On 12/07/07, Norman Franke <no...@myasd.com> wrote:
> I've been integrating Tapestry 4.0.x into my existing web application
> based on JSP and servlets. It's all been going quite well so far.
>
> I've been using Hibernate for database access in Tapestry, but was
> using JDBC in the old servlet code. (Since it was developed pre-
> hibernate.) Anyway, I want to start using Hibernate (via HiveMind) in
> my servlet code. The question is, how do I get a reference to it?
>
> I can do this via:
>
> RegistryInfrastructure reg = (RegistryInfrastructure)
> ServiceSerializationHelper.getServiceSerializationSupport();
>
> And then call getService(MyDesiredDAO.class, null). That seems to
> work. When Tomcat starts up, Tapestry doesn't initialize and
> getService throws exception stating that HiveMind has not been
> configured.
>
> The question is, how can I force HiveMind to initialize or initialize
> it myself and not mess up Tapestry?
>
> Norman Franke
>
>


-- 
Best regards,
Renat Zubairov

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4 Pre-Initialization?

Posted by Steve Shucker <ss...@vmsinfo.com>.
The registry is initialized in tapestry's ApplicationServlet.init().  In 
web.xml, you need to specify <load-on-startup>1</load-on-startup> for 
the servlet configuration.  This will force ApplicationServlet.init() to 
run when the application is deployed instead of the first time a 
tapestry page is hit.

-Steve

Norman Franke wrote:
> I've been integrating Tapestry 4.0.x into my existing web application 
> based on JSP and servlets. It's all been going quite well so far.
>
> I've been using Hibernate for database access in Tapestry, but was 
> using JDBC in the old servlet code. (Since it was developed 
> pre-hibernate.) Anyway, I want to start using Hibernate (via HiveMind) 
> in my servlet code. The question is, how do I get a reference to it?
>
> I can do this via:
>
> RegistryInfrastructure reg = (RegistryInfrastructure) 
> ServiceSerializationHelper.getServiceSerializationSupport();
>
> And then call getService(MyDesiredDAO.class, null). That seems to 
> work. When Tomcat starts up, Tapestry doesn't initialize and 
> getService throws exception stating that HiveMind has not been 
> configured.
>
> The question is, how can I force HiveMind to initialize or initialize 
> it myself and not mess up Tapestry?
>
> Norman Franke
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org