Browse Source

Polishing

pull/1714/head
Juergen Hoeller 8 years ago
parent
commit
cec7204fca
  1. 9
      spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java
  2. 75
      spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java

9
spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java

@ -1176,7 +1176,6 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
} }
@Deprecated @Deprecated
@SuppressWarnings({"rawtypes", "deprecation"}) @SuppressWarnings({"rawtypes", "deprecation"})
private static org.hibernate.Query queryObject(@Nullable Object result) { private static org.hibernate.Query queryObject(@Nullable Object result) {
@ -1228,12 +1227,12 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
// If return value is a Query or Criteria, apply transaction timeout. // If return value is a Query or Criteria, apply transaction timeout.
// Applies to createQuery, getNamedQuery, createCriteria. // Applies to createQuery, getNamedQuery, createCriteria.
if (retVal instanceof org.hibernate.Query) { if (retVal instanceof Criteria) {
prepareQuery(((org.hibernate.Query) retVal));
}
else if (retVal instanceof Criteria) {
prepareCriteria(((Criteria) retVal)); prepareCriteria(((Criteria) retVal));
} }
else if (retVal instanceof org.hibernate.Query) {
prepareQuery(((org.hibernate.Query) retVal));
}
return retVal; return retVal;
} }

75
spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ import org.springframework.web.socket.handler.BeanCreatingHandlerProvider;
/** /**
* An implementation of {@link javax.websocket.server.ServerEndpointConfig} for use in * An implementation of {@link javax.websocket.server.ServerEndpointConfig} for use in
* Spring applications. A {@link ServerEndpointRegistration} bean is detected by * Spring-based applications. A {@link ServerEndpointRegistration} bean is detected by
* {@link ServerEndpointExporter} and registered with a Java WebSocket runtime at startup. * {@link ServerEndpointExporter} and registered with a Java WebSocket runtime at startup.
* *
* <p>Class constructors accept a singleton {@link javax.websocket.Endpoint} instance * <p>Class constructors accept a singleton {@link javax.websocket.Endpoint} instance
@ -45,11 +45,12 @@ import org.springframework.web.socket.handler.BeanCreatingHandlerProvider;
* each client WebSocket connection. * each client WebSocket connection.
* *
* <p>This class also extends * <p>This class also extends
* {@link javax.websocket.server.ServerEndpointConfig.Configurator} to make it easier to * {@link javax.websocket.server.ServerEndpointConfig.Configurator} to make it easier
* override methods for customizing the handshake process. * to override methods for customizing the handshake process.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0 * @author Juergen Hoeller
* @since 4.0
* @see ServerEndpointExporter * @see ServerEndpointExporter
*/ */
public class ServerEndpointRegistration extends ServerEndpointConfig.Configurator public class ServerEndpointRegistration extends ServerEndpointConfig.Configurator
@ -63,15 +64,15 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
@Nullable @Nullable
private final BeanCreatingHandlerProvider<Endpoint> endpointProvider; private final BeanCreatingHandlerProvider<Endpoint> endpointProvider;
private List<Class<? extends Encoder>> encoders = new ArrayList<>(); private List<String> subprotocols = new ArrayList<>(0);
private List<Class<? extends Decoder>> decoders = new ArrayList<>(); private List<Extension> extensions = new ArrayList<>(0);
private List<String> protocols = new ArrayList<>(); private List<Class<? extends Encoder>> encoders = new ArrayList<>(0);
private List<Extension> extensions = new ArrayList<>(); private List<Class<? extends Decoder>> decoders = new ArrayList<>(0);
private final Map<String, Object> userProperties = new HashMap<>(); private final Map<String, Object> userProperties = new HashMap<>(4);
/** /**
@ -81,8 +82,8 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
* @param endpoint the endpoint instance * @param endpoint the endpoint instance
*/ */
public ServerEndpointRegistration(String path, Endpoint endpoint) { public ServerEndpointRegistration(String path, Endpoint endpoint) {
Assert.hasText(path, "path must not be empty"); Assert.hasText(path, "Path must not be empty");
Assert.notNull(endpoint, "endpoint must not be null"); Assert.notNull(endpoint, "Endpoint must not be null");
this.path = path; this.path = path;
this.endpoint = endpoint; this.endpoint = endpoint;
this.endpointProvider = null; this.endpointProvider = null;
@ -95,14 +96,16 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
* @param endpointClass the endpoint class * @param endpointClass the endpoint class
*/ */
public ServerEndpointRegistration(String path, Class<? extends Endpoint> endpointClass) { public ServerEndpointRegistration(String path, Class<? extends Endpoint> endpointClass) {
Assert.hasText(path, "path must not be empty"); Assert.hasText(path, "Path must not be empty");
Assert.notNull(endpointClass, "endpointClass must not be null"); Assert.notNull(endpointClass, "Endpoint Class must not be null");
this.path = path; this.path = path;
this.endpoint = null; this.endpoint = null;
this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass); this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass);
} }
// ServerEndpointConfig implementation
@Override @Override
public String getPath() { public String getPath() {
return this.path; return this.path;
@ -129,13 +132,13 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
} }
} }
public void setSubprotocols(List<String> protocols) { public void setSubprotocols(List<String> subprotocols) {
this.protocols = protocols; this.subprotocols = subprotocols;
} }
@Override @Override
public List<String> getSubprotocols() { public List<String> getSubprotocols() {
return this.protocols; return this.subprotocols;
} }
public void setExtensions(List<Extension> extensions) { public void setExtensions(List<Extension> extensions) {
@ -147,16 +150,6 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
return this.extensions; return this.extensions;
} }
public void setUserProperties(Map<String, Object> userProperties) {
this.userProperties.clear();
this.userProperties.putAll(userProperties);
}
@Override
public Map<String, Object> getUserProperties() {
return this.userProperties;
}
public void setEncoders(List<Class<? extends Encoder>> encoders) { public void setEncoders(List<Class<? extends Encoder>> encoders) {
this.encoders = encoders; this.encoders = encoders;
} }
@ -175,20 +168,23 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
return this.decoders; return this.decoders;
} }
public void setUserProperties(Map<String, Object> userProperties) {
this.userProperties.clear();
this.userProperties.putAll(userProperties);
}
@Override @Override
public Configurator getConfigurator() { public Map<String, Object> getUserProperties() {
return this; return this.userProperties;
} }
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) { public Configurator getConfigurator() {
if (this.endpointProvider != null) { return this;
this.endpointProvider.setBeanFactory(beanFactory);
}
} }
// Implementations of ServerEndpointConfig.Configurator // ServerEndpointConfig.Configurator implementation
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@ -201,8 +197,19 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
super.modifyHandshake(this, request, response); super.modifyHandshake(this, request, response);
} }
// Remaining methods
@Override
public void setBeanFactory(BeanFactory beanFactory) {
if (this.endpointProvider != null) {
this.endpointProvider.setBeanFactory(beanFactory);
}
}
@Override @Override
public String toString() { public String toString() {
return "ServerEndpointRegistration for path '" + getPath() + "': " + getEndpointClass(); return "ServerEndpointRegistration for path '" + getPath() + "': " + getEndpointClass();
} }
} }

Loading…
Cancel
Save