Created
March 15, 2011 10:05
-
-
Save aslakknutsen/870535 to your computer and use it in GitHub Desktop.
Arquillian Container Deployment SPI, multiple known types, multiple interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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