throw new IllegalArgumentException("deployables must not be null");
}
// Get the MainDeployer
//TODO Use ProfileService - EMB-39
final MainDeployer mainDeployer = this.getMainDeployer();
// Record the deployments to be added
final Map<Deployable, Deployment> deploymentsToBeAdded = new HashMap<Deployable, Deployment>();
// For all Deployables
for (final Deployable deployable : deployables)
{
// If already deployed
if (deployed.containsKey(deployable))
{
log.warn("Attempting to re-deploy " + deployable + "; ignoring.");
}
// Make a VFS Deployment
final URL target = deployable.getTarget();
final VirtualFile vf;
try
{
vf = VFS.getChild(target);
}
catch (final URISyntaxException e)
{
throw new RuntimeException("Could not create new VFS root from " + target, e);
}
final Deployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(vf);
// Add to the MainDeployer
log.debug("Adding to " + mainDeployer + ": " + deployment);
try
{
// Add the deployment to the MainDeployer
mainDeployer.addDeployment(deployment);
deploymentsToBeAdded.put(deployable, deployment);
}
catch (final org.jboss.deployers.spi.DeploymentException de)
{
// Construct a new DeploymentException of this API
final DeploymentException wrappedException = new DeploymentException(de);
// Remove all previously-added deployables from further MainDeployer processing
final Iterator<Entry<Deployable, Deployment>> it = deploymentsToBeAdded.entrySet().iterator();
while (it.hasNext())
{
final Entry<Deployable, Deployment> next = it.next();
final Deployable thisDeployable = next.getKey();
try
{
mainDeployer.removeDeployment(deploymentsToBeAdded.get(thisDeployable));
}
catch (org.jboss.deployers.spi.DeploymentException e)
{
log.warn("Atomic deployment of " + Arrays.asList(deployables) + " failed due to " + de.getMessage()
+ ", and we could not remove " + thisDeployable + " from further processing");