Hi, Have solved my problem and thought I'd pass on the knowledge here.
Brief problem desc: Magnolia is instantiating my ModelClass via a new command, but I want to Spring inject my data model/state/service classes into the ModelClass instance. As Magnolia not Spring aware, all the ModelClass dependencies end up null. Solution: first create a Spring Context provider class as described in http://jerlinworld.wordpress.com/2009/07/20/making-your-spring-application-context-aware/ This will give you a static class that will be injected with the Spring context. Then within ModelClass, use this provider class to get the Spring context, and use getBean(type) to get each dependency. I lazy load these dependencies and cache them locally as static references. So whenever ModelClass is created by Magnolia (suspect this is on every page load that is configured to use ModelClass - in my case, that is all my pages), its dependencies are present. Note - I went down this approach as I have a simple Magnolia module project (i.e. not a webapp module) that contains just my ModelClass, templates (i.e. ftl files) and required Magnolia lifecycle classes. I also have a seperate project that contains my data model classes and Spring context. Both projects are packaged as jars and put in the WEB-INF/lib folder so visible to Magnolia. Seems to work ok for me, and I'm happy with this. Regards, Paul -- Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=5f4656e6-a1b8-47cd-870a-d4a564f3514f ---------------------------------------------------------------- For list details, see http://www.magnolia-cms.com/community/mailing-lists.html Alternatively, use our forums: http://forum.magnolia-cms.com/ To unsubscribe, E-mail to: <[email protected]> ----------------------------------------------------------------
