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.server.deployment.Attachments.DEPLOYMENT_ROOT;
 import static org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS;
 import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
 import static org.jboss.as.webservices.util.ASHelper.getAnnotations;
 import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_ANNOTATION;
 import static org.jboss.as.webservices.util.WSAttachmentKeys.JMS_ENDPOINT_METADATA_KEY;
 
 import java.net.URL;
 import java.util.List;
 import java.util.Map;
 
 
DUP for detecting JMS WS endpoints

Author(s):
Alessio Soldano
 
 public final class WSIntegrationProcessorJAXWS_JMS implements DeploymentUnitProcessor {
 
     private static final String WSDL_LOCATION = "wsdlLocation";
     private static final String PORT_NAME = "portName";
     private static final String SERVICE_NAME = "serviceName";
     private static final String TARGET_NAMESPACE = "targetNamespace";
 
     @Override
     public void deploy(final DeploymentPhaseContext phaseContextthrows DeploymentUnitProcessingException {
         final DeploymentUnit unit = phaseContext.getDeploymentUnit();
         if (DeploymentTypeMarker.isType(.unit)) {
             return;
         }
         final List<AnnotationInstancewebServiceAnnotations = getAnnotations(unit);
         // TODO: how about @WebServiceProvider JMS based endpoints?
 
         //group @WebService annotations in the deployment by wsdl contract location
         Map<StringList<AnnotationInstance>> map = new HashMap<StringList<AnnotationInstance>>();
         for (AnnotationInstance webServiceAnnotation : webServiceAnnotations) {
             final AnnotationValue wsdlLocation = webServiceAnnotation.value();
             final AnnotationValue port = webServiceAnnotation.value();
             final AnnotationValue service = webServiceAnnotation.value();
             //support for contract-first development only: pick-up @WebService annotations referencing a provided wsdl contract only
             if (wsdlLocation != null && port != null && service != null) {
                 String key = wsdlLocation.asString();
                 List<AnnotationInstanceannotations = map.get(key);
                 if (annotations == null) {
                     annotations = new LinkedList<AnnotationInstance>();
                     map.put(keyannotations);
                 }
                 annotations.add(webServiceAnnotation);
             }
         }
 
         //extract SOAP-over-JMS 1.0 bindings
         List<JMSEndpointMetaDatalist = new LinkedList<JMSEndpointMetaData>();
         if (!map.isEmpty()) {
 
             for (String wsdlLocation : map.keySet()) {
                 try {
                    final ResourceRoot resourceRoot = getWsdlResourceRoot(unitwsdlLocation);
                    if (resourceRoot == nullcontinue;
                    final VirtualFile wsdlLocationFile = resourceRoot.getRoot().getChild(wsdlLocation);
                    final URL url = wsdlLocationFile.toURL();
                    SOAPAddressWSDLParser parser = new SOAPAddressWSDLParser(url);
                    for (AnnotationInstance ai : map.get(wsdlLocation)) {
                        String port = ai.value().asString();
                        String service = ai.value().asString();
                        AnnotationValue targetNS = ai.value();
                        String tns = targetNS != null ? targetNS.asString() : null;
                        QName serviceName = new QName(tnsservice);
                        QName portName = new QName(tnsport);
                        String soapAddress = parser.filterSoapAddress(serviceNameportName.);
                        if (soapAddress != null) {
                            ClassInfo webServiceClassInfo = (ClassInfoai.target();
                            String beanClassName = webServiceClassInfo.name().toString();
                            //service name ?
                            list.add(new JMSEndpointMetaData(beanClassNameportbeanClassNamewsdlLocationsoapAddress));
                        }
                    }
                } catch (Exception ignore) {
                    .cannotReadWsdl(wsdlLocation);
                }
            }
        }
    }
    @Override
    public void undeploy(final DeploymentUnit context) {
        // NOOP
    }
    private static ResourceRoot getWsdlResourceRoot(final DeploymentUnit unitfinal String wsdlPath) {
        final AttachmentList<ResourceRootresourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class);
        final ResourceRoot root = unit.getAttachment();
        resourceRoots.add(root);
        final AttachmentList<ResourceRoototherResourceRoots = unit.getAttachment();
        if (otherResourceRoots != null) {
            resourceRoots.addAll(otherResourceRoots);
        }
        for (final ResourceRoot resourceRoot : resourceRoots) {
            VirtualFile file = resourceRoot.getRoot().getChild(wsdlPath);
            if (file.exists()) return resourceRoot;
        }
        return null;
    }
New to GrepCode? Check out our FAQ X