Running Liquibase from @Singleton EJB


We are building an EJB + app client JEE6 application.

I am new to liquibase and I see there is a ServletListener and a Spring implementation for the kick-off.

For us, as we don’t have a web module or use spring either, would be very convenient to be able to deploy it as a @Singleton EJB 3.1.

If there is a programmatic way of calling liquibase, we could also do it from the @PostConstruct of the singleton EJB.

In summary:

Does it sounds like a good idea to add a singleton ejb implementation to the liquibase binaries so we could add it to ejb-jar.xml (ejb3.1) for those people who do not use web modules?

Is there a programmatic way of running Liquibase from @PostConstruct of @Singleton EJB?


Yes, if you take a look at the source for the SpringLiquibase class or ServletListener you can see how to call liquibase programatically.  It mainly consists of creating an instance of liquibase.Liquibase then calling the update() method