/** * Executed after each undeploy for the container. * * @param afterDeploy the lifecycle event * @param container the container the event is being invoked on * * @throws Exception if an error occurs processing the event */ public synchronized void handleAfterUndeploy(@Observes AfterUnDeploy afterDeploy, final Container container) throws Exception { final String containerName = container.getName(); final ServerSetupTaskHolder holder = setupTasks.get(containerName); if (holder == null) { return; } // Remove the deployment if (holder.deployments.remove(afterDeploy.getDeployment())) { // If the deployments are now empty and the AfterClass has been invoked we need to ensure the tearDown() has // happened. This should clean up any tasks left from managed deployments or unmanaged deployments that were // not undeployed manually. if (afterClassRun && holder.deployments.isEmpty()) { holder.tearDown(containerName); setupTasks.remove(containerName); } } }
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription description = deployment.getDescription(); deployEvent.fire(new BeforeUnDeploy(deployableContainer, description)); try { if (deployment.getDescription().isArchiveDeployment()) { try { deployableContainer.undeploy( description.getTestableArchive() != null ? description.getTestableArchive() : description.getArchive()); } catch (Exception e) { if (!deployment.hasDeploymentError()) { throw e; } } } else { deployableContainer.undeploy(description.getDescriptor()); } } finally { deployment.undeployed(); } deployEvent.fire(new AfterUnDeploy(deployableContainer, description)); return null; } });
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription description = deployment.getDescription(); deployEvent.fire(new BeforeUnDeploy(deployableContainer, description)); try { if (deployment.getDescription().isArchiveDeployment()) { try { deployableContainer.undeploy( description.getTestableArchive() != null ? description.getTestableArchive() : description.getArchive()); } catch (Exception e) { if (!deployment.hasDeploymentError()) { throw e; } } } else { deployableContainer.undeploy(description.getDescriptor()); } } finally { deployment.undeployed(); } deployEvent.fire(new AfterUnDeploy(deployableContainer, description)); return null; } });
/** * Executed after each undeploy for the container. * * @param afterDeploy the lifecycle event * @param container the container the event is being invoked on * * @throws Exception if an error occurs processing the event */ public synchronized void handleAfterUndeploy(@Observes AfterUnDeploy afterDeploy, final Container container) throws Exception { final String containerName = container.getName(); final ServerSetupTaskHolder holder = setupTasks.get(containerName); if (holder == null) { return; } // Remove the deployment if (holder.deployments.remove(afterDeploy.getDeployment())) { // If the deployments are now empty and the AfterClass has been invoked we need to ensure the tearDown() has // happened. This should clean up any tasks left from managed deployments or unmanaged deployments that were // not undeployed manually. if (afterClassRun && holder.deployments.isEmpty()) { holder.tearDown(containerName); setupTasks.remove(containerName); } } }