0

I've been looking for someone else doing this same thing, but haven't seen a scenario that's quite like this so I thought I'd see if anyone here has any good ideas on how to accomplish this.

My group builds and maintains an open-source neuroimaging data archive tool called XNAT. Previous versions of our application have always required users to run a builder application that took in a build.properties file and used that to initialize the database server configuration, among other things. We're really trying to get down to a single installable war file that we can make available on the NeuroDebian repository. In order to do this, we need to be able to start the application WITHOUT any database configuration information, run through a configuration wizard a la Wordpress or Drupal installations that includes the user inputting the database configuration, and finally setting this configuration information SOMEWHERE and re-starting or re-initializing the application context so that it gets its data source started up, Hibernate entity scans run, all auto-wired or injected dependencies that require the data source or Hibernate transaction manager resolved, and services scanned for @Transactional annotations, and so on.

I can easily see how we can use the new Spring Framework WebApplicationInitializer to detect whether the user has already set up the database configuration and initialize the app properly based on that:

  • If database has not been configured, create an servlet that just supports the UI for the initialization wizard
  • If database has been configured, create the regular application context

The problem in the first case is what happens once the user has completed the initialization wizard? We can store the database configuration somewhere and now we're ready to go but... how do we get the regular application context working? Can we just take the code that we'd call in the already initialized scenario and call that? Will that initialize the application properly then, with component scans and so on all being handled or...?

The only solution we have currently is to have the user restart the server manually (it's usually Tomcat) or use the server manager application to restart just our application. That's not very aesthetically pleasing though.

My end goal here will be to write a simple test app that takes in the database credentials and then tries to initialize everything else afterwards, but I'm hoping to see if anyone's thought about this particular issue and/or tried it and has any advice on how to handle it. Any help would be greatly appreciated!

Spanky Quigman
  • 870
  • 7
  • 16
  • Maybe the UI wizard should instead be a installation step when deploying the application. – Sotirios Delimanolis Oct 22 '13 at 17:05
  • @SotiriosDelimanolis That's an option, the only problem is getting that set up across various platforms. You can add some of those steps in the set up for apt-get, but how do you manage it for Windows or a dev machine situation where someone may just download the war and drop it into the webapps folder? So the *preferred* means of initialization is what I described. If not, we'll go to whatever alternative is required! – Spanky Quigman Oct 22 '13 at 20:29
  • yeap -- for the *Debian platforms we better utilize debconf (http://www.debian.org/doc/packaging-manuals/debconf_specification.html) to provide unified interface for configuring XNAT with the rest of the system (interactively or via preseeding) – Yaroslav Halchenko Oct 24 '13 at 02:18
  • Thanks for chiming in, @YaroslavHalchenko! I was going to send you and Michael a message to follow up with you guys on this very issue. We also have the requirement to configure the data archive directories as well, so the issue really extends into permissions and Tomcat user and so on as well. – Spanky Quigman Oct 24 '13 at 13:26

0 Answers0