001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.socket.server.support;
018
019import javax.servlet.ServletContext;
020
021import org.springframework.web.context.ServletContextAware;
022import org.springframework.web.socket.server.RequestUpgradeStrategy;
023
024/**
025 * A default {@link org.springframework.web.socket.server.HandshakeHandler} implementation,
026 * extending {@link AbstractHandshakeHandler} with Servlet-specific initialization support.
027 * See {@link AbstractHandshakeHandler}'s javadoc for details on supported servers etc.
028 *
029 * @author Rossen Stoyanchev
030 * @author Juergen Hoeller
031 * @since 4.0
032 */
033public class DefaultHandshakeHandler extends AbstractHandshakeHandler implements ServletContextAware {
034
035        public DefaultHandshakeHandler() {
036        }
037
038        public DefaultHandshakeHandler(RequestUpgradeStrategy requestUpgradeStrategy) {
039                super(requestUpgradeStrategy);
040        }
041
042
043        @Override
044        public void setServletContext(ServletContext servletContext) {
045                RequestUpgradeStrategy strategy = getRequestUpgradeStrategy();
046                if (strategy instanceof ServletContextAware) {
047                        ((ServletContextAware) strategy).setServletContext(servletContext);
048                }
049        }
050
051}