There is a good example of Hibernate session management in Kent Tong's e-book "Enjoying Web Development with Tapestry" which involves using hivemind to provide thread-local instances of Session objects to request threads in a Tap application. All based on Tap 4.
Highly recommended. -jason On Tuesday 18 October 2005 06:44, Lance Arlaus wrote: > One additional questions: > What's the best way to hook into the request cycle to perform > request-specific setup and cleanup? A good example is opening and closing > a Hibernate session, but there are other resources to manage as well that > aren't owned by specific pages. Currently using the > OpenSessionInViewFilter from Spring for Hibernate, but is there an option > available in Tap4 to accomplish similar tasks? > > -----Original Message----- > From: Lance Arlaus [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 18, 2005 9:27 AM > To: 'Tapestry users' > Subject: RE: Dependency injection within an ASO > > > I'm still digesting this, but isn't there another approach to this? > > Here's what I'm thinking (please let me know if I'm on the right track): > 1. Create a StateObjectPersistenceManager similar to the > SessionScopeManager that uses attributes on the request rather than the > session. > 2. Add the following contribution to the StateObjectPersistenceManagers > configuration point: > <manager scope="request" object="service:RequestScopeManager"/> > 3. Contribute entries to the ApplicationObjects configuration point for > request scoped objects. A sample: > <state-object name="objectPerRequest" scope="request"> > <create-instance class="SomeClass" .../> > </state-object> > 4. Add the following in page(s) to gain access to a shared, per-request > instance > @InjectState("objectPerRequest") > public abstract SomeClass getObjectPerRequest(); > > -Lance > > -----Original Message----- > From: Howard Lewis Ship [mailto:[EMAIL PROTECTED] > Sent: Monday, October 17, 2005 3:27 PM > To: Tapestry users > Subject: Re: Dependency injection within an ASO > > > The general approach is to define you own StateObjectFactory and > inject your dependencies there. It can pass them to the ASO when it > creates it. > > http://jakarta.apache.org/tapestry/tapestry/apidocs/org/apache/tapestry/eng >i ne/state/StateObjectFactory.html > > http://jakarta.apache.org/tapestry/tapestry/hivedocs/config/tapestry.state. >F actoryObjects.html > > http://jakarta.apache.org/tapestry/tapestry/hivedocs/config/tapestry.state. >A pplicationObjects.html > > In theory, you could also create an annotations-driven > StateObjectFactory implementation. > > On 10/17/05, Lance Arlaus <[EMAIL PROTECTED]> wrote: > > I'm currently designing a dependency injection solution for use within > > application state objects that I'd also like to use elsewhere in my > > application. > > > > The idea is simple - I have a set of services that I need to use > > throughout > > > the app for which I don't want to be passing references around. > > A good example is the Vlib sample that ships with Tap4. Taking a look at > > the Visit object, it requires an IRequestCycle object to be passed in to > > get > > > the current user - I'd like to do away with this. > > > > // Copied from Vlib - Visit.java > > // Don't want to be passing this around! > > public Person getUser(IRequestCycle cycle) > > { > > ... > > VirtualLibraryEngine vengine = (VirtualLibraryEngine) > > cycle.getEngine(); > > > _user = vengine.readPerson(_userId); > > ... > > } > > > > What I'd like to do is simply annotate my Visit object and, with the > > right HiveMind configuration, have it retrieve a request specific > > reference to necessary application services. > > Something like the following (additional notes inline): > > > > public class Visit implements Serializable { > > > > /* > > * This should retrieve an object created or retrieved > > * from a pool and bound to the current request (thread). > > * AppServices will have injected objects of its own > > * (references to EJBs, etc.) > > */ > > @InjectObject("service:myapp.services") > > public abstract AppServices getAppServices() > > { > > } > > } > > > > > > Any idea on how to get this to work properly and efficiently (including > > the > > > nested HiveMind annotations within AppServices)? > > > > -Lance > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > Howard M. Lewis Ship > Independent J2EE / Open-Source Java Consultant > Creator, Jakarta Tapestry > Creator, Jakarta HiveMind > > Professional Tapestry training, mentoring, support > and project work. http://howardlewisship.com > > --------------------------------------------------------------------- > 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] -- Jason L. Buberel -- [EMAIL PROTECTED] -- www.buberel.org +1.650.483.1989 -- jabber:[EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
