I found these notes
http://wiki.apache.org/jakarta-tapestry/CayenneTapestrySqueezer, but seems
not so helpful for your case. I have a different solution which may help
you.
What I did to use Cayenne in HiveMind is this:
configure this listener in web.xml:
<listener>
<listener-class>org.objectstyle.cayenne.conf.WebApplicationContextProvider</
listener-class>
</listener>
and in my HiveMind services which are PoolManageable:
public DataContext getDataContext() {
return context;
}
public void activateService() {
// this method only works when a DataContext is bound by a listener
try {
context = DataContext.getThreadDataContext();
} catch (java.lang.IllegalStateException ex) {
// TODO oh dear!
}
log.debug("activate service..."
+ Thread.currentThread().getName());
}
public void passivateService() {
try {
context.commitChanges();
} catch (CayenneRuntimeException rex) {
log.error("error commiting changes:", rex);
}
log.debug("passivate service..."
+ Thread.currentThread().getName());
}
This way there is no need to mess with the visit object, just pick the
DataContext off the current thread. In my case whenever a service is pulled
off the pool, it grabs the DataContext and the service can then get that
using a getDataContext() method from the subclass service implementation.
This is quite neat and decouples things a bit.
Ideally I'd like not to use the WebAppContextProvider and have a standalone
solution done 100% in HiveMind POJOs. I'd still like to see how the squeezer
is used, and understand the practical benefits of it.
John
----- Original Message -----
From: "Steve Wells" <[EMAIL PROTECTED]>
To: "Tapestry users" <[email protected]>
Sent: Friday, December 09, 2005 5:49 AM
Subject: Re: Wiring Hivemind to
Just to clarify a bit.
What I'm trying to do is get a custom squeezer defined in HiveMind to
access ASO's, without using any static threadLocal implmentation. The
ASO's are data context and object id stores for the squeezer.
Another way I thought here is to pass the
tapestry.state.ApplicationObjects to the squeezer service:
<service-point id="CayenneAdapter"
interface="org.rz.squeezer.IDataObjectAdapter">
<invoke-factory>
<construct class="org.rz.squeezer.DataObjectAdaptor">
<set-configuration property="visitList"
configuration-id="tapestry.state.ApplicationObjects"/>
</construct>
and the constructor:
public DataObjectAdaptor(Map visitList)
I've also exchanged Map with List and Object and get:
Unable to find constructor applicable for autowiring. Use explicit
constructor parameters.
TIA
On Fri, 09 Dec 2005 14:02:32 +1000, "Steve Wells"
<[EMAIL PROTECTED]> said:
> I'm trying to get a Cayenne Data Squeezer to work wired with more
> Hivemind than some previous solutions out there.
> The Squeeze adapter constructor has 2 params which should both be stored
> in session scope, so I'd like to config Hivemind to set the object into
> session scope and pass them to the SqueezeAdapter, maybe this is a dumb
> thing to do.
>
> I've tryed various things but here is the best shot so far:
> hivemodule.xml
> <!-- Cayenne Squeeze adapter service -->
> <service-point id="CayenneAdapter"
> interface="org.rz.squeezer.IDataObjectAdapter">
> <invoke-factory>
> <construct
> class="org.rz.squeezer.DataObjectAdaptor"></construct>
> <!-- It would be nice if I could get the constructor params to autowire
> from the session instances -->
>
> <!-- DataContext param that should go into session and feed into
> Squeezeadapter -->
> <contribution configuration-id="tapestry.state.ApplicationObjects">
> <state-object name="dataContextProvider" scope="session">
> <create-instance
> class="org.rz.squeezer.DataContextProviderImpl"/>
> </state-object>
> </contribution>
>
> What I also tryed was to create a service for the dataContextProvider
> and pass the reference to the state-object but it seems this is a no go.
>
> Has anyone tried this or can anyone provide at least a hint?
>
> Thanks,
>
> Steve
>
>
> --
> Steve Wells
> [EMAIL PROTECTED]
>
> --
> http://www.fastmail.fm - Same, same, but different.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
Steve Wells
[EMAIL PROTECTED]
--
http://www.fastmail.fm - Choose from over 50 domains or use your own
---------------------------------------------------------------------
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]