use of org.apache.openejb.jee.JavaWsdlMapping in project tomee by apache.
the class DeploymentLoader method addWebservices.
private static void addWebservices(final WsModule wsModule) throws OpenEJBException {
final boolean webservicesEnabled = SystemInstance.get().getOptions().get(ConfigurationFactory.WEBSERVICES_ENABLED, true);
if (!webservicesEnabled) {
wsModule.getAltDDs().remove("webservices.xml");
// should be null already, but just for good measure
wsModule.setWebservices(null);
return;
}
// get location of webservices.xml file
final Object webservicesObject = wsModule.getAltDDs().get("webservices.xml");
if (webservicesObject == null || !(webservicesObject instanceof URL)) {
return;
}
final URL webservicesUrl = (URL) webservicesObject;
// determine the base url for this module (either file: or jar:)
URL moduleUrl;
try {
final File jarFile = new File(wsModule.getJarLocation());
moduleUrl = jarFile.toURI().toURL();
if (jarFile.isFile()) {
moduleUrl = new URL("jar", "", -1, moduleUrl + "!/");
}
} catch (final MalformedURLException e) {
logger.warning("Invalid module location " + wsModule.getJarLocation());
return;
}
// parse the webservices.xml file
final Map<URL, JavaWsdlMapping> jaxrpcMappingCache = new HashMap<URL, JavaWsdlMapping>();
final Webservices webservices = ReadDescriptors.readWebservices(webservicesUrl);
wsModule.setWebservices(webservices);
if ("file".equals(webservicesUrl.getProtocol())) {
wsModule.getWatchedResources().add(URLs.toFilePath(webservicesUrl));
}
// parse any jaxrpc-mapping-files mentioned in the webservices.xml file
for (final WebserviceDescription webserviceDescription : webservices.getWebserviceDescription()) {
final String jaxrpcMappingFile = webserviceDescription.getJaxrpcMappingFile();
if (jaxrpcMappingFile != null) {
final URL jaxrpcMappingUrl;
try {
jaxrpcMappingUrl = new URL(moduleUrl, jaxrpcMappingFile);
JavaWsdlMapping jaxrpcMapping = jaxrpcMappingCache.get(jaxrpcMappingUrl);
if (jaxrpcMapping == null) {
jaxrpcMapping = ReadDescriptors.readJaxrpcMapping(jaxrpcMappingUrl);
jaxrpcMappingCache.put(jaxrpcMappingUrl, jaxrpcMapping);
}
webserviceDescription.setJaxrpcMapping(jaxrpcMapping);
if ("file".equals(jaxrpcMappingUrl.getProtocol())) {
wsModule.getWatchedResources().add(URLs.toFilePath(jaxrpcMappingUrl));
}
} catch (final MalformedURLException e) {
logger.warning("Invalid jaxrpc-mapping-file location " + jaxrpcMappingFile);
}
}
}
}
use of org.apache.openejb.jee.JavaWsdlMapping in project tomee by apache.
the class AxisService method getJaxRpcServiceInfo.
private JaxRpcServiceInfo getJaxRpcServiceInfo(ClassLoader classLoader) throws OpenEJBException {
// the java to wsdl mapping file
JavaWsdlMapping mapping = null;
// the schema data from the wsdl file
CommonsSchemaInfoBuilder xmlBeansSchemaInfoBuilder = new CommonsSchemaInfoBuilder(null, null);
// webservice.xml declaration of this service
PortComponent portComponent = null;
// wsdl.xml declaration of this service
Port port = null;
String wsdlFile = null;
XmlSchemaInfo schemaInfo = xmlBeansSchemaInfoBuilder.createSchemaInfo();
JaxRpcServiceInfoBuilder serviceInfoBuilder = new JaxRpcServiceInfoBuilder(mapping, schemaInfo, portComponent, port, wsdlFile, classLoader);
JaxRpcServiceInfo serviceInfo = serviceInfoBuilder.createServiceInfo();
return serviceInfo;
}
Aggregations