I'm working with very large JSF/Facelets applications which use Spring for DI/bean management. My applications have modular structure and I'm currently looking for approaches to standardize the modularization.
My goal is to compose a web application from a number of modules (possibly depending on each other). Each module may contain the following:
- Classes;
- Static resources (images, CSS, scripts);
- Facelet templates;
- Managed beans - Spring application contexts, with request, session and application-scoped beans (alternative is JSF managed beans);
- Servlet API stuff - servlets, filters, listeners (this is optional).
What I'd like to avoid (almost at all costs) is the need to copy or extract module resources (like Facelets templates) to the WAR or to extend the web.xml for module's servlets, filters, etc. It must be enough to add the module (JAR, bundle, artifact, ...) to the web application (WEB-INF/lib, bundles, plugins, ...) to extend the web application with this module.
Currently I solve this task with a custom modularization solution which is heavily based on using classpath resources:
- Special resources servlet serves static resources from classpath resources (JARs).
- Special Facelets resource resolver allows loading Facelet templates from classpath resources.
- Spring loads application contexts via the pattern
classpath*:com/acme/foo/module/applicationContext.xml- this loads application contexts defined in module JARs. - Finally, a pair of delegating servlets and filters delegate request processing to the servlets and filters configured in Spring application contexts from modules.
Last days I read a lot about OSGi and I was considering, how (and if) I could use OSGi as a standardized modularization approach. I was thinking about how individual tasks could be solved