Re: T5.3 application level singleton cache with Hibernate injection

2012-08-09 Thread Daniel Jue
Thanks Kalle, that was the example I wanted to see.  Is there a way to
force my tapestry-hibernate module to load before my CacheModule , so I can
grab it's configuration?  Right now I'm spinning up a separate hibernate
configuration, and then manually loading classes into that configuration.


On Thu, Aug 9, 2012 at 1:05 AM, Kalle Korhonen
kalle.o.korho...@gmail.comwrote:

 On Wed, Aug 8, 2012 at 9:46 PM, Daniel Jue teamp...@gmail.com wrote:
  Problem:
  I want to initialize this cache on server startup, before any pages are
  served, since it can take a few minutes.
  I want to pass it session from tapestry hibernate, since I use that
  configuration in the pages (I'm guessing there is some way to get an
  instance of HibernateSessionSource)
  I'm sure I could brute force a way to load it's own
 HibernateSessionManager
  and then read stuff into memory, but I wanted to see if I could
  @injectservice somehow.
  The objects being stored in memory are not necessarily hibernate objects,
  but we want to use hibernate to construct the caches.
  Once the in memory cache is created, the session it used to communicate
  with the DB is no longer needed.
  Looking around online, it seems that what I want is closest to a service
  and something like a DAO+Cache.  Again, the DAO part is understandable,
 but
  is there a proper way to get a Hibernate session injected into it at
  startup so it can be built, without having to access any web resource to
  kick it off?

 Yes, create your service (or create a helper service) to start with
 @EagerLoad. Lots of things use this but for an example, you could take
 a look at SeedEntityImpl, an implementation class in Tynamo's
 seedentity module
 (http://tynamo.org/tapestry-hibernate-seedentity+guide).

 Kalle

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




Re: T5.3 application level singleton cache with Hibernate injection

2012-08-09 Thread Kalle Korhonen
On Thu, Aug 9, 2012 at 10:17 AM, Daniel Jue teamp...@gmail.com wrote:
 Thanks Kalle, that was the example I wanted to see.  Is there a way to
 force my tapestry-hibernate module to load before my CacheModule , so I can
 grab it's configuration?  Right now I'm spinning up a separate hibernate
 configuration, and then manually loading classes into that configuration.

Just inject whatever services you need, Tapestry will take care of the
rest. It's not a question of loading modules but in which order the
services are realized.

Kalle


 On Thu, Aug 9, 2012 at 1:05 AM, Kalle Korhonen
 kalle.o.korho...@gmail.comwrote:

 On Wed, Aug 8, 2012 at 9:46 PM, Daniel Jue teamp...@gmail.com wrote:
  Problem:
  I want to initialize this cache on server startup, before any pages are
  served, since it can take a few minutes.
  I want to pass it session from tapestry hibernate, since I use that
  configuration in the pages (I'm guessing there is some way to get an
  instance of HibernateSessionSource)
  I'm sure I could brute force a way to load it's own
 HibernateSessionManager
  and then read stuff into memory, but I wanted to see if I could
  @injectservice somehow.
  The objects being stored in memory are not necessarily hibernate objects,
  but we want to use hibernate to construct the caches.
  Once the in memory cache is created, the session it used to communicate
  with the DB is no longer needed.
  Looking around online, it seems that what I want is closest to a service
  and something like a DAO+Cache.  Again, the DAO part is understandable,
 but
  is there a proper way to get a Hibernate session injected into it at
  startup so it can be built, without having to access any web resource to
  kick it off?

 Yes, create your service (or create a helper service) to start with
 @EagerLoad. Lots of things use this but for an example, you could take
 a look at SeedEntityImpl, an implementation class in Tynamo's
 seedentity module
 (http://tynamo.org/tapestry-hibernate-seedentity+guide).

 Kalle

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



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



T5.3 application level singleton cache with Hibernate injection

2012-08-08 Thread Daniel Jue
After a long hiatus from web development, I have a chance to get back into
Tapestry for a small project.  I kind of need a refresher for an approach I
haven't had to do before:

Context note: Running T5.3 on Tomcat or Jetty, from latest Tynamo release
with Tynamo hibernate/resteasy modules.

Application:
I'm adapting/restructuring an existing application where I have an in
memory, RO cache of several GB in a singleton object.  Requests hit this
cache for some things, and my plan is to have my tapestry pages and rest
services bounce against that.
A call to the custom cache from a page/rest service will take a session in
case it needs to forward the request to databases, etc.
Access from rest services/pages are not a problem because I can just inject
a session and pass it to the cache.
It's a requirement that this cache be in memory.

Problem:
I want to initialize this cache on server startup, before any pages are
served, since it can take a few minutes.
I want to pass it session from tapestry hibernate, since I use that
configuration in the pages (I'm guessing there is some way to get an
instance of HibernateSessionSource)

I'm sure I could brute force a way to load it's own HibernateSessionManager
and then read stuff into memory, but I wanted to see if I could
@injectservice somehow.
The objects being stored in memory are not necessarily hibernate objects,
but we want to use hibernate to construct the caches.
Once the in memory cache is created, the session it used to communicate
with the DB is no longer needed.


Looking around online, it seems that what I want is closest to a service
and something like a DAO+Cache.  Again, the DAO part is understandable, but
is there a proper way to get a Hibernate session injected into it at
startup so it can be built, without having to access any web resource to
kick it off?

Thanks


Re: T5.3 application level singleton cache with Hibernate injection

2012-08-08 Thread Kalle Korhonen
On Wed, Aug 8, 2012 at 9:46 PM, Daniel Jue teamp...@gmail.com wrote:
 Problem:
 I want to initialize this cache on server startup, before any pages are
 served, since it can take a few minutes.
 I want to pass it session from tapestry hibernate, since I use that
 configuration in the pages (I'm guessing there is some way to get an
 instance of HibernateSessionSource)
 I'm sure I could brute force a way to load it's own HibernateSessionManager
 and then read stuff into memory, but I wanted to see if I could
 @injectservice somehow.
 The objects being stored in memory are not necessarily hibernate objects,
 but we want to use hibernate to construct the caches.
 Once the in memory cache is created, the session it used to communicate
 with the DB is no longer needed.
 Looking around online, it seems that what I want is closest to a service
 and something like a DAO+Cache.  Again, the DAO part is understandable, but
 is there a proper way to get a Hibernate session injected into it at
 startup so it can be built, without having to access any web resource to
 kick it off?

Yes, create your service (or create a helper service) to start with
@EagerLoad. Lots of things use this but for an example, you could take
a look at SeedEntityImpl, an implementation class in Tynamo's
seedentity module
(http://tynamo.org/tapestry-hibernate-seedentity+guide).

Kalle

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