You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stefan Baur <st...@baurs.ch> on 2013/05/05 20:01:09 UTC

Usage of Tapestry Services from outside of Tapestry.

Hi

I am runnung a card game application within a Tapestry website. For user
management, I use tapestry-hibernate and some tapestry pages to
create/list/etc users.

Withing the game application, I create my own Hibernate SessionFactory
handle logins in the game.

Is it possible to somehow obtain the SessionFactory from Tapestry instead
of creating a second instance? I am aware that the tapestry context is
registered as a ServletContext parameter, but I have no idea how to
"manually" get an object that would be @Inject-ed in Tapestry context.

Thanks for help.
Stefan

Re: Usage of Tapestry Services from outside of Tapestry.

Posted by Lance Java <la...@googlemail.com>.
tapestry-hibernate provides a singleton hibernate session which can be
looked up from the registry.

This singleton is a proxy to a lazy-loaded, per-thread hibernate session
instance. All service methods invoked on the thread will share the same
hibernate session. You must call either Registry.cleanupThread() or
PerThreadManager.cleanup() to clean up the thread local if you are using
tapestry-hibernate outside of a normal request / response since this is not
managed by tapestry.

 There are two options for handling transactions

1. Annotate your service interface with @CommitAfter - tapestry-hibernate
will then commit() or abort() the transaction automatically.

2. Manage the transaction manually - Lookup the HibernateSessionManager
from the registry and call commit() or abort() yourself.

Re: Usage of Tapestry Services from outside of Tapestry.

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Not sure. The injection aspect should work but I do t use hibernate so I don't really know. 

On May 6, 2013, at 2:01 AM, Stefan Baur <st...@baurs.ch> wrote:

> Thanks.
> Will this also work for a hibernate Session with usage of
> tapestry-hibernate?
> 
> 
> -------
> Stefan Baur
> Schiltwiesenweg 8
> 8404 Winterthur
> ---
> 
> 
> 
> 2013/5/6 Lenny Primak <lp...@hope.nyc.ny.us>
> 
>> 
>> http://code.google.com/p/flowlogix/source/browse/tapestry-services/src/main/java/com/flowlogix/util/ExternalServiceUtil.java
>> 
>> Use this function to locate your service by class ID. It works exactly
>> like @Inject.
>> 
>> 
>> On May 5, 2013, at 1:01 PM, Stefan Baur <st...@baurs.ch> wrote:
>> 
>>> Hi
>>> 
>>> I am runnung a card game application within a Tapestry website. For user
>>> management, I use tapestry-hibernate and some tapestry pages to
>>> create/list/etc users.
>>> 
>>> Withing the game application, I create my own Hibernate SessionFactory
>>> handle logins in the game.
>>> 
>>> Is it possible to somehow obtain the SessionFactory from Tapestry instead
>>> of creating a second instance? I am aware that the tapestry context is
>>> registered as a ServletContext parameter, but I have no idea how to
>>> "manually" get an object that would be @Inject-ed in Tapestry context.
>>> 
>>> Thanks for help.
>>> Stefan
>> 
>> ---------------------------------------------------------------------
>> 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: Usage of Tapestry Services from outside of Tapestry.

Posted by Stefan Baur <st...@baurs.ch>.
Thanks.
Will this also work for a hibernate Session with usage of
tapestry-hibernate?


-------
Stefan Baur
Schiltwiesenweg 8
8404 Winterthur
---



2013/5/6 Lenny Primak <lp...@hope.nyc.ny.us>

>
> http://code.google.com/p/flowlogix/source/browse/tapestry-services/src/main/java/com/flowlogix/util/ExternalServiceUtil.java
>
> Use this function to locate your service by class ID. It works exactly
> like @Inject.
>
>
> On May 5, 2013, at 1:01 PM, Stefan Baur <st...@baurs.ch> wrote:
>
> > Hi
> >
> > I am runnung a card game application within a Tapestry website. For user
> > management, I use tapestry-hibernate and some tapestry pages to
> > create/list/etc users.
> >
> > Withing the game application, I create my own Hibernate SessionFactory
> > handle logins in the game.
> >
> > Is it possible to somehow obtain the SessionFactory from Tapestry instead
> > of creating a second instance? I am aware that the tapestry context is
> > registered as a ServletContext parameter, but I have no idea how to
> > "manually" get an object that would be @Inject-ed in Tapestry context.
> >
> > Thanks for help.
> > Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Usage of Tapestry Services from outside of Tapestry.

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
http://code.google.com/p/flowlogix/source/browse/tapestry-services/src/main/java/com/flowlogix/util/ExternalServiceUtil.java

Use this function to locate your service by class ID. It works exactly like @Inject. 


On May 5, 2013, at 1:01 PM, Stefan Baur <st...@baurs.ch> wrote:

> Hi
> 
> I am runnung a card game application within a Tapestry website. For user
> management, I use tapestry-hibernate and some tapestry pages to
> create/list/etc users.
> 
> Withing the game application, I create my own Hibernate SessionFactory
> handle logins in the game.
> 
> Is it possible to somehow obtain the SessionFactory from Tapestry instead
> of creating a second instance? I am aware that the tapestry context is
> registered as a ServletContext parameter, but I have no idea how to
> "manually" get an object that would be @Inject-ed in Tapestry context.
> 
> Thanks for help.
> Stefan

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