001/*
002 * Copyright 2012-2014 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 *      http://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.boot.autoconfigure.websocket;
018
019import org.eclipse.jetty.util.thread.ShutdownThread;
020import org.eclipse.jetty.webapp.AbstractConfiguration;
021import org.eclipse.jetty.webapp.WebAppContext;
022import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
023import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
024
025import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
026
027/**
028 * {@link WebSocketContainerCustomizer} for {@link JettyEmbeddedServletContainerFactory}.
029 *
030 * @author Dave Syer
031 * @author Phillip Webb
032 * @author Andy Wilkinson
033 * @since 1.2.0
034 */
035public class JettyWebSocketContainerCustomizer
036                extends WebSocketContainerCustomizer<JettyEmbeddedServletContainerFactory> {
037
038        @Override
039        protected void doCustomize(JettyEmbeddedServletContainerFactory container) {
040                container.addConfigurations(new AbstractConfiguration() {
041
042                        @Override
043                        public void configure(WebAppContext context) throws Exception {
044                                ServerContainer serverContainer = WebSocketServerContainerInitializer
045                                                .configureContext(context);
046                                ShutdownThread.deregister(serverContainer);
047                        }
048
049                });
050        }
051
052}