Polishing

This commit is contained in:
Juergen Hoeller
2014-10-22 01:10:01 +02:00
parent 0e907764a4
commit 15c8987cc4
15 changed files with 154 additions and 176 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -26,23 +26,24 @@ import org.springframework.util.Assert;
import org.springframework.web.context.ServletContextAware;
/**
* A FactoryBean for configuring {@link javax.websocket.server.ServerContainer}. Since
* there is only one {@code ServerContainer} instance accessible under a well-known
* {@code javax.servlet.ServletContext} attribute, simply declaring this FactoryBean and
* using its setters allows configuring the {@code ServerContainer} through Spring
* configuration.
* A {@link FactoryBean} for configuring {@link javax.websocket.server.ServerContainer}.
* Since there is usually only one {@code ServerContainer} instance accessible under a
* well-known {@code javax.servlet.ServletContext} attribute, simply declaring this
* FactoryBean and using its setters allows for configuring the {@code ServerContainer}
* through Spring configuration.
*
* <p>This is useful even if the {@code ServerContainer} is not injected into any other
* bean. For example, an application can configure a {@link org.springframework.web.socket.server.support.DefaultHandshakeHandler}, a
* {@link org.springframework.web.socket.sockjs.SockJsService}, or {@link ServerEndpointExporter},
* and separately declare this FactoryBean in order to customize the properties of the
* (one and only) {@code ServerContainer} instance.
* bean within the Spring application context. For example, an application can configure
* a {@link org.springframework.web.socket.server.support.DefaultHandshakeHandler},
* a {@link org.springframework.web.socket.sockjs.SockJsService}, or
* {@link ServerEndpointExporter}, and separately declare this FactoryBean in order
* to customize the properties of the (one and only) {@code ServerContainer} instance.
*
* @author Rossen Stoyanchev
* @since 4.0
*/
public class ServletServerContainerFactoryBean
implements FactoryBean<WebSocketContainer>, InitializingBean, ServletContextAware {
implements FactoryBean<WebSocketContainer>, ServletContextAware, InitializingBean {
private Long asyncSendTimeout;
@@ -120,7 +121,7 @@ public class ServletServerContainerFactoryBean
@Override
public Class<?> getObjectType() {
return ServerContainer.class;
return (this.serverContainer != null ? this.serverContainer.getClass() : ServerContainer.class);
}
@Override

View File

@@ -5,7 +5,7 @@
* 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
* 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,
@@ -16,6 +16,7 @@
package org.springframework.web.socket.server.standard;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.server.ServerEndpoint;
@@ -114,7 +115,7 @@ public class SpringConfigurator extends Configurator {
beanNamesByType.put(endpointClass, NO_VALUE);
if (names.length > 1) {
throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
endpointClass.getName() + "]: bean names " + names);
endpointClass.getName() + "]: bean names " + Arrays.asList(names));
}
}
}