I think a common case is that code using a database needs the database to be in a certain state to work correctly.

A lot of people use tools like liquibase to achieve that. Now the question is how to best hook liquibase or a similar tool into the startup of an OSGi application.

What I would like to do is provide a way to specify a migration task in a pax-jdbc-config that is then guaranteed to run before the DataSource is published for general use.

What I imagine is to use some interface like:

public interface DatabaseSetupHook {
    public void prepare(DataSource ds);
}

An implementation could be exposed as a service given a name using a service property like this:

@Component(property={"name=myhook"})
public class Migrate implements DatabaseSetupHook {

    public void prepare(DataSource ds) {

    }

}


In the database config we could refer to the hook via:

pre-hook=myhook

Pax-jdbc-config would then only establish the DataSource once that hook is present and will run it before publishing the DataSource.

If it makes sense we could even wrap liquidbase in a hook that just needs to be configured by the user.

What do you think?

Christian




--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to