Menu

Vertical Modularization of SpringResin WebApp

Help
Frank Misa
2011-03-21
2013-04-26
  • Frank Misa

    Frank Misa - 2011-03-21

    Hi All…

    Hoping someone here can confirm for me - if the following is the correct usage scenario for JCL.
    Has anyone here successfully used JCL/JarClassLoader to veritically modularize a WebApplication ?

    Our application has 4 or 5 domain areas – that share a common core and utility libraries.  Could I use JCL to have each domain use it’s own version (possible different versions) of the core and utility classes/JARs ?

    I see that at the Spring level each service could be associated with – it’s own classloader - OK.
    But is there an easier way to give a range of packages ? i.e. Everyone in this range of packages:
    com.xxx.domain1.* uses JarClass loader1… would load all dependencies from JAR1versionA, JAR2versionB etc.
    com.yyy.domain2.* uses JarClass loader2…would load all dependencies from JAR1versionB, JAR2versionD etc.

    Could same be done for the Servlet/WebApp engine ?

    Just want to make sure I’m not using JCL to solve a problem it was not meant to solve…

    Hope to hear from someone here….

    Thanks
    Frank

    NOTE:
    I've looked at OSGi but find the tooling support is not there.
    Given Java7 - might go with Jigsaw (some other mechanism to support modularity) - I'd rather go with a simple ClassLoader solution - that would allow us to refactor a legacy application - without stepping on eachothers toes ?

    Any thoughts ? Experience with same ?

    Thanks

     
  • Kamran

    Kamran - 2011-03-23

    Hi Frank, you can do that as long as classes in different package-ranges are packaged in different jar files. In spring however you have to specify which classloader to use to create beans. At the moment the jcl-spring support doesn't allow you to specify package ranges and associate them to different classloaders.

    You could look at BeanNameAutoProxyCreator and try to use it to create proxies(using JCL) based on different package names. When you use JCL you will probably have to override the "createProxy" method. Below is a little blog entry I wrote a while back, which shows how to use BeanNameAutoProxyCreator, its not JCL specific though.

    http://terrajava.blogspot.com/2009/04/regex-based-spring-auto-proxy-creator.html

    I will try to to use this mechanism to provide such support for spring in future releases of JCL.

     

Log in to post a comment.

MongoDB Logo MongoDB