Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2011, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.as.webservices.deployers;
 
 import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
 
Adaptor of DeploymentAspect to DeploymentUnitProcessor

Author(s):
Alessio Soldano
Richard Opalka
 
 public final class AspectDeploymentProcessor implements DeploymentUnitProcessor {
 
     private Class<? extends DeploymentAspectclazz;
     private String aspectClass;
     private DeploymentAspect aspect;
 
     public AspectDeploymentProcessor(final Class<? extends DeploymentAspectaspectClass) {
         this. = aspectClass;
     }
 
     public AspectDeploymentProcessor(final String aspectClass) {
         this. = aspectClass;
     }
 
     public AspectDeploymentProcessor(final DeploymentAspect aspect) {
         this. = aspect;
         this. = aspect.getClass();
     }
 
     @Override
     public void deploy(final DeploymentPhaseContext phaseContextthrows DeploymentUnitProcessingException {
         final DeploymentUnit unit = phaseContext.getDeploymentUnit();
         if (isWebServiceDeployment(unit)) {
             ensureAspectInitialized();
             final Deployment dep = ASHelper.getRequiredAttachment(unit.);
             if (.canHandle(dep)) {
                 .aspectStart(unit.getName());
                 ClassLoader origClassLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
                 try {
                     WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(.getLoader());
                     dep.addAttachment(ServiceTarget.classphaseContext.getServiceTarget());
                     .start(dep);
                     dep.removeAttachment(ServiceTarget.class);
                 } finally {
                     WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(origClassLoader);
                 }
             }
         }
     }
 
     @Override
     public void undeploy(final DeploymentUnit unit) {
         if (isWebServiceDeployment(unit)) {
             final Deployment dep = ASHelper.getRequiredAttachment(unit.);
             if (.canHandle(dep)) {
                 .aspectStop(unit.getName());
                 ClassLoader origClassLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
                 try {
                     WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(.getLoader());
                     .stop(dep);
                 } finally {
                     WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(origClassLoader);
                 }
             }
         }
     }
    @SuppressWarnings("unchecked")
        if ( == null) {
            try {
                if ( == null) {
                     = (Class<? extends DeploymentAspect>) ClassLoaderProvider.getDefaultProvider()
                            .getServerIntegrationClassLoader().loadClass();
                }
                 = .newInstance();
            } catch (Exception e) {
                throw new DeploymentUnitProcessingException(e);
            }
        }
    }
    private static boolean isWebServiceDeployment(final DeploymentUnit unit) {
        return unit.getAttachment(.) != null;
    }
New to GrepCode? Check out our FAQ X