-
Notifications
You must be signed in to change notification settings - Fork 19
How to integrate AutoPatch with a web application
The easiest way to integrate AutoPatch with a web application is to add the WebAppMigrationLauncher as a ContextListener for your application context. This can be done with a web.xml snippet that looks like this:
<!-- in the context-params section -->
<context-param>
<param-name>migration.systemname</param-name>
<param-value>mysystemname</param-value>
</context-param>
<!-- in the listeners section -->
<listener>
<listener-class>com.tacitknowledge.util.migration.jdbc.WebAppMigrationLauncher</listener-class>
</listener>
"migration.systemname" is used to differentiate different systems storing their state in the same database (and thus the same patches table). It also used as a prefix for all migration.properties property keys.
So long as migration.properties, the AutoPatch library, , its dependent libraries (from the lib directory of the AutoPatch distribution) and all of your patches (with their paths specified in migration.properties) are in the web application's classpath, AutoPatch should work fine.
As of the 0.7 release of autopatch there is a new way to configure your web application. You can use JNDI to supply a data source and eliminate the need for a migration.properties file altogether. Do this by adding the following to your web.xml file:
<!-- in the context-params section -->
<context-param>
<param-name>migration.systemname</param-name>
<param-value>beekeeper</param-value>
</context-param>
<context-param>
<param-name>migration.readonly</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>migration.databasetype</param-name>
<param-value>mysql</param-value>
</context-param>
<context-param>
<param-name>migration.patchpath</param-name>
<param-value>patches:com.stylehive.profile.db.patch</param-value>
</context-param>
<context-param>
<param-name>migration.datasource</param-name>
<param-value>jdbc/profile</param-value>
</context-param>
<!-- in the listeners section -->
<listener>
<listener-class>com.tacitknowledge.util.migration.jdbc.WebAppJNDIMigrationLauncher</listener-class>
</listener>
Note that there are similar parameters supplied in the servlet context that once existed in the migration.properties file. All database connection properties have been replaced by a parameter called migration.datasource. This uses an existing datasource to perform the autopatch updates.
- Overview
- Design Requirements
- Basic Design
- Detailed Design
- How to integrate AutoPatch with a web application
- How to integrate AutoPatch with your development cycle
- How to implement a patch
- How to extend AutoPatch with new patch types
- How to rollback patches
- How to migrate from AutoPatch 1.1 to AutoPatch 1.2
- How to Migrate to AutoPatch 1.3