au.net.causal.maven.plugins.boxdb.db.DockerDatabaseFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boxdb-maven-plugin Show documentation
Show all versions of boxdb-maven-plugin Show documentation
Maven plugin to start databases using Docker and VMs
package au.net.causal.maven.plugins.boxdb.db;
import java.util.Objects;
public abstract class DockerDatabaseFactory implements BoxDatabaseFactory
{
private final String name;
protected DockerDatabaseFactory(String name)
{
Objects.requireNonNull(name, "name == null");
this.name = name;
}
@Override
public String name()
{
return name;
}
@Override
public BoxDatabase create(BoxConfiguration boxConfiguration, ProjectConfiguration projectConfiguration, BoxContext context)
throws BoxDatabaseException
{
Objects.requireNonNull(boxConfiguration, "boxConfiguration == null");
Objects.requireNonNull(context, "context == null");
initializeDefaults(boxConfiguration);
return createDockerDatabase(boxConfiguration, projectConfiguration, context);
}
protected abstract DockerDatabase createDockerDatabase(BoxConfiguration boxConfiguration,
ProjectConfiguration projectConfiguration,
BoxContext context)
throws BoxDatabaseException;
protected void initializeDefaults(BoxConfiguration boxConfiguration)
{
if (boxConfiguration.getDatabaseUser() == null)
boxConfiguration.setDatabaseUser(boxConfiguration.getAdminUser());
if (boxConfiguration.getDatabasePassword() == null)
boxConfiguration.setDatabasePassword(boxConfiguration.getAdminPassword());
if (boxConfiguration.getContainerName() == null)
boxConfiguration.setContainerName("boxdb-" + boxConfiguration.getDatabaseType() + "-" + boxConfiguration.getDatabaseVersion());
}
}