I'm trying to handle multiple web modules in a spring MVC application. Let's say I have two modules : financial module and warehousing module. They have their own business processes, but there's some common processes like LDAP authentication and searches ... and also dependencies between them. So I want to keep them in a single web application, with two different requestmappings : /finance/* and warehouse/*
My question is similar to this one : How should I build a modularized enterprise application which must use Spring and JPA?
So my first approach was to create an enum to store the modules list :
public enum WebApplicationModule {
FINANCE("/finance", "Finance Module"),
WAREHOUSE("/warehouse", "Warehouse Module");
private final String moduleTitle;
private final String moduleRequestMapping;
WebApplicationModule(String moduleRequestMapping, String moduleTitle) {
this.moduleRequestMapping = moduleRequestMapping;
this.moduleTitle = moduleTitle;
}
public String getModuleTitle() {
return moduleTitle;
}
public String getModuleRequestMapping() {
return moduleRequestMapping;
}
}
Then I created two abstract controllers :
@Controller
@RequestMapping(value = {WebApplicationModule.FINANCE.getModuleRequestMapping()})
public abstract class FinanceAbstractController {
private final String VIEWS_FOLDER = "finance";
}
and
@Controller
@RequestMapping(value = {WebApplicationModule.WAREHOUSE.getModuleRequestMapping()})
public abstract class WarehouseAbstractController {
private final String VIEWS_FOLDER = "warehouse";
}
All controllers in the modules will extend them.
The goal is to handle RequestMappings dynamically : /finance/* and warehouse/*. I also want to be able to display dynamically a menu (ul li ahref) to choose module on the header of the web page.
I know it's not working because RequestMapping's value have to be a constant value, that's why I'm asking you the best way to do this.
Thanks