Search in sources :

Example 1 with FlywayFraction

use of org.wildfly.swarm.flyway.FlywayFraction in project wildfly-swarm by wildfly-swarm.

the class FlywayMigrationArchivePreparer method process.

@Override
public void process() {
    if (archive.getName().endsWith(".war")) {
        WARArchive webArchive = archive.as(WARArchive.class);
        WebXmlAsset webXml = webArchive.findWebXmlAsset();
        webXml.addListener("org.wildfly.swarm.flyway.deployment.FlywayMigrationServletContextListener");
        FlywayFraction flywayFraction = flywayFractionInstance.get();
        if (flywayFraction.usePrimaryDataSource()) {
            String dataSourceJndi = getDatasourceNameJndi();
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JNDI_DATASOURCE, dataSourceJndi);
        } else {
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JDBC_URL, flywayFraction.jdbcUrl());
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JDBC_USER, flywayFraction.jdbcUser());
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JDBC_PASSWORD, flywayFraction.jdbcPassword());
        }
    }
}
Also used : WebXmlAsset(org.wildfly.swarm.undertow.descriptors.WebXmlAsset) FlywayFraction(org.wildfly.swarm.flyway.FlywayFraction) WARArchive(org.wildfly.swarm.undertow.WARArchive)

Aggregations

FlywayFraction (org.wildfly.swarm.flyway.FlywayFraction)1 WARArchive (org.wildfly.swarm.undertow.WARArchive)1 WebXmlAsset (org.wildfly.swarm.undertow.descriptors.WebXmlAsset)1