You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Chiappone <ch...@gmail.com> on 2005/12/23 20:57:34 UTC
Injecting hibernate DAO
I am attempting to inject my DAO object into my page class using the
following code. This is what I've added to my hivemodule.xml file
from refering to the hiveutils docs:
<service-point id="PortaluserHome"
interface="crd.IPortaluserHome">
<invoke-factory service-id="hiveutils.AdapterBuilderFactory"
model="singleton">
<exception-mapping from="org.hibernate.HibernateException"
to="example.dao.PersistenceException" />
<construct
class="crd.PortaluserHome">
<log />
<service>Session</service>
</construct>
</invoke-factory>
<interceptor
service-id="hivetranse.core.TransactionInterceptor">
<method pattern="*" demarcation="Required" />
</interceptor>
</service-point>
<implementation service-id="PortaluserHome">
<interceptor service-id="hivemind.LoggingInterceptor" />
</implementation>
Am I missing something here? I wasn't sure about the correct way to
get access to the hivemind registry so doing the following may be
totally off?
@InjectObject("service:tapestry.globals.HttpServletRequest")
public abstract HttpServletRequest getServReq();
public void pageBeginRender(PageEvent arg0) {
Registry reg = HiveMindFilter.getRegistry(getServReq());
IPortaluserHome puh = (IPortaluserHome) reg.getService(
"crd.IPortaluserHome",
crd.IPortaluserHome.class);
Portaluser pu = puh.findById(67);
setDbTest(pu.getUsername());
}
Any help would be greatly appreciated.
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Injecting hibernate DAO
Posted by Jesse Kuhnert <jk...@gmail.com>.
Just inject your service instead of the servlet request :)
ie:
@InjectObject("service:crd.IPortaluserHome")
public abstract IPortaluserHome getUserHome();
On 12/23/05, Chris Chiappone <ch...@gmail.com> wrote:
>
> I am attempting to inject my DAO object into my page class using the
> following code. This is what I've added to my hivemodule.xml file
> from refering to the hiveutils docs:
>
> <service-point id="PortaluserHome"
> interface="crd.IPortaluserHome">
> <invoke-factory service-id="
> hiveutils.AdapterBuilderFactory"
> model="singleton">
> <exception-mapping from="
> org.hibernate.HibernateException"
> to="example.dao.PersistenceException" />
> <construct
> class="crd.PortaluserHome">
> <log />
> <service>Session</service>
> </construct>
> </invoke-factory>
> <interceptor
> service-id="hivetranse.core.TransactionInterceptor
> ">
> <method pattern="*" demarcation="Required" />
> </interceptor>
> </service-point>
>
>
>
> <implementation service-id="PortaluserHome">
> <interceptor service-id="hivemind.LoggingInterceptor" />
> </implementation>
>
>
> Am I missing something here? I wasn't sure about the correct way to
> get access to the hivemind registry so doing the following may be
> totally off?
>
> @InjectObject("service:tapestry.globals.HttpServletRequest")
> public abstract HttpServletRequest getServReq();
>
> public void pageBeginRender(PageEvent arg0) {
>
> Registry reg = HiveMindFilter.getRegistry(getServReq());
>
> IPortaluserHome puh = (IPortaluserHome) reg.getService(
> "crd.IPortaluserHome",
> crd.IPortaluserHome.class);
> Portaluser pu = puh.findById(67);
> setDbTest(pu.getUsername());
>
> }
>
> Any help would be greatly appreciated.
> --
> ~chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>