Jun 10th, 2011, 03:51 PM
Delay certain beans from loading; dynamic bean loading
Our Spring highly enterprise integrated spring app config yields an all or nothing monolithic web app. When it finds everything correctly during start up, it starts up perfectly. If not, it fails to deploy in numerous ways. This is probably ok for web and service providers who centrally manage and control their environments, but for those of us shipping our apps to customers for them to install, this can be a real challenge. Telling our customers to 'check the logs' for start up problems isn't exactly a 21st century solution - these are IT people, not programmers, so stack traces are unfamiliar.
I would like to improve the installation/startup experience for our customers by providing an interactive startup experience. Our app has a ton of enterprise dependencies: authentication servers, database servers, os dependencies, etc. Is it possible to start the Spring container and only load these services conditionally / dynamically? I could then build a startup wizard around this. For example; in the common case of the missing/unconfigured database: "No schema detected - would you like to create one? Please enter jdbc url / password. <test> <create schema>". And then attempt to run liquibase to build the schema and then dynamically load JPA / Hibernate.
I can't wrap my head around how that would work using the current context loader I am familiar with where everything is loaded up front. Is it possible to dynamically load JPA/Hibernate after I've determined the db is ok and up - to date? I have many such beans with direct dependencies which fail the whole deployment if their dependecies are not met.