in modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java [290:444]
protected ArrayList<AxisService> populateService(AxisServiceGroup serviceGroup,
URL servicesURL, String serviceName) throws DeploymentException {
try {
serviceGroup.setServiceGroupName(serviceName);
ClassLoader serviceClassLoader = Utils
.createClassLoader(servicesURL, null, axisConfig
.getServiceClassLoader(), (File) axisConfig
.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR),
axisConfig.isChildFirstClassLoading());
String metainf = "meta-inf";
serviceGroup.setServiceGroupClassLoader(serviceClassLoader);
// processing wsdl.list
InputStream wsdlfilesStream = serviceClassLoader
.getResourceAsStream("meta-inf/wsdl.list");
if (wsdlfilesStream == null) {
wsdlfilesStream = serviceClassLoader.getResourceAsStream("META-INF/wsdl.list");
if (wsdlfilesStream != null) {
metainf = "META-INF";
}
}
HashMap<String, AxisService> servicesMap = new HashMap<String, AxisService>();
if (wsdlfilesStream != null) {
ArchiveReader reader = new ArchiveReader();
BufferedReader input = new BufferedReader(new InputStreamReader(wsdlfilesStream));
String line;
while ((line = input.readLine()) != null) {
line = line.trim();
if (line.length() > 0 && line.charAt(0) != '#') {
line = metainf + "/" + line;
try {
List<AxisService> services = reader.getAxisServiceFromWsdl(
serviceClassLoader.getResourceAsStream(line),
serviceClassLoader, line);
if (services != null) {
for (Object service : services) {
AxisService axisService = (AxisService) service;
servicesMap.put(axisService.getName(), axisService);
}
}
} catch (Exception e) {
throw new DeploymentException(e);
}
}
}
}
InputStream servicexmlStream = serviceClassLoader
.getResourceAsStream("META-INF/services.xml");
if (servicexmlStream == null) {
servicexmlStream = serviceClassLoader.getResourceAsStream("meta-inf/services.xml");
} else {
metainf = "META-INF";
}
if (servicexmlStream == null) {
throw new DeploymentException(Messages.getMessage(
DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND, servicesURL.toString()));
}
DescriptionBuilder builder = new DescriptionBuilder(servicexmlStream, configCtx);
OMElement rootElement = builder.buildOM();
String elementName = rootElement.getLocalName();
if (DeploymentConstants.TAG_SERVICE.equals(elementName)) {
AxisService axisService = null;
String wsdlLocation = "META-INF/service.wsdl";
InputStream wsdlStream = serviceClassLoader.getResourceAsStream(wsdlLocation);
URL wsdlURL = serviceClassLoader.getResource(metainf + "/service.wsdl");
if (wsdlStream == null) {
wsdlLocation = "META-INF/" + serviceName + ".wsdl";
wsdlStream = serviceClassLoader.getResourceAsStream(wsdlLocation);
wsdlURL = serviceClassLoader.getResource(wsdlLocation);
}
if (wsdlStream != null) {
WSDL11ToAxisServiceBuilder wsdl2AxisServiceBuilder = new WSDL11ToAxisServiceBuilder(
wsdlStream, null, null);
File file = Utils.toFile(servicesURL);
if (file != null && file.exists()) {
wsdl2AxisServiceBuilder.setCustomWSDLResolver(new AARBasedWSDLLocator(
wsdlLocation, file, wsdlStream));
wsdl2AxisServiceBuilder
.setCustomResolver(new AARFileBasedURIResolver(file));
}
if (wsdlURL != null) {
wsdl2AxisServiceBuilder.setDocumentBaseUri(wsdlURL.toString());
}
axisService = wsdl2AxisServiceBuilder.populateService();
axisService.setWsdlFound(true);
axisService.setCustomWsdl(true);
axisService.setName(serviceName);
}
if (axisService == null) {
axisService = new AxisService(serviceName);
}
axisService.setParent(serviceGroup);
axisService.setClassLoader(serviceClassLoader);
ServiceBuilder serviceBuilder = new ServiceBuilder(configCtx, axisService);
AxisService service = serviceBuilder.populateService(rootElement);
ArrayList<AxisService> serviceList = new ArrayList<AxisService>();
serviceList.add(service);
return serviceList;
} else if (DeploymentConstants.TAG_SERVICE_GROUP.equals(elementName)) {
ServiceGroupBuilder groupBuilder = new ServiceGroupBuilder(rootElement,
servicesMap, configCtx);
ArrayList<AxisService> servicList = groupBuilder.populateServiceGroup(serviceGroup);
Iterator<AxisService> serviceIterator = servicList.iterator();
while (serviceIterator.hasNext()) {
AxisService axisService = (AxisService) serviceIterator.next();
String wsdlLocation = "META-INF/service.wsdl";
InputStream wsdlStream = serviceClassLoader.getResourceAsStream(wsdlLocation);
URL wsdlURL = serviceClassLoader.getResource(wsdlLocation);
if (wsdlStream == null) {
wsdlLocation = "META-INF/" + serviceName + ".wsdl";
wsdlStream = serviceClassLoader.getResourceAsStream(wsdlLocation);
wsdlURL = serviceClassLoader.getResource(wsdlLocation);
}
if (wsdlStream != null) {
WSDL11ToAxisServiceBuilder wsdl2AxisServiceBuilder = new WSDL11ToAxisServiceBuilder(
wsdlStream, axisService);
File file = Utils.toFile(servicesURL);
if (file != null && file.exists()) {
wsdl2AxisServiceBuilder.setCustomWSDLResolver(new AARBasedWSDLLocator(
wsdlLocation, file, wsdlStream));
wsdl2AxisServiceBuilder.setCustomResolver(new AARFileBasedURIResolver(
file));
}
if (wsdlURL != null) {
wsdl2AxisServiceBuilder.setDocumentBaseUri(wsdlURL.toString());
}
axisService = wsdl2AxisServiceBuilder.populateService();
axisService.setWsdlFound(true);
axisService.setCustomWsdl(true);
// Set the default message receiver for the operations
// that were
// not listed in the services.xml
Iterator<AxisOperation> operations = axisService.getOperations();
while (operations.hasNext()) {
AxisOperation operation = (AxisOperation) operations.next();
if (operation.getMessageReceiver() == null) {
operation.setMessageReceiver(loadDefaultMessageReceiver(
operation.getMessageExchangePattern(), axisService));
}
}
}
}
return servicList;
}
} catch (IOException e) {
throw new DeploymentException(e);
} catch (XMLStreamException e) {
throw new DeploymentException(e);
}
return null;
}