I have noticed that in the retrieveVisit method of InjectStateWorker.java : visit = (Visit) _applicationStateManager.get("visit") ;
But in the hivemodule.xml, the state object name is 'Visit' with a captial V. You might like to rename 'visit' to something else. I do not know whether it would conflict with the default visit object (the one that could be specified in .application.) I have written up an example on injecting an aso into a service and put it on http://lombok.demon.co.uk/tapestry4Demo If you like, you can take a look and see if it helps. Shing --- Finster Hannon <[EMAIL PROTECTED]> wrote: > I would like to get access to my ASO 'Visit' from a > servlet filter let's > say. I have used a piece I saw Howard post where I > am subclassing the > ApplicationServlet which will provide access to the > HiveMind (HM) > registry. I would think then calling from anywhere > in the app to the > servlet would give me the HM registry. Once I have > the registry, I > would think I can access it's services. I saw an > example of injecting > an ASO into a POJO using a service and implemented > that below. It is > not really the ASO getting injected, rather it is > the > ApplicationStateManager (ASM) getting injected. I > am getting the > service, getting the ASM, but when attempting to get > 'Visit' from the > ASM, an exception is thrown visible in the logging > below. I then moved > my call to a page class to see if that would change > things and it did > not. Debugging my servlet shows the registry > obtained has many services > including mine. > > I have seen many references to 'HiveUtils > ObjectBuilder' and would like > to get this working before attempting use of that. > Also saw in this > list: 'how to inject visit object into pojo', 'how > to inject aso in > service', 'injecting an aso into a hivemind > service', and 'injecting > an aso into a service' which all relate to this > post. > > Can I get the HM registry from my servlet and is it > valid? Is there > another way to get the registry? Suggestions on > getting the ASO 'Visit' > from a POJO? Is my code invalid? > > Thanks, > Joseph > > The call: > IInjectEnhancementWorker stateWorker = > (IInjectEnhancementWorker) > ApplyServlet.getRegistry().getService(IInjectEnhancementWorker.class); > > Some logging: > Getting HM Registry.......... > ASM: <OuterProxy for > tapestry.state.ApplicationStateManager(org.apache.tapestry.engine.state.ApplicationStateManager)> > Visit is not yet defined: Property 'webRequest' of > <OuterProxy for > tapestry.globals.RequestGlobals(org.apache.tapestry.services.RequestGlobals)> > > is null. > > hivemodule.xml: > <?xml version="1.0" encoding="utf-8"?> > <module id="apply" version="1.0.0" > package="foo.apply.hivemind"> > <contribution > configuration-id="tapestry.state.ApplicationObjects"> > <state-object name="Visit" scope="session"> > <create-instance > class="foo.apply.application.Visit"/> > </state-object> > </contribution> > > <service-point id="InjectStateWorker" > interface="foo.apply.hivemind.IInjectEnhancementWorker"> > <invoke-factory> > <construct > class="foo.apply.hivemind.InjectStateWorker"> > <!--<set-service > property="applicationStateManager" > service-id="tapestry.state.ApplicationStateManager"/>--> > <set-object > property="applicationStateManager" > value="infrastructure:applicationStateManager"/> > </construct> > </invoke-factory> > </service-point> > </module> > > Servlet: > public class ApplyServlet extends ApplicationServlet > { > Logger log = > Utility.fetchLogger(ApplyServlet.class) ; > private static Registry sRegistry ; > private static final String REGISTRY_KEY = > "org.apache.tapestry.Registry:apply" ; > > public void init(ServletConfig config) > throws ServletException { > super.init(config) ; > > log.debug ("Pre getting registry...") ; > Registry r = (Registry) > getServletContext().getAttribute(REGISTRY_KEY) ; > log.debug ("Registry='" + r.toString() + "'") > ; > sRegistry = r ; > } > > public static Registry getRegistry() { > return sRegistry ; > } > } > > Service interface: > public interface IInjectEnhancementWorker { > public void > setApplicationStateManager(ApplicationStateManager > manager) ; > public ApplicationStateManager > getApplicationStateManager() ; > > public Visit retrieveVisit () ; > } > > Service POJO: > public class InjectStateWorker implements > IInjectEnhancementWorker { > private Logger log = > Utility.fetchLogger(InjectStateWorker.class) ; > private ApplicationStateManager > _applicationStateManager ; > > public void > setApplicationStateManager(ApplicationStateManager > manager) { > _applicationStateManager = manager ; > } > > public ApplicationStateManager > getApplicationStateManager() { > return _applicationStateManager ; > } > > public Visit retrieveVisit () { > Visit visit = null ; > > try { > log.debug ("ASM: " + > _applicationStateManager) ; > visit = (Visit) > _applicationStateManager.get("visit") ; > } > catch (Exception e) { > log.info ("Visit is not yet defined: " + > e.getMessage()) ; > } > > return visit ; > } > } > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > Home page : http://uk.geocities.com/matmsh/index.html ____________________________________________________ Yahoo! Photos is now offering a quality print service from just 7p a photo. http://uk.photos.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]