Its a very good idea, because now I to achive that I have to make "database
ready" marker interface on ServiceRegistry via liquibase loader and have to
make some extra service dependency for marker interface where the
datasource is also referenced - So I had to wrapped it the whole. Its very
ugly. So I prefere this way Christian!
Regards,
Robert
On Monday, February 6, 2017 at 1:37:07 PM UTC+1, Christian Schneider wrote:
>
> 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.