Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -23,27 +23,27 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
|
||||
/**
|
||||
* XStream {@link Converter} that supports all classes but throws exceptions
|
||||
* for (un)marshalling.
|
||||
* XStream {@link Converter} that supports all classes, but throws exceptions for
|
||||
* (un)marshalling.
|
||||
*
|
||||
* <p>Main purpose of this class is to
|
||||
* {@linkplain com.thoughtworks.xstream.XStream#registerConverter(Converter, int) register}
|
||||
* this converter as a catch-all converter with a
|
||||
* <p>The main purpose of this class is to
|
||||
* {@linkplain com.thoughtworks.xstream.XStream#registerConverter(com.thoughtworks.xstream.converters.Converter, int) register}
|
||||
* this converter as a catch-all last converter with a
|
||||
* {@linkplain com.thoughtworks.xstream.XStream#PRIORITY_NORMAL normal}
|
||||
* or higher priority, in addition to converters that explicitly support the domain
|
||||
* classes that should be supported. As a result, default XStream converters with lower
|
||||
* priorities and possible security vulnerabilities do not get invoked.
|
||||
* or higher priority, in addition to converters that explicitly handle the domain
|
||||
* classes that should be supported. As a result, default XStream converters with
|
||||
* lower priorities and possible security vulnerabilities do not get invoked.
|
||||
*
|
||||
* <p>For instance:</p>
|
||||
* <p>For instance:
|
||||
* <pre class="code">
|
||||
* XStreamMarshaller unmarshaller = new XStreamMarshaller();
|
||||
* unmarshaller.getXStream().registerConverter(new MyDomainClassConverter(), XStream.PRIORITY_VERY_HIGH);
|
||||
* unmarshaller.getXStream().registerConverter(new CatchAllConverter(), XStream.PRIORITY_NORMAL);
|
||||
* MyDomainClass o = unmarshaller.unmarshal(source);
|
||||
* MyDomainClass myObject = unmarshaller.unmarshal(source);
|
||||
* </pre
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @since 3.2.5
|
||||
*/
|
||||
public class CatchAllConverter implements Converter {
|
||||
|
||||
|
||||
@@ -42,15 +42,13 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(NativeWebSocketSession.class);
|
||||
|
||||
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
|
||||
|
||||
private T nativeSession;
|
||||
|
||||
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance and associate the given attributes with it.
|
||||
*
|
||||
* @param attributes attributes from the HTTP handshake to associate with the WebSocket
|
||||
* session; the provided attributes are copied, the original map is not used.
|
||||
*/
|
||||
@@ -83,7 +81,7 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
|
||||
}
|
||||
|
||||
public void initializeNativeSession(T session) {
|
||||
Assert.notNull(session, "session must not be null");
|
||||
Assert.notNull(session, "WebSocket session must not be null");
|
||||
this.nativeSession = session;
|
||||
}
|
||||
|
||||
@@ -125,6 +123,7 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
|
||||
|
||||
protected abstract void sendPongMessage(PongMessage message) throws IOException;
|
||||
|
||||
|
||||
@Override
|
||||
public final void close() throws IOException {
|
||||
close(CloseStatus.NORMAL);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -62,7 +62,6 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
|
||||
|
||||
/**
|
||||
* Create a new {@link JettyWebSocketSession} instance.
|
||||
*
|
||||
* @param attributes attributes from the HTTP handshake to associate with the WebSocket session
|
||||
*/
|
||||
public JettyWebSocketSession(Map<String, Object> attributes) {
|
||||
@@ -71,11 +70,10 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
|
||||
|
||||
/**
|
||||
* Create a new {@link JettyWebSocketSession} instance associated with the given user.
|
||||
*
|
||||
* @param attributes attributes from the HTTP handshake to associate with the WebSocket
|
||||
* session; the provided attributes are copied, the original map is not used.
|
||||
* @param user the user associated with the session; if {@code null} we'll fallback on the user
|
||||
* available via {@link org.eclipse.jetty.websocket.api.Session#getUpgradeRequest()}
|
||||
* @param user the user associated with the session; if {@code null} we'll fallback on the
|
||||
* user available via {@link org.eclipse.jetty.websocket.api.Session#getUpgradeRequest()}
|
||||
*/
|
||||
public JettyWebSocketSession(Map<String, Object> attributes, Principal user) {
|
||||
super(attributes);
|
||||
@@ -156,9 +154,10 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return ((getNativeSession() != null) && getNativeSession().isOpen());
|
||||
return (getNativeSession() != null && getNativeSession().isOpen());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initializeNativeSession(Session session) {
|
||||
super.initializeNativeSession(session);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -22,7 +22,6 @@ import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -75,12 +74,12 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
|
||||
|
||||
private final WebSocketServerFactory factory;
|
||||
|
||||
private volatile List<WebSocketExtension> supportedExtensions;
|
||||
|
||||
private ServletContext servletContext;
|
||||
|
||||
private volatile boolean running = false;
|
||||
|
||||
private volatile List<WebSocketExtension> supportedExtensions;
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor that creates {@link WebSocketServerFactory} through
|
||||
@@ -215,16 +214,18 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
|
||||
|
||||
private final List<ExtensionConfig> extensionConfigs;
|
||||
|
||||
public WebSocketHandlerContainer(JettyWebSocketHandlerAdapter handler, String protocol, List<WebSocketExtension> extensions) {
|
||||
public WebSocketHandlerContainer(
|
||||
JettyWebSocketHandlerAdapter handler, String protocol, List<WebSocketExtension> extensions) {
|
||||
|
||||
this.handler = handler;
|
||||
this.selectedProtocol = protocol;
|
||||
if (CollectionUtils.isEmpty(extensions)) {
|
||||
this.extensionConfigs = null;
|
||||
}
|
||||
else {
|
||||
this.extensionConfigs = new ArrayList<ExtensionConfig>();
|
||||
for (WebSocketExtension e : extensions) {
|
||||
this.extensionConfigs.add(new WebSocketToJettyExtensionConfigAdapter(e));
|
||||
this.extensionConfigs = new ArrayList<ExtensionConfig>(extensions.size());
|
||||
for (WebSocketExtension extension : extensions) {
|
||||
this.extensionConfigs.add(new WebSocketToJettyExtensionConfigAdapter(extension));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user