private void createWGAServicesSOAPFilter(WGACore core) {
try {
// Determine the protocol implementation to use
String implClass = core.getWgaConfiguration().getWebServiceProtocolImplementation();
ModuleDefinition protocolDefinition = null;
if (implClass != null) {
protocolDefinition = core.getModuleRegistry().getModuleDefinition(WGAServicesSoapProtocolModuleType.class, implClass);
if (protocolDefinition == null) {
core.getLog().error("Unable to use WGAServices protocol implementation " + implClass + " because it is not registered");
}
}
// If not configured or configured not found, try to take the "first best"
if (protocolDefinition == null) {
Iterator<ModuleDefinition> impls = core.getModuleRegistry().getModulesForType(WGAServicesSoapProtocolModuleType.class).values().iterator();
if (impls.hasNext()) {
protocolDefinition = impls.next();
}
}
// Create and init the filter (which we do anyway, even if there are no protocol implementation)
FilterMapping filterMapping = new FilterMapping();
filterMapping.setName("WGAServices SOAP Request Filter");
filterMapping.setEnabled(true);
filterMapping.setImplClassName(WGAServicesSOAPFilter.class.getName());
List<String> patterns = new ArrayList<String>();
patterns.add("/services/*");
patterns.add("//services/*");
filterMapping.setUrlPatterns(patterns);
Map<String, String> parameters = new HashMap<String, String>();
// If we have a definition we pass on the servlet class to the filter, otherwise we used the "SOAP disabled" servlet
if (protocolDefinition != null) {
parameters.put(WGAServicesSOAPFilter.PARAM_PROTOCOL_SERVLET, protocolDefinition.getImplementationClass().getName());
}
else {
parameters.put(WGAServicesSOAPFilter.PARAM_PROTOCOL_SERVLET, WGAServicesSOAPDisabledServlet.class.getName());
}
filterMapping.setInitParameters(parameters);
WGAServicesSOAPFilter filter = new WGAServicesSOAPFilter();
WGAFilterConfig filterConfig = WGAFilterConfig.createFromMapping(filterMapping);
filterConfig.setServletContext(core.getServletContext());
filter.init(filterConfig);
_filters.add(filter);
_filterToURLPatterns.put(filter, filterMapping.getUrlPatterns());
if (protocolDefinition != null) {
core.getLog().info("WGAServices enabled using protocol implementation " + protocolDefinition.getTitle(Locale.getDefault()));
}
else {
core.getLog().info("No WGAServices SOAP protocol implementation available. SOAP Web Service is disabled.");
}
}