views:

43

answers:

1

Hello.

I'm working on a Java Web Application with Wicket, Spring and Hibernate. The web application is not particularily large (I have one DAO and one service), but I'd like to offer the users that deploy the application a startup wizard much like the ones found in Wordpress.

When the webpage is accessed for the first time (no database tables are created / no users), I want the user to be able to enter database settings (username, password, database name, database type) and then I want the web application to create all the tables that it will use.

As I'm new to Wicket and Java Web Development I'm not sure how one would go about achieving this. Usually, when interacting with the DAO (such as creating a user) the database table is created on demand (if it didn't already exist) -- at least that's what it looks like to me.

Is there a way to extract the SQL for mye domain objects that my application will use via the service->DAO layer?

Right now I configure database access via filters; src/main/config/application-DEV.properties for example. If I want to use a wizard such as described I guess I would need to move away from using property files?

Any help is greatly appreciated.

+1  A: 

I have often contemplated this, as it is standard practice in many PHP / Perl systems, but seems complicated in java / spring etc.

First of all: use wicket-extensions for the wizard functionality

What I would do then is simple, I'd declare all my spring beans as lazy and use system properties to configure them (with a PropertyPlaceHolderConfigurer). I'd use the wizard to get those properties the first time and then write them to a well-known location in the file system (DB would be better, but that's a chicken / egg problem). Then I'd initialize the application context using the system properties.

The problem here is: I don't think there is a portable way to access the file system from a web application, I think every app server may handle file system access differently, so you need to be careful there.

seanizer