Search code examples
javatapestry

tapestry4: Access visit object from IEngineService implementation


what is the best way to get a reference to the current session's visit object from an implementation of IEngineService?

on my pages/components i access it via @InjectState("visit") public abstract Visit getVisit().

Can i inject it into my EngineService via hivemodule.xml or access it via the RequestCycle?

As usual with tapestry, the documentation mentions nothing...


Solution

  • figured it out.

    <service-point id="MyService" interface="pkg.MyService">
        <invoke-factory>
            <construct class="pkg.MyService">
                <set-object property="linkFactory" value="infrastructure:linkFactory" />
                <set-service property="appStateMgr" service-id="tapestry.state.ApplicationStateManager"/>
            </construct>
        </invoke-factory>
    </service-point>
    

    and once it's injected:

    (Visit) appStateMgr.get("visit")