2

I mainly develop a big Web project with Java, Maven, and Spring. However, there are different flavors of the Web project that are created for specific customer needs. For instance, if one customer wants a Twitter page, but another does not, I need to be able to build a flavor of that Web project with or without that Twitter page.

I have been looking into Maven overlays and OSGi as two options. Maven overlays tend to take a long time to build when copying resources from the base overlay. I was looking at Spring OSGi Web as an option because they seem to be on the right track for modularizing small chuncks (controllers, views, JS/resources/images) for Web projects.

Is OSGi overkill? Is it what I need to use? Is there something better?

Matt
  • 3,254
  • 3
  • 23
  • 32

4 Answers4

1

You might be interested in Spring Slices. It basically allows you to have fragments of a web application deployed as individual bundles. Depending upon the complexity of your overall offering this may be desirable.

I've not looked at it seriously for a while, so I'm not too sure of it's current status, though I expect it's improved greatly since I last looked.

Anyone with more up to date info please feel free to add links.

http://blog.springsource.com/2009/08/07/slices-menu-bar-screencast/

ptomli
  • 11,730
  • 4
  • 40
  • 68
  • I have briefly looked at this as well. I think Spring Slices is the right direction by allowing developers to pick which modules to build a project/WAR. Looking more into this... – Matt Feb 12 '11 at 02:23
  • Actually it's far more impressive than that. You develop the functionality of your site in separate bundles, then you can deploy/upgrade features at runtime. Think upgrading a forum section while the cart and store section continues to run. – ptomli Feb 14 '11 at 10:34
1

OSGI is great if you need to add/remove unforeseen features (and code) at runtime (and not just enable or disable it), but most time this is not needed for web apps.

So in your case I would recommend to use a configuration (file) to enable or disable features as long as this is possible. This also have the advantage, that you need only one WAR.

To handle the problem of: "how to put the configuration file in the WAR", you have several ways ( Different files to be packaged in a Maven war project ):

  • use maven environements - (ok then you have several WARs, but the only differn in the config file, and the Build Process becomes not so slow, because only the WAR packaging process is done for each environment)
  • store the configuration outside of the WAR
  • store the configuration outside of the WAR for example in a Database
Community
  • 1
  • 1
Ralph
  • 118,862
  • 56
  • 287
  • 383
  • I don't think environments is the answer. I am not building one WAR for many environments with different configurations, but many different WARs with different features. For example, the index.jsp and login.jsp may be shared between all projects, but profile.jsp only for some. – Matt Feb 12 '11 at 02:20
  • @Matt Fisher - the hint about environments is only usefull in combingation with configuration files. If you really have a reason to put in and remove source code, than use osgi. – Ralph Feb 12 '11 at 08:18
0

https://github.com/griddynamics/banshun which is osgi-less modularity for Spring supports two notions of customization. It can pickup and instantiate modules (children contexts) by wildcard that's called build time customization, implying that maven profile put necessary overlays in WAR. An opposite way is runtime customizatoin, when necessary modules are defined in according to a property.

mkhludnev
  • 203
  • 2
  • 5
0

Matt, as a rule of thumb, try to have only one version of your application and try to manage it with configuration properties. Imagine what happens when you have 10 clients and each one has a couple of features, but not two clients have the same set of features.

Augusto
  • 28,839
  • 5
  • 58
  • 88
  • That's kinda the idea... Why would I include pages, controllers, images, scripts, etc. in a WAR that doesn't need them? I don't think modularizing a project (set of projects) is bad--I'm looking for the best way to do it. – Matt Feb 12 '11 at 02:15