Skip to content

Instantly share code, notes, and snippets.

@aslakknutsen
Created March 15, 2011 10:05
Show Gist options
  • Save aslakknutsen/870535 to your computer and use it in GitHub Desktop.
Save aslakknutsen/870535 to your computer and use it in GitHub Desktop.
Arquillian Container Deployment SPI, multiple known types, multiple interfaces
public interface Container
{
}
public interface ControllableContainer extends Container
{
void setup();
void start();
void stop();
}
public interface ArchiveDeployableContainer extends Container
{
void deploy(Archive a);
void undeploy(Archive a);
}
public interface DescriptorDeployableContainer extends Container
{
void deploy(Descriptor d);
void undeploy(Descriptor d);
}
public class ContainerImpl implements ArchiveDeployableContainer, DescriptorDeployableContainer
{
public void deploy(Archive a)
{
deploy(a.getName(), a.as(ZipExporter.class).exportToStream());
}
public void deploy(Descriptor b)
{
deploy(b.getName(), new StringInputStream(b.exportAsString()));
}
private void deploy(String name, InputStream deployment)
{
// do deploy
}
}
public interface Container
{
}
public interface ControllableContainer extends Container
{
void setup();
void start();
void stop();
}
public interface DeploymentDeployableContainer extends ControllableContainer
{
void deploy(Deployment d);
void undeploy(Deployment d);
}
public class ContainerImpl2 implements ArchiveDeployableContainer, DescriptorDeployableContainer
{
public void deploy(Deployment d)
{
if(d instanceof ArchiveDeployment)
{
deploy(((ArchiveDeployment)d).getArchive());
}
else if( d instanceof DescriptorDeployment)
{
deploy(((DescriptorDeployment)d).getDescriptor());
}
}
private void deploy(Descriptor d)
{
// do deploy
}
private void deploy(Archive a)
{
// do deploy
}
}
public class ContainerImpl3 implements ControllableContainer
{
@Deployer
public void deploy(Archive a) {}
@UnDeployer
public void undeploy(Archive a) {}
@Deployer
public void deploy(Image a) {}
@UnDeployer
public void undeploy(Image a) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment