@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (isWebServiceDeployment(unit)) {
ensureAspectInitialized();
final Deployment dep = ASHelper.getRequiredAttachment(unit, WSAttachmentKeys.DEPLOYMENT_KEY);
if (aspect.canHandle(dep)) {
ROOT_LOGGER.aspectStart(aspect, unit.getName());
ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
final List<SetupAction> setupActions = unit.getAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS);
try {
SecurityActions.setContextClassLoader(aspect.getLoader());
dep.addAttachment(ServiceTarget.class, phaseContext.getServiceTarget());
for (final SetupAction action : setupActions) {
action.setup(null);
}
aspect.start(dep);
dep.removeAttachment(ServiceTarget.class);
} finally {
for (final SetupAction action : setupActions) {
action.teardown(null);
}
SecurityActions.setContextClassLoader(origClassLoader);