/*
* ========================================================================
*
* Copyright 2005 Vincent Massol.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================================================================
*/
package org.codehaus.cargo.maven2;
import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
import org.codehaus.cargo.generic.ContainerFactory;
import org.codehaus.cargo.generic.ContainerType;
import org.codehaus.cargo.generic.DefaultContainerFactory;
/**
* Holds configuration data for the <container> tag used to configure
* the plugin in the pom.xml file.
*
* @version $Id: $
*/
public class Container
{
private String containerId;
private Class implementation;
private File homeDir;
private File output;
private ZipUrlInstaller zipUrlInstaller;
private boolean append;
private File log;
private Configuration configuration;
private String type = ContainerType.LOCAL.getType();
public ContainerType getType()
{
return ContainerType.toType(this.type);
}
public String getContainerId()
{
return this.containerId;
}
public File getHomeDir()
{
return this.homeDir;
}
public File getOutput()
{
return this.output;
}
public ZipUrlInstaller getZipUrlInstaller()
{
return this.zipUrlInstaller;
}
public boolean shouldAppend()
{
return this.append;
}
public File getLog()
{
return this.log;
}
public Configuration getConfiguration()
{
return this.configuration;
}
public Class getImplementation()
{
return this.implementation;
}
public org.codehaus.cargo.container.Container createContainer() throws MojoExecutionException
{
ContainerFactory factory = new DefaultContainerFactory();
// If the user has registered a custom container class, register it against the
// default container factory.
if (getImplementation() != null)
{
factory.registerContainer(getContainerId(), getType(), getImplementation());
}
if (getConfiguration() == null)
{
throw new MojoExecutionException("Missing mandatory [configuration] element.");
}
org.codehaus.cargo.container.Container container = factory.createContainer(
getContainerId(), getType(), getConfiguration().createConfiguration(getContainerId()));
return container;
}
}