Page tree
Skip to end of metadata
Go to start of metadata
Your Rating: Results: 1 Star2 Star3 Star4 Star5 Star 149 rates

Combining modules that use blossom puts some new requirements on how they collaborate to initialize the ApplicationContext.

  • You should have only one root WebApplicationContext, so every module can't create its own.
  • You should have <blossom:configuration /> only once in your application.
  • Your xml files, both for application context and DispatcherServlet needs to have unique names. For instance two modules both using the name blossom-servlet.xml will collide/overlap.

Let one of your modules take the role of master module. It should load the root web application context. It should have the <blossom:configuration />. It can find xml files from other modules by scanning the classpath. Use a wildcard when setting configLocation. Another strategy could have modules registering their xml files in the repository where the master module would look for them.

public void start(ModuleLifecycleContext moduleLifecycleContext) {
    initRootWebApplicationContext("classpath:/META-INF/applicationContext*.xml");
}

Your other modules should depend on the master module to make sure its initialized first. They should not call BlossomModuleSupport.initRootWebApplicationContext(). They can however create BlossomDispatcherServlets.

To keep things clean and separated it can be a good idea to make a new module that serves as the master module.

2 Comments

  1. Note that <blossom:configuration /> is only required when using Blossom previous to 2.0.