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/engine/state/StateObjectFactory.html http://jakarta.apache.org/tapestry/tapestry/hivedocs/config/tapestry.state.FactoryObjects.html http://jakarta.apache.org/tapestry/tapestry/hivedocs/config/tapestry.state.ApplicationObjects.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]
