Integration of T5 with the domain model
Just wanted to share how I hooked up T5 with my domain model. I'm using jpa for persistence, so the thing I needed was injection of the EntityManager into the objects providing access to my top level domain objects. And for just that simple IoC, Spring is way too overkill. Guice on the other hand was quite nice for it. I integrated it like this: The access object public class BlaBlaJPAQuery implements BlaBlaFinder { @Inject //the guice inject annotation private EntityManager _entityManager; //Code... } the JPAUtil public class JPAUtil implements Provider { private static final EntityManagerFactory _entityManagerFactory; private static ThreadLocal _entityManagerContainer; static { _entityManagerFactory = Persistence.createEntityManagerFactory("POB"); _entityManagerContainer = new ThreadLocal(); } public static void createEntityManager() { _entityManagerContainer.set(_entityManagerFactory.createEntityManager()) ; } public static void closeEntityManager() { EntityManager entityManager = _entityManagerContainer.get(); entityManager.close(); } public EntityManager get() { return _entityManagerContainer.get(); } } Another filter before the T5 filter that does this: public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { try { JPAUtil.createEntityManager(); filterChain.doFilter(request, response); } finally { JPAUtil.closeEntityManager(); } } The Guice module: public class POBGuiceModule extends AbstractModule { public void configure() { bind(EntityManager.class).toProvider(JPAUtil.class); } } And the T5 module: public class POBTapestryModule { private static final Injector _injector; static { _injector = Guice.createInjector(new Module[] { new POBGuiceModule() }); } @Lifecycle(value="perthread") public static BlaBlaFinder buildBlaBlaFinder() { return _injector.getInstance(BlaBlaJPAQuery.class); } } And offcourse the page: @Inject //T5 inject annotation private BlaBlaFinder _blablaFinder; Comments/Suggestions/missed design flaws? DISCLAIMER: Dit bericht (met bijlagen) is met grote zorgvuldigheid samengesteld. Voor mogelijke onjuistheid en/of onvolledigheid van de hierin verstrekte informatie kan Stichting Kennisnet Ict op school geen aansprakelijkheid aanvaarden, evenmin kunnen aan de inhoud van dit bericht (met bijlagen) rechten worden ontleend. De inhoud van dit bericht (met bijlagen) kan vertrouwelijke informatie bevatten en is uitsluitend bestemd voor de geadresseerde van dit bericht. Indien u niet de beoogde ontvanger van dit bericht bent, verzoekt Stichting Kennisnet Ict op school u dit bericht te verwijderen, eventuele bijlagen niet te openen en wijst Stichting Kennisnet Ict op school u op de onrechtmatigheid van het gebruiken, kopiƫren of verspreiden van de inhoud van dit bericht (met bijlagen). This message (with attachments) is given in good faith. Stichting Kennisnet Ict op school cannot assume any responsibility for the accuracy or reliability of the information contained in this message (with attachments), nor shall the information be construed as constituting any obligation on the part of Stichting Kennisnet Ict op school. The information contained in this message (with attachments) may be confidential or privileged and is only intended for the use of the named addressee. If you are not the intended recipient, you are requested by Stichting Kennisnet Ict op school to delete this message (with attachments) without opening it and you are notified by Stichting Kennisnet Ict op school that any disclosure, copying or distribution of the information contained in this message (with attachments) is strictly prohibited and unlawful. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: load modules with jettylauncher without a jar
Thanks for the quick reply. I resolved it by adding a .jar with only the manifest file as library in eclipse. I have an m2 project setup with inheritance where all code (and then with manifest file) is built into jars anyway which are then included in the war. So for the integration and test servers I didn't have a problem anyway. The 'manifest jar' is just for running jettylauncher and is only present in that environment. -Oorspronkelijk bericht- Van: Howard Lewis Ship [mailto:[EMAIL PROTECTED] Verzonden: woensdag 11 april 2007 16:16 Aan: Tapestry users Onderwerp: Re: load modules with jettylauncher without a jar Servlet class loaders do not look for META-INF/Manifest.mf inside the WAR. I believe you could place it WEB-INF/classes/META-INF/Manifest.mf. From what you describe, I'm not sure that the manifest file is showing up in the right place. I would not rely on the manifest approach for a web application, but instead rely on how T5 loads the "application module", as demonstrated in the quickstart Maven archetype. On 4/11/07, Leon Pennings <[EMAIL PROTECTED]> wrote: > Ok, I'm doing something wrong here. > I'm working on a T5 project where I have a T5 module. I made a > manifest file which is in the META-INF folder that is in the classpath > (m2 resource folder, that is added as a source folder under eclipse). > I'm running jettylauncher to test the project, but the module isn't > loaded by Tapestry. > > What am I doing wrong? > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER: Dit bericht (met bijlagen) is met grote zorgvuldigheid samengesteld. Voor mogelijke onjuistheid en/of onvolledigheid van de hierin verstrekte informatie kan Stichting Kennisnet Ict op school geen aansprakelijkheid aanvaarden, evenmin kunnen aan de inhoud van dit bericht (met bijlagen) rechten worden ontleend. De inhoud van dit bericht (met bijlagen) kan vertrouwelijke informatie bevatten en is uitsluitend bestemd voor de geadresseerde van dit bericht. Indien u niet de beoogde ontvanger van dit bericht bent, verzoekt Stichting Kennisnet Ict op school u dit bericht te verwijderen, eventuele bijlagen niet te openen en wijst Stichting Kennisnet Ict op school u op de onrechtmatigheid van het gebruiken, kopiƫren of verspreiden van de inhoud van dit bericht (met bijlagen). This message (with attachments) is given in good faith. Stichting Kennisnet Ict op school cannot assume any responsibility for the accuracy or reliability of the information contained in this message (with attachments), nor shall the information be construed as constituting any obligation on the part of Stichting Kennisnet Ict op school. The information contained in this message (with attachments) may be confidential or privileged and is only intended for the use of the named addressee. If you are not the intended recipient, you are requested by Stichting Kennisnet Ict op school to delete this message (with attachments) without opening it and you are notified by Stichting Kennisnet Ict op school that any disclosure, copying or distribution of the information contained in this message (with attachments) is strictly prohibited and unlawful. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
load modules with jettylauncher without a jar
Ok, I'm doing something wrong here. I'm working on a T5 project where I have a T5 module. I made a manifest file which is in the META-INF folder that is in the classpath (m2 resource folder, that is added as a source folder under eclipse). I'm running jettylauncher to test the project, but the module isn't loaded by Tapestry. What am I doing wrong? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]