use of org.jboss.ws.common.deployment.SOAPAddressWSDLParser in project wildfly by wildfly.
the class WSIntegrationProcessorJAXWS_JMS method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
return;
}
final List<AnnotationInstance> webServiceAnnotations = getAnnotations(unit, WEB_SERVICE_ANNOTATION);
// TODO: how about @WebServiceProvider JMS based endpoints?
//group @WebService annotations in the deployment by wsdl contract location
Map<String, List<AnnotationInstance>> map = new HashMap<String, List<AnnotationInstance>>();
for (AnnotationInstance webServiceAnnotation : webServiceAnnotations) {
final AnnotationValue wsdlLocation = webServiceAnnotation.value(WSDL_LOCATION);
final AnnotationValue port = webServiceAnnotation.value(PORT_NAME);
final AnnotationValue service = webServiceAnnotation.value(SERVICE_NAME);
//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<AnnotationInstance> annotations = map.get(key);
if (annotations == null) {
annotations = new LinkedList<AnnotationInstance>();
map.put(key, annotations);
}
annotations.add(webServiceAnnotation);
}
}
//extract SOAP-over-JMS 1.0 bindings
List<JMSEndpointMetaData> list = new LinkedList<JMSEndpointMetaData>();
if (!map.isEmpty()) {
for (String wsdlLocation : map.keySet()) {
try {
final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
if (resourceRoot == null)
continue;
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(PORT_NAME).asString();
String service = ai.value(SERVICE_NAME).asString();
AnnotationValue targetNS = ai.value(TARGET_NAMESPACE);
String tns = targetNS != null ? targetNS.asString() : null;
QName serviceName = new QName(tns, service);
QName portName = new QName(tns, port);
String soapAddress = parser.filterSoapAddress(serviceName, portName, SOAPAddressWSDLParser.SOAP_OVER_JMS_NS);
if (soapAddress != null) {
ClassInfo webServiceClassInfo = (ClassInfo) ai.target();
String beanClassName = webServiceClassInfo.name().toString();
//service name ?
list.add(new JMSEndpointMetaData(beanClassName, port, beanClassName, wsdlLocation, soapAddress));
}
}
} catch (Exception ignore) {
WSLogger.ROOT_LOGGER.cannotReadWsdl(wsdlLocation);
}
}
}
unit.putAttachment(JMS_ENDPOINT_METADATA_KEY, new JMSEndpointsMetaData(list));
}
Aggregations