Hi Mike, Sorry to not address your question directly, but from an architectural perspective, do you really want persistence implementation dependant code in your application objects? For most projects I know this is not a big deal as you choose your persistence engine and stick to it.
One solution I came up with was to implement interfaces for my persistent entities, then implement a service in HiveMind that implements that interface. The actual mechanics of accessing the data is then hidden from application code. Really if you use HM, you must provide an implementation of an interface, and it should be fully self contained, so that it is readily pluggable with some other implementation without any need of any other code or configuration. That as far as I gather is the spirit of HM. I provide a HM service that can take the Cayenne classes and add the interface implementation to them so they can deliver back to the application. It works nicely. I still have put an entry in web.xml so that a session based context is available off the thread for the persistence layer to use. Ideally I would like a fully enclosed solution, with no references to the persistence mechanism other that what implementation you choose in the hivemodule. I can provide working code if you are interested in this idea. John ----- Original Message ----- From: "Mike Pestorich" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Friday, February 17, 2006 8:01 AM Subject: Injecting service into ASO > I am trying to contribute an object to tapestry's ASOs with session scope > and inject (or wire in) a Cayenne DataContext. I receive this error: > > java.lang.NoSuchMethodException > setFactory > Stack Trace: > org.apache.hivemind.schema.rules.InvokeParentRule.findMethod(InvokeParentRul e.java:127) > org.apache.hivemind.schema.rules.InvokeParentRule.begin(InvokeParentRule.jav a:58) > org.apache.hivemind.impl.SchemaElement.fireBegin(SchemaElement.java:228) > org.apache.hivemind.impl.SchemaProcessorImpl.processElement(SchemaProcessorI mpl.java:255) > org.apache.hivemind.impl.SchemaProcessorImpl.processNestedElements(SchemaPro cessorImpl.java:277) > org.apache.hivemind.impl.SchemaProcessorImpl.processElement(SchemaProcessorI mpl.java:257) > org.apache.hivemind.impl.SchemaProcessorImpl.processRootElement(SchemaProces sorImpl.java:235) > ... > > I am new to hivemind and tapestry and I know that there are other ways of > doing this (and actually have got it to work those other ways) but am trying > to do things the way the tapestry and hivemind documentation preach. I have > been stuck on this for a little while now and it seems to me that what I am > trying to do should be working based on the documentation I have read. > However, I just reviewed a previous post on this list from last December > "Injecting registry services to POJOS" and it looks like this person had the > same problem as me. From that post it looks like he eventually solved it > using hiveutils. Before I add another jar to my project and head in a > different direction, I would like to know what I am doing or where my > thinking is wrong here. > > ===web.xml=== > > <web-app> > ... > <listener> > <listener-class>org.objectstyle.cayenne.conf.WebApplicationContextProvider</ listener-class> > </listener> > ... > </web-app> > > ===DataContextService.java=== > > package com.pestorich.tapestry; > > import org.objectstyle.cayenne.access.DataContext; > > public interface DataContextService { > > public DataContext getDataContext(); > > } > > ===DataContextServiceImpl.java=== > > package com.pestorich.tapestry; > > import org.objectstyle.cayenne.access.DataContext; > > public class DataContextServiceImpl implements DataContextService { > > public DataContext getDataContext() { > return DataContext.getThreadDataContext(); > } > } > > ===Session.java=== > > package com.pestorich.tapestry; > > import java.io.Serializable; > import org.objectstyle.cayenne.access.DataContext; > import com.pestorich.tapestry.DataContextService; > > public class Session implements Serializable { > > private static final long serialVersionUID = 1L; > private DataContextService _dataContextService; > > public Session() {} > > public void setDataContextService(DataContextService dataContextService) { > _dataContextService = dataContextService; > } > > public DataContext getContext() { > return _dataContextService.getDataContext(); > } > } > > ===hivemodule.xml=== > > <module id="com.pestorich.tapestry" version="1.0.0"> > <service-point id="DataContextService"> > <invoke-factory> > <construct class="DataContextServiceImpl" /> > </invoke-factory> > <interceptor service-id="hivemind.LoggingInterceptor" /> > </service-point> > <service-point id="Session"> > <invoke-factory> > <construct class="Session" /> > </invoke-factory> > </service-point> > <contribution configuration-id="tapestry.state.ApplicationObjects"> > <state-object name="Session" scope="session"> > <invoke-factory object="service:Session" /> > </state-object> > </contribution> > </module> > > > Thanks for any help or criticism in advance. It's all greatly appreciated :) > > Mike > > > > --------------------------------------------------------------------- > 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]
