Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2015, Red Hat, Inc., 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.server.deployment.Attachments.DEPLOYMENT_ROOT;
 import static org.jboss.as.webservices.util.ASHelper.getJaxwsEjbs;
 import static org.jboss.as.webservices.util.ASHelper.getJaxwsPojos;
 import static org.jboss.as.webservices.util.ASHelper.getOptionalAttachment;
 import static org.jboss.as.webservices.util.ASHelper.isJaxwsEndpoint;
 import static org.jboss.as.webservices.util.WSAttachmentKeys.WS_ENDPOINT_HANDLERS_MAPPING_KEY;
 
 import java.util.Set;
 
 
 import  org.jboss.metadata.web.jboss.JBossWebMetaData;

Author(s):
Richard Opalka
Jim Ma
Alessio Soldano
 
 
     }
 
     @Override
     protected void processAnnotation(final DeploymentUnit unitfinal EEModuleDescription moduleDescriptionthrows DeploymentUnitProcessingException {
         final VirtualFile root = unit.getAttachment().getRoot();
         final JBossWebservicesMetaData jbossWebservicesMD = unit.getAttachment(.);
         final CompositeIndex index = unit.getAttachment(.);
         final boolean war = DeploymentTypeMarker.isType(.unit);
         final JBossWebMetaData jwmd = ASHelper.getJBossWebMetaData(unit);
         for (EEModuleClassDescription classDescription : moduleDescription.getClassDescriptions()) {
             ClassInfo classInfo = null;
             ClassAnnotationInformation<WebServiceWebServiceAnnotationInfoannotationInfo = classDescription
                     .getAnnotationInformation(WebService.class);
             if (annotationInfo != null) {
                 classInfo = (ClassInfoannotationInfo.getClassLevelAnnotations().get(0).getTarget();
             }
             final ClassAnnotationInformation<WebServiceProviderWebServiceProviderAnnotationInfoprovidreInfo = classDescription
                         .getAnnotationInformation(WebServiceProvider.class);
             if (providreInfo != null) {
                 classInfo = (ClassInfoprovidreInfo.getClassLevelAnnotations().get(0).getTarget();
             }
 
             if (classInfo != null && isJaxwsEndpoint(classInfoindexfalse)) {
                 final String endpointClassName = classInfo.name().toString();
                 final ConfigResolver configResolver = new ConfigResolver(classInfojbossWebservicesMDjwmdrootwar);
                 final EndpointConfig config = configResolver.resolveEndpointConfig();
                 if (config != null) {
                 	registerConfigMapping(endpointClassNameconfigunit);
                 }
                 final Set<Stringhandlers = getHandlers(endpointClassNameconfigconfigResolvermapping);
                if (!handlers.isEmpty()) {
                    if (isEjb3(classInfo)) {
                        for (final EJBEndpoint ejbEndpoint : getJaxwsEjbs(unit)) {
                            if (endpointClassName.equals(ejbEndpoint.getClassName())) {
                                for (final String handlerClassName : handlers) {
                                    final String ejbEndpointName = ejbEndpoint.getName();
                                    final String handlerName = ejbEndpointName + "-" + handlerClassName;
                                    final ComponentDescription jaxwsHandlerDescription = createComponentDescription(unit,
                                            handlerNamehandlerClassNameejbEndpointName);
                                    propagateNamingContext(jaxwsHandlerDescriptionejbEndpoint);
                                }
                            }
                        }
                    } else {
                        for (final POJOEndpoint pojoEndpoint : getJaxwsPojos(unit)) {
                            if (endpointClassName.equals(pojoEndpoint.getClassName())) {
                                for (final String handlerClassName : handlers) {
                                    final String pojoEndpointName = pojoEndpoint.getName();
                                    final String handlerName = pojoEndpointName + "-" + handlerClassName;
                                    createComponentDescription(unithandlerNamehandlerClassNamepojoEndpointName);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //TODO this could be moved to a separate DeploymentUnitProcessor operating on endpoints (together with the rest of the config resolution mechanism)
    private void registerConfigMapping(String endpointClassNameEndpointConfig configDeploymentUnit unit) {
        if (mapping == null) {
            mapping = new WSEndpointConfigMapping();
            unit.putAttachment(.mapping);
        }
        mapping.registerEndpointConfig(endpointClassNameconfig);
    }
    private Set<StringgetHandlers(String endpointClassNameEndpointConfig configConfigResolver resolverWSEndpointHandlersMapping mapping) {
        Set<Stringhandlers = resolver.getAllHandlers(config); //handlers from the resolved endpoint configuration
        if (mapping != null) {
            Set<Stringhch = mapping.getHandlers(endpointClassName); // handlers from @HandlerChain
            if (hch != null) {
                handlers.addAll(hch);
            }
        }
        return handlers;
    }
    private static void propagateNamingContext(final ComponentDescription jaxwsHandlerDescriptionfinal EJBEndpoint ejbEndpoint) {
        final ServiceName ejbContextServiceName = ejbEndpoint.getContextServiceName();
        final DeploymentDescriptorEnvironment ejbEnv = ejbEndpoint.getDeploymentDescriptorEnvironment();
        // configure JAXWS EJB3 handler to be able to see EJB3 environment
        jaxwsHandlerDescription.setContextServiceName(ejbContextServiceName);
        jaxwsHandlerDescription.setDeploymentDescriptorEnvironment(ejbEnv);
        jaxwsHandlerDescription.addDependency(ejbContextServiceName..);
    }
New to GrepCode? Check out our FAQ X