}
private void discoverPOJOWebServices(WebModule module, Map<String, String> portLocations, Map<String, PortInfo> servletNamePortInfoMap) throws DeploymentException {
Bundle bundle = module.getEarContext().getDeploymentBundle();
WebApp webApp = module.getSpecDD();
Set<String> ignoredEJBWebServiceClassNames = getEJBWebServiceClassNames(module);
if (webApp.isMetadataComplete()) {
// full web.xml, just examine all servlet entries for web services
List<Servlet> servletTypes = webApp.getServlet();
for (Servlet servletType : servletTypes) {
String servletName = servletType.getServletName().trim();
PortInfo portInfo = getPortInfo(servletType, bundle, portLocations);
if (portInfo != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Found POJO Web Service: {}", servletName);
}
servletNamePortInfoMap.put(servletName, portInfo);
}
}
} else {
// partial web.xml, discover all web service classes
Map<String, List<String>> classServletMap = createClassServetMap(webApp);
List<Class<?>> services = discoverWebServices(module);
String contextRoot = (module).getContextRoot();
for (Class<?> service : services) {
// skip interfaces and such
if (!JAXWSUtils.isWebService(service)) {
continue;
}
if (ignoredEJBWebServiceClassNames.contains(service.getName())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Web service " + service.getClass().getName() + " is ignored as it is also an EJB, it will exposed as an EJB Web Service ");
}
continue;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Discovered POJO Web Service class: {}", service.getName());
}
List<String> mappedServlets = classServletMap.get(service.getName());
if (mappedServlets == null) {
// no <servlet/> entry, add one
if (LOG.isDebugEnabled()) {
LOG.debug("POJO Web Service class {} is not mapped to any servlet", service.getName());
}
Servlet servlet = new Servlet();
servlet.setServletName(service.getName());
servlet.setServletClass(service.getName());
webApp.getServlet().add(servlet);
String location = portLocations.get(service.getName());
if (location == null) {
// add new <servlet-mapping/> element
location = "/" + JAXWSUtils.getServiceName(service);
ServletMapping servletMapping = new ServletMapping();
servletMapping.setServletName(service.getName());
servletMapping.getUrlPattern().add(location);
webApp.getServletMapping().add(servletMapping);
} else {
// weird, there was no servlet entry for this class but
// servlet-mapping exists
LOG.warn("Found <servlet-mapping> {} but corresponding <servlet> {} was not defined", location, service.getName());
}
// map service
PortInfo portInfo = new PortInfo();
portInfo.setLocation(contextRoot + location);
portInfo.setHandlerChainsInfo(annotationHandlerChainFinder.buildHandlerChainFromClass(service));
portInfo.setWsdlService(JAXWSUtils.getServiceQName(service));
portInfo.setWsdlPort(JAXWSUtils.getPortQName(service));
servletNamePortInfoMap.put(service.getName(), portInfo);
} else {
// found at least one mapped <servlet/> entry
for (String servlet : mappedServlets) {
if (LOG.isDebugEnabled()) {
LOG.debug("POJO Web Service class {} is mapped to {} servlet", service.getName(), servlet);
}
PortInfo portInfo = createPortInfo(servlet, portLocations);
portInfo.setWsdlService(JAXWSUtils.getServiceQName(service));
portInfo.setWsdlPort(JAXWSUtils.getPortQName(service));
servletNamePortInfoMap.put(servlet, portInfo);
}
}
}
// double check servlets in case we missed something
List<Servlet> servletTypes = webApp.getServlet();
for (Servlet servletType : servletTypes) {
String servletName = servletType.getServletName().trim();
if (servletNamePortInfoMap.get(servletName) == null) {
PortInfo portInfo = getPortInfo(servletType, bundle, portLocations);
if (portInfo != null) {