I want to have 3 websites, all with distinct public domain names but they all share a common java back-end SpringMVC server and use common static web resources like js and css files.
Rather than maintaining the UI code in 3 places, I'd rather run 1 server and deploy 1 WAR on a Tomcat8, Jboss or Wildfly cloud instance like OpenShift or AWS, but still be able configure my dns CNAME's to point to different paths on that WAR.
For example, here is where each domain would map to their respective endpoints but not have visibility of the others:
www.mydomainA.com ---> mycloudprovider.ip/sharedcontext/A
www.mydomainB.com ---> mycloudprovider.ip/sharedcontext/B
www.mydomainC.com ---> mycloudprovider.ip/sharedcontext/C
Is this possible? If so, what would be the steps to configure?
Best How To :
It is actually beneficial to configure 3 separate projects. They will all need to have their own application contexts, but can share a single parent POM. This will result in better load balancing performance. Also, since Amazon's pricing structure is such that it is cheaper to set up 3 micro instances than one powerful instance to run all 3 wars. Note: You can still have all 3 instances pointing to the same dataSource.
To solve the problem of duplicate webapp code, you can create a pom overlay using the maven-war-plugin. When Maven applies the overlay it will essentially apply a union of the files from your app with the files from the overlay. Any files that intersect will be used from the app rather than the overlay.
To solve the problem of duplicate java code, you can separate the common code into a new project and build a jar to use as a dependency.