Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2012 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.kuali.rice.ksb.messaging.servlet;
 import java.util.List;

A org.springframework.web.servlet.DispatcherServlet which dispatches incoming requests to the appropriate service endpoint.

Kuali Rice Team (
 public class KSBDispatcherServlet extends DispatcherServlet {
 	private static final Logger LOG = Logger.getLogger(KSBDispatcherServlet.class);
 	private static final long serialVersionUID = 6790121225857950019L;
     private static final String REMOTING_SERVLET_CONFIG_LOCATION = "classpath:org/kuali/rice/ksb/config/remoting-servlet.xml";
 	protected void initFrameworkServlet() throws ServletExceptionBeansException {
         Bus bus = KSBServiceLocator.getCXFBus();
         List<Interceptor<? extends Message>> inInterceptors = KSBServiceLocator.getInInterceptors();
         if(inInterceptors != null) {
         	List<Interceptor<? extends Message>> busInInterceptors = bus.getInInterceptors();
         List<Interceptor<? extends Message>> outInterceptors = KSBServiceLocator.getOutInterceptors();
         if(outInterceptors != null) {
         	List<Interceptor<? extends Message>> busOutInterceptors = bus.getOutInterceptors();
 		ServletTransportFactory servletTransportFactory = KSBServiceLocator.getCXFServletTransportFactory();
 		this. = new ServletController(servletTransportFactorythis.getServletConfig(), this.getServletContext(), bus);
 		if (!ConfigContext.getCurrentContextConfig().getDevMode()) {
 		    // disable handling of URLs ending in /services which display CXF generated service lists
 	protected HandlerAdapter getHandlerAdapter(Object handlerthrows ServletException {
		if (handler instanceof HttpRequestHandler) {
else if (handler instanceof Controller) {
			Object unwrappedHandler = ClassLoaderUtils.unwrapFromProxy(handler);
			if (unwrappedHandler instanceof CXFServletControllerAdapter) {
				// TODO this just seems weird as this controller is initially null when it's created, does there need to be some synchronization here?
		throw new RiceRuntimeException("handler of type " + handler.getClass().getName() + " is not known and can't be used by " + KSBDispatcherServlet.class.getName());
	protected HandlerExecutionChain getHandler(HttpServletRequest requestboolean cachethrows Exception {
		return this..getHandler(request);
	protected ModelAndView processHandlerException(HttpServletRequest requestHttpServletResponse responseObject handlerException exthrows Exception {
		try {
			QName serviceName = this..getServiceNameFromRequest(request);
			.info("Caught Exception from service " + serviceNameex);
catch (Throwable throwable) {
			.warn("Caught exception attempting to log exception thrown from remotely accessed service"throwable);
		return null;

Overrides the service method to replace the request and responses with one which will provide input and output streams for verifying and signing the data.
	protected void service(HttpServletRequest requestHttpServletResponse responsethrows ServletExceptionIOException {
		if (isSecure(request)) {
			super.service(new SignatureVerifyingRequestWrapper(request), new SignatureSigningResponseWrapper(response));
else {
        return super.initWebApplicationContext();
	protected boolean isSecure(HttpServletRequest request) {
		QName serviceName = this..getServiceNameFromRequest(request);
		    .debug("Checking service " + serviceName + " for security enabled");
		Endpoint endpoint = KsbApiServiceLocator.getServiceBus().getEndpoint(serviceName);
		if (endpoint == null) {
			.error("Attempting to acquire non-existent service " + request.getRequestURI());
		    throw new RiceRuntimeException("Attempting to acquire non-existent service.");
		ServiceConfiguration serviceConfiguration = endpoint.getServiceConfiguration();
		if (serviceConfiguration instanceof SoapServiceConfiguration) {
		    return false;
		return serviceConfiguration.getBusSecurity();
New to GrepCode? Check out our FAQ X