From 0b61e89996207920b2e4ff7634c61d6bb8976dd2 Mon Sep 17 00:00:00 2001 From: Rick Evans Date: Wed, 30 May 2007 08:04:52 +0000 Subject: [PATCH] Added missing Apache license header. --- .../http/MessageDispatcherServlet.java | 131 +++++++++++------- 1 file changed, 79 insertions(+), 52 deletions(-) diff --git a/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java b/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java index 34e8ed7e..7e31f0e5 100644 --- a/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java +++ b/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java @@ -1,3 +1,19 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.ws.transport.http; import java.util.Map; @@ -25,19 +41,25 @@ import org.springframework.ws.transport.support.DefaultStrategiesHelper; import org.springframework.ws.wsdl.WsdlDefinition; /** - * Servlet for simplified dispatching of Web service messages. This servlet is a convenient alternative for a standard - * Spring-MVC {@link DispatcherServlet} with a separate {@link WebServiceMessageReceiverHandlerAdapter} and a {@link - * MessageDispatcher}, and a {@link WsdlDefinitionHandlerAdapter}. - *

- * This servlet automatically detects {@link EndpointAdapter}s, {@link EndpointMapping}s, and {@link - * EndpointExceptionResolver}s by type. - *

- * This servlet also automatically detects any {@link WsdlDefinition} in its application context. This WSDL is exposed - * under the bean name (e.g. a {@link WsdlDefinition} bean named 'echo' will be exposed as - * echo.wsdl in this servlet's context: http://localhost:8080/spring-ws/echo.wsdl). When the - * transformWsdlLocations init-param is set to true in this servlet's configuration in - * web.xml, all location attributes in the WSDL definitions will reflect the URL of the - * incoming request. + * Servlet for simplified dispatching of Web service messages. + * + *

This servlet is a convenient alternative to the standard Spring-MVC + * {@link DispatcherServlet} with separate + * {@link WebServiceMessageReceiverHandlerAdapter}, {@link MessageDispatcher}, and + * {@link WsdlDefinitionHandlerAdapter} instances. + * + *

This servlet automatically detects {@link EndpointAdapter EndpointAdapters}, + * {@link EndpointMapping EndpointMappings}, and + * {@link EndpointExceptionResolver EndpointExceptionResolvers} by type. + * + *

This servlet also automatically detects any {@link WsdlDefinition} in its + * application context. This WSDL is exposed under the bean name: for example, a + * {@link WsdlDefinition} bean named 'echo' will be exposed as + * echo.wsdl in this servlet's context: + * http://localhost:8080/spring-ws/echo.wsdl. When the + * transformWsdlLocations init-param is set to true in + * this servlet's configuration in web.xml, all location + * attributes in the WSDL definitions will reflect the URL of the incoming request. * * @author Arjen Poutsma * @see org.springframework.web.servlet.DispatcherServlet @@ -46,15 +68,15 @@ import org.springframework.ws.wsdl.WsdlDefinition; */ public class MessageDispatcherServlet extends FrameworkServlet { - /** Well-known name for the WebServiceMessageFactory object in the bean factory for this namespace. */ + /** Well-known name for the {@link WebServiceMessageFactory} bean in the bean factory for this namespace. */ public static final String WEB_SERVICE_MESSAGE_FACTORY_BEAN_NAME = "messageFactory"; - /** Well-known name for the WebServiceMessageReceiver object in the bean factory for this namespace. */ + /** Well-known name for the {@link WebServiceMessageReceiver} object in the bean factory for this namespace. */ public static final String MESSAGE_RECEIVER_BEAN_NAME = "messageReceiver"; /** - * Name of the class path resource (relative to the MessageDispatcherServlet class) that defines - * MessageDispatcherServlet's default strategy names. + * Name of the class path resource (relative to the {@link MessageDispatcherServlet} + * class) that defines MessageDispatcherServlet's default strategy names. */ private static final String DEFAULT_STRATEGIES_PATH = "MessageDispatcherServlet.properties"; @@ -63,36 +85,37 @@ public class MessageDispatcherServlet extends FrameworkServlet { private final DefaultStrategiesHelper defaultStrategiesHelper; - /** The WebServiceMessageReceiverHandlerAdapter used by this servlet. */ + /** The {@link WebServiceMessageReceiverHandlerAdapter} used by this servlet. */ private WebServiceMessageReceiverHandlerAdapter messageReceiverHandlerAdapter = new WebServiceMessageReceiverHandlerAdapter(); - /** The WsdlDefinitionHandlerAdapter used by this servlet. */ + /** The {@link WsdlDefinitionHandlerAdapter} used by this servlet. */ private WsdlDefinitionHandlerAdapter wsdlDefinitionHandlerAdapter = new WsdlDefinitionHandlerAdapter(); - /** The WebServiceMessageReceiver used by this servlet. */ + /** The {@link WebServiceMessageReceiver} used by this servlet. */ private WebServiceMessageReceiver messageReceiver; - /** Keys are bean names, values are WsdlDefinitions. */ + /** Keys are bean names, values are {@link WsdlDefinition WsdlDefinitions}. */ private Map wsdlDefinitions; private boolean transformWsdlLocations = false; /** Public constructor, necessary for some Web application servers. */ public MessageDispatcherServlet() { - defaultStrategiesHelper = new DefaultStrategiesHelper( + this.defaultStrategiesHelper = new DefaultStrategiesHelper( new ClassPathResource(DEFAULT_STRATEGIES_PATH, MessageDispatcherServlet.class)); } /** - * Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming - * HttpServletRequest. Defaults to false. + * Sets whether relative address locations in the WSDL are to be transformed using + * the request URI of the incoming {@link HttpServletRequest}. + *

Defaults to false. */ public void setTransformWsdlLocations(boolean transformWsdlLocations) { this.transformWsdlLocations = transformWsdlLocations; } - /** Returns the WebServiceMessageReceiver used by this servlet. */ + /** Returns the {@link WebServiceMessageReceiver} used by this servlet. */ protected WebServiceMessageReceiver getMessageReceiver() { return messageReceiver; } @@ -106,10 +129,10 @@ public class MessageDispatcherServlet extends FrameworkServlet { protected long getLastModified(HttpServletRequest httpServletRequest) { WsdlDefinition definition = getWsdlDefinition(httpServletRequest); if (definition != null) { - return wsdlDefinitionHandlerAdapter.getLastModified(httpServletRequest, definition); + return this.wsdlDefinitionHandlerAdapter.getLastModified(httpServletRequest, definition); } else { - return messageReceiverHandlerAdapter.getLastModified(httpServletRequest, messageReceiver); + return this.messageReceiverHandlerAdapter.getLastModified(httpServletRequest, this.messageReceiver); } } @@ -117,26 +140,27 @@ public class MessageDispatcherServlet extends FrameworkServlet { throws Exception { WsdlDefinition definition = getWsdlDefinition(httpServletRequest); if (definition != null) { - wsdlDefinitionHandlerAdapter.handle(httpServletRequest, httpServletResponse, definition); + this.wsdlDefinitionHandlerAdapter.handle(httpServletRequest, httpServletResponse, definition); } else { - messageReceiverHandlerAdapter.handle(httpServletRequest, httpServletResponse, messageReceiver); + this.messageReceiverHandlerAdapter.handle(httpServletRequest, httpServletResponse, this.messageReceiver); } } /** - * Determines the WsdlDefinition for a given request, or null if none is found. + * Determines the {@link WsdlDefinition} for a given request, or null + * if none is found. *

- * Default implementation checks whether the request method is GET, whether the request uri ends with ".wsdl", and - * if there is a WsdlDefinition with the same name as the filename in the request uri. - * + * Default implementation checks whether the request method is GET, + * whether the request uri ends with ".wsdl", and if there is a + * WsdlDefinition with the same name as the filename in the request uri. * @param request the HttpServletRequest * @return a definition, or null */ protected WsdlDefinition getWsdlDefinition(HttpServletRequest request) { if ("GET".equals(request.getMethod()) && request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) { String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI()); - return (WsdlDefinition) wsdlDefinitions.get(fileName); + return (WsdlDefinition) this.wsdlDefinitions.get(fileName); } else { return null; @@ -146,13 +170,13 @@ public class MessageDispatcherServlet extends FrameworkServlet { private void initHandlerAdapters() throws BeansException { try { // setup the receiver adapter - messageReceiverHandlerAdapter = new WebServiceMessageReceiverHandlerAdapter(); + this.messageReceiverHandlerAdapter = new WebServiceMessageReceiverHandlerAdapter(); initWebServiceMessageFactory(); - messageReceiverHandlerAdapter.afterPropertiesSet(); + this.messageReceiverHandlerAdapter.afterPropertiesSet(); // setup the wsdl adapter - wsdlDefinitionHandlerAdapter = new WsdlDefinitionHandlerAdapter(); - wsdlDefinitionHandlerAdapter.setTransformLocations(transformWsdlLocations); - wsdlDefinitionHandlerAdapter.afterPropertiesSet(); + this.wsdlDefinitionHandlerAdapter = new WsdlDefinitionHandlerAdapter(); + this.wsdlDefinitionHandlerAdapter.setTransformLocations(this.transformWsdlLocations); + this.wsdlDefinitionHandlerAdapter.afterPropertiesSet(); } catch (Exception ex) { throw new BeanInitializationException("Could not initialize handler adapters", ex); @@ -166,40 +190,43 @@ public class MessageDispatcherServlet extends FrameworkServlet { .getBean(WEB_SERVICE_MESSAGE_FACTORY_BEAN_NAME, WebServiceMessageFactory.class); } catch (NoSuchBeanDefinitionException ignored) { - messageFactory = (WebServiceMessageFactory) defaultStrategiesHelper + messageFactory = (WebServiceMessageFactory) this.defaultStrategiesHelper .getDefaultStrategy(WebServiceMessageFactory.class, getWebApplicationContext()); - if (logger.isInfoEnabled()) { - logger.info("Unable to locate WebServiceMessageFactory with name '" + + if (this.logger.isInfoEnabled()) { + this.logger.info("Unable to locate WebServiceMessageFactory with name '" + WEB_SERVICE_MESSAGE_FACTORY_BEAN_NAME + "': using default [" + messageFactory + "]"); } if (messageFactory instanceof InitializingBean) { ((InitializingBean) messageFactory).afterPropertiesSet(); } } - messageReceiverHandlerAdapter.setMessageFactory(messageFactory); + this.messageReceiverHandlerAdapter.setMessageFactory(messageFactory); } private void initMessageReceiver() { try { - messageReceiver = (WebServiceMessageReceiver) getWebApplicationContext() + this.messageReceiver = (WebServiceMessageReceiver) getWebApplicationContext() .getBean(MESSAGE_RECEIVER_BEAN_NAME, WebServiceMessageReceiver.class); } catch (NoSuchBeanDefinitionException ex) { - messageReceiver = (WebServiceMessageReceiver) defaultStrategiesHelper + this.messageReceiver = (WebServiceMessageReceiver) this.defaultStrategiesHelper .getDefaultStrategy(WebServiceMessageReceiver.class, getWebApplicationContext()); - if (messageReceiver instanceof BeanNameAware) { - ((BeanNameAware) messageReceiver).setBeanName(getServletName()); + if (this.messageReceiver instanceof BeanNameAware) { + ((BeanNameAware) this.messageReceiver).setBeanName(getServletName()); } - if (logger.isInfoEnabled()) { - logger.info("Unable to locate MessageDispatcher with name '" + MESSAGE_RECEIVER_BEAN_NAME + - "': using default [" + messageReceiver + "]"); + if (this.logger.isInfoEnabled()) { + this.logger.info("Unable to locate MessageDispatcher with name '" + MESSAGE_RECEIVER_BEAN_NAME + + "': using default [" + this.messageReceiver + "]"); } } } + /** + * Find all {@link WsdlDefinition WsdlDefinitions} in the ApplicationContext, + * incuding ancestor contexts. + */ private void initWsdlDefinitions() { - // Find all WsdlDefinitions in the ApplicationContext, incuding ancestor contexts. - wsdlDefinitions = BeanFactoryUtils + this.wsdlDefinitions = BeanFactoryUtils .beansOfTypeIncludingAncestors(getWebApplicationContext(), WsdlDefinition.class, true, false); } }