ArrayList<WebAppComponent> servlets = new ArrayList<WebAppComponent>();
if (this.enableJaxws) {
for (WsdlInfo wsdlInfo : getModelInternal().getNamespacesToWSDLs().values()) {
for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) {
String path = (String) ei.getMetaData().get("soapPath");
WebAppComponent wsComponent = new WebAppComponent();
wsComponent.setName(ei.getServiceName());
wsComponent.setClassname(ei.getEndpointImplementations().iterator().next().getQualifiedName());
wsComponent.setUrlMappings(new TreeSet<String>(Arrays.asList(path)));
servlets.add(wsComponent);
}
}
}
if (this.enableJaxrs) {
WebAppComponent jaxrsServletComponent = new WebAppComponent();
jaxrsServletComponent.setName("resteasy-jaxrs");
jaxrsServletComponent.setClassname(EnunciateJBossHttpServletDispatcher.class.getName());
TreeSet<String> jaxrsUrlMappings = new TreeSet<String>();
StringBuilder resources = new StringBuilder();
for (RootResource rootResource : getModel().getRootResources()) {
if (resources.length() > 0) {
resources.append(',');
}
resources.append(rootResource.getQualifiedName());
for (ResourceMethod resourceMethod : rootResource.getResourceMethods(true)) {
String resourceMethodPattern = resourceMethod.getServletPattern();
for (Set<String> subcontextList : ((Map<String, Set<String>>) resourceMethod.getMetaData().get("subcontexts")).values()) {
for (String subcontext : subcontextList) {
String servletPattern;
if ("".equals(subcontext)) {
servletPattern = resourceMethodPattern;
}
else {
servletPattern = subcontext + resourceMethodPattern;
}
if (jaxrsUrlMappings.add(servletPattern)) {
debug("Resource method %s of resource %s to be made accessible by servlet pattern %s.",
resourceMethod.getSimpleName(), resourceMethod.getParent().getQualifiedName(), servletPattern);
}
}
}
}
}
if (jaxrsUrlMappings.contains("/*")) {
jaxrsUrlMappings.clear();
jaxrsUrlMappings.add("/*");
}
else {
Iterator<String> iterator = jaxrsUrlMappings.iterator();
while (iterator.hasNext()) {
String mapping = iterator.next();
if (!mapping.endsWith("/*") && jaxrsUrlMappings.contains(mapping + "/*")) {
iterator.remove();
}
}
}
StringBuilder providers = new StringBuilder();
for (TypeDeclaration provider : getModel().getJAXRSProviders()) {
if (providers.length() > 0) {
providers.append(',');
}
providers.append(provider.getQualifiedName());
}
if (jacksonAvailable) {
if (providers.length() > 0) {
providers.append(',');
}
providers.append("org.codehaus.enunciate.jboss.ResteasyJacksonJaxbProvider");
}
if (getEnunciate().isModuleEnabled("amf")) {
if (providers.length() > 0) {
providers.append(',');
}
providers.append("org.codehaus.enunciate.modules.amf.JAXRSProvider");
}
jaxrsServletComponent.setUrlMappings(jaxrsUrlMappings);
jbossContextParameters.put(ResteasyContextParameters.RESTEASY_RESOURCES, resources.toString());
jbossContextParameters.put(ResteasyContextParameters.RESTEASY_PROVIDERS, providers.toString());
String mappingPrefix = this.useSubcontext ? getRestSubcontext() : "";
if (!"".equals(mappingPrefix)) {
jbossContextParameters.put("resteasy.servlet.mapping.prefix", mappingPrefix);
jaxrsServletComponent.addInitParam("resteasy.servlet.mapping.prefix", mappingPrefix);
}
if (isUsePathBasedConneg()) {
Map<String, String> contentTypesToIds = getModelInternal().getContentTypesToIds();
if (contentTypesToIds != null && contentTypesToIds.size() > 0) {
StringBuilder builder = new StringBuilder();