Polishing
This commit is contained in:
		
							parent
							
								
									a4b6682c3e
								
							
						
					
					
						commit
						59a24b406a
					
				| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			@ -31,14 +31,16 @@ public abstract class AbstractCacheInvoker {
 | 
			
		|||
 | 
			
		||||
	private CacheErrorHandler errorHandler;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	protected AbstractCacheInvoker() {
 | 
			
		||||
		this(new SimpleCacheErrorHandler());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected AbstractCacheInvoker(CacheErrorHandler errorHandler) {
 | 
			
		||||
		Assert.notNull("ErrorHandler must not be null");
 | 
			
		||||
		this.errorHandler = errorHandler;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected AbstractCacheInvoker() {
 | 
			
		||||
		 this(new SimpleCacheErrorHandler());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Set the {@link CacheErrorHandler} instance to use to handle errors
 | 
			
		||||
| 
						 | 
				
			
			@ -56,6 +58,7 @@ public abstract class AbstractCacheInvoker {
 | 
			
		|||
		return this.errorHandler;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Execute {@link Cache#get(Object)} on the specified {@link Cache} and
 | 
			
		||||
	 * invoke the error handler if an exception occurs. Return {@code null}
 | 
			
		||||
| 
						 | 
				
			
			@ -67,9 +70,9 @@ public abstract class AbstractCacheInvoker {
 | 
			
		|||
		try {
 | 
			
		||||
			return cache.get(key);
 | 
			
		||||
		}
 | 
			
		||||
		catch (RuntimeException e) {
 | 
			
		||||
			getErrorHandler().handleCacheGetError(e, cache, key);
 | 
			
		||||
			return null; // If the exception is handled, return a cache miss
 | 
			
		||||
		catch (RuntimeException ex) {
 | 
			
		||||
			getErrorHandler().handleCacheGetError(ex, cache, key);
 | 
			
		||||
			return null;  // If the exception is handled, return a cache miss
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -81,8 +84,8 @@ public abstract class AbstractCacheInvoker {
 | 
			
		|||
		try {
 | 
			
		||||
			cache.put(key, result);
 | 
			
		||||
		}
 | 
			
		||||
		catch (RuntimeException e) {
 | 
			
		||||
			getErrorHandler().handleCachePutError(e, cache, key, result);
 | 
			
		||||
		catch (RuntimeException ex) {
 | 
			
		||||
			getErrorHandler().handleCachePutError(ex, cache, key, result);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -94,8 +97,8 @@ public abstract class AbstractCacheInvoker {
 | 
			
		|||
		try {
 | 
			
		||||
			cache.evict(key);
 | 
			
		||||
		}
 | 
			
		||||
		catch (RuntimeException e) {
 | 
			
		||||
			getErrorHandler().handleCacheEvictError(e, cache, key);
 | 
			
		||||
		catch (RuntimeException ex) {
 | 
			
		||||
			getErrorHandler().handleCacheEvictError(ex, cache, key);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -107,8 +110,8 @@ public abstract class AbstractCacheInvoker {
 | 
			
		|||
		try {
 | 
			
		||||
			cache.clear();
 | 
			
		||||
		}
 | 
			
		||||
		catch (RuntimeException e) {
 | 
			
		||||
			getErrorHandler().handleCacheClearError(e, cache);
 | 
			
		||||
		catch (RuntimeException ex) {
 | 
			
		||||
			getErrorHandler().handleCacheClearError(ex, cache);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -418,7 +418,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
 | 
			
		|||
					excluded.add(context);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (VariableNotAvailableException e) {
 | 
			
		||||
			catch (VariableNotAvailableException ex) {
 | 
			
		||||
				// Ignoring failure due to missing result, consider the cache put has to proceed
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,8 +70,8 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				try {
 | 
			
		||||
					jmsMessage.setJMSCorrelationID((String) jmsCorrelationId);
 | 
			
		||||
				}
 | 
			
		||||
				catch (Exception e) {
 | 
			
		||||
					logger.info("failed to set JMSCorrelationID, skipping", e);
 | 
			
		||||
				catch (Exception ex) {
 | 
			
		||||
					logger.info("Failed to set JMSCorrelationID - skipping", ex);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			Destination jmsReplyTo = getHeaderIfAvailable(headers, JmsHeaders.REPLY_TO, Destination.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -79,8 +79,8 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				try {
 | 
			
		||||
					jmsMessage.setJMSReplyTo(jmsReplyTo);
 | 
			
		||||
				}
 | 
			
		||||
				catch (Exception e) {
 | 
			
		||||
					logger.info("failed to set JMSReplyTo, skipping", e);
 | 
			
		||||
				catch (Exception ex) {
 | 
			
		||||
					logger.info("Failed to set JMSReplyTo - skipping", ex);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			String jmsType = getHeaderIfAvailable(headers, JmsHeaders.TYPE, String.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -88,8 +88,8 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				try {
 | 
			
		||||
					jmsMessage.setJMSType(jmsType);
 | 
			
		||||
				}
 | 
			
		||||
				catch (Exception e) {
 | 
			
		||||
					logger.info("failed to set JMSType, skipping", e);
 | 
			
		||||
				catch (Exception ex) {
 | 
			
		||||
					logger.info("Failed to set JMSType - skipping", ex);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			Set<String> headerNames = headers.keySet();
 | 
			
		||||
| 
						 | 
				
			
			@ -101,14 +101,15 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
							String propertyName = this.fromHeaderName(headerName);
 | 
			
		||||
							jmsMessage.setObjectProperty(propertyName, value);
 | 
			
		||||
						}
 | 
			
		||||
						catch (Exception e) {
 | 
			
		||||
						catch (Exception ex) {
 | 
			
		||||
							if (headerName.startsWith("JMSX")) {
 | 
			
		||||
								if (logger.isTraceEnabled()) {
 | 
			
		||||
									logger.trace("skipping reserved header, it cannot be set by client: " + headerName);
 | 
			
		||||
									logger.trace("Skipping reserved header '" + headerName +
 | 
			
		||||
											"' since it cannot be set by client");
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
							else if (logger.isWarnEnabled()) {
 | 
			
		||||
								logger.warn("failed to map Message header '" + headerName + "' to JMS property", e);
 | 
			
		||||
								logger.warn("Failed to map message header '" + headerName + "' to JMS property", ex);
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -117,7 +118,7 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
		}
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			if (logger.isWarnEnabled()) {
 | 
			
		||||
				logger.warn("error occurred while mapping from MessageHeaders to JMS properties", ex);
 | 
			
		||||
				logger.warn("Error occurred while mapping from MessageHeaders to JMS properties", ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -133,7 +134,7 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSCorrelationID property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSCorrelationID property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				Destination destination = jmsMessage.getJMSDestination();
 | 
			
		||||
| 
						 | 
				
			
			@ -142,21 +143,21 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSDestination property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSDestination property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				int deliveryMode = jmsMessage.getJMSDeliveryMode();
 | 
			
		||||
				headers.put(JmsHeaders.DELIVERY_MODE, deliveryMode);
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSDeliveryMode property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSDeliveryMode property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				long expiration = jmsMessage.getJMSExpiration();
 | 
			
		||||
				headers.put(JmsHeaders.EXPIRATION, expiration);
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSExpiration property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSExpiration property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				String messageId = jmsMessage.getJMSMessageID();
 | 
			
		||||
| 
						 | 
				
			
			@ -165,13 +166,13 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSMessageID property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSMessageID property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				headers.put(JmsHeaders.PRIORITY, jmsMessage.getJMSPriority());
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSPriority property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSPriority property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				Destination replyTo = jmsMessage.getJMSReplyTo();
 | 
			
		||||
| 
						 | 
				
			
			@ -180,13 +181,13 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSReplyTo property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSReplyTo property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				headers.put(JmsHeaders.REDELIVERED, jmsMessage.getJMSRedelivered());
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSRedelivered property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSRedelivered property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				String type = jmsMessage.getJMSType();
 | 
			
		||||
| 
						 | 
				
			
			@ -195,13 +196,13 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSType property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSType property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				headers.put(JmsHeaders.TIMESTAMP, jmsMessage.getJMSTimestamp());
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				logger.info("failed to read JMSTimestamp property, skipping", ex);
 | 
			
		||||
				logger.info("Failed to read JMSTimestamp property - skipping", ex);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			@ -98,13 +98,13 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
 | 
			
		|||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
 | 
			
		||||
		super.setDestinationResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
 | 
			
		||||
		setDestinationResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected final void doSend(MessageChannel channel, Message<?> message) {
 | 
			
		||||
		Assert.notNull(channel, "'channel' is required");
 | 
			
		||||
		Assert.notNull(channel, "MessageChannel is required");
 | 
			
		||||
 | 
			
		||||
		MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
 | 
			
		||||
		if (accessor != null && accessor.isMutable()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -116,13 +116,13 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
 | 
			
		|||
 | 
			
		||||
		if (!sent) {
 | 
			
		||||
			throw new MessageDeliveryException(message,
 | 
			
		||||
					"failed to send message to channel '" + channel + "' within timeout: " + timeout);
 | 
			
		||||
					"Failed to send message to channel '" + channel + "' within timeout: " + timeout);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	protected final Message<?> doReceive(MessageChannel channel) {
 | 
			
		||||
		Assert.notNull(channel, "'channel' is required");
 | 
			
		||||
		Assert.notNull(channel, "MessageChannel is required");
 | 
			
		||||
		Assert.state(channel instanceof PollableChannel, "A PollableChannel is required to receive messages");
 | 
			
		||||
 | 
			
		||||
		long timeout = this.receiveTimeout;
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +208,7 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
 | 
			
		|||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (InterruptedException e) {
 | 
			
		||||
			catch (InterruptedException ex) {
 | 
			
		||||
				Thread.currentThread().interrupt();
 | 
			
		||||
			}
 | 
			
		||||
			return this.replyMessage;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
		try {
 | 
			
		||||
			host = InetAddress.getLocalHost().getHostAddress();
 | 
			
		||||
		}
 | 
			
		||||
		catch (UnknownHostException e) {
 | 
			
		||||
		catch (UnknownHostException ex) {
 | 
			
		||||
			host = "unknown";
 | 
			
		||||
		}
 | 
			
		||||
		return host + "-" + UUID.randomUUID();
 | 
			
		||||
| 
						 | 
				
			
			@ -87,6 +87,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
				((SmartApplicationListener) this.localRegistry).getOrder() : Ordered.LOWEST_PRECEDENCE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// SmartApplicationListener methods
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
| 
						 | 
				
			
			@ -108,6 +109,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// SimpUserRegistry methods
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
| 
						 | 
				
			
			@ -143,6 +145,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
		return result;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// Internal methods for UserRegistryMessageHandler to manage broadcasts
 | 
			
		||||
 | 
			
		||||
	Object getLocalRegistryDto() {
 | 
			
		||||
| 
						 | 
				
			
			@ -179,7 +182,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
	 * Holds a copy of a SimpUserRegistry for the purpose of broadcasting to and
 | 
			
		||||
	 * receiving broadcasts from other application servers.
 | 
			
		||||
	 */
 | 
			
		||||
	@SuppressWarnings("unused")
 | 
			
		||||
	private static class UserRegistrySnapshot {
 | 
			
		||||
 | 
			
		||||
		private String id;
 | 
			
		||||
| 
						 | 
				
			
			@ -188,10 +190,10 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
 | 
			
		||||
		private long expirationTime;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Default constructor for JSON deserialization.
 | 
			
		||||
		 */
 | 
			
		||||
		@SuppressWarnings("unused")
 | 
			
		||||
		public UserRegistrySnapshot() {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +209,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		public void setId(String id) {
 | 
			
		||||
			this.id = id;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +229,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
			return (now > this.expirationTime);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		public void init(long expirationPeriod, SessionLookup sessionLookup) {
 | 
			
		||||
			this.expirationTime = System.currentTimeMillis() + expirationPeriod;
 | 
			
		||||
			for (TransferSimpUser user : this.users.values()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +236,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) {
 | 
			
		||||
			Set<SimpSubscription> result = new HashSet<>();
 | 
			
		||||
			for (TransferSimpUser user : this.users.values()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -251,12 +250,10 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
			return result;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
		public String toString() {
 | 
			
		||||
			return "id=" + this.id + ", users=" + this.users;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -274,7 +271,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
		/* Cross-server session lookup (e.g. user connected to multiple servers) */
 | 
			
		||||
		private SessionLookup sessionLookup;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Default constructor for JSON deserialization.
 | 
			
		||||
		 */
 | 
			
		||||
| 
						 | 
				
			
			@ -294,7 +290,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		public void setName(String name) {
 | 
			
		||||
			this.name = name;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -369,6 +364,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * SimpSession that can be (de)serialized and broadcast to other servers.
 | 
			
		||||
	 */
 | 
			
		||||
| 
						 | 
				
			
			@ -381,7 +377,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
 | 
			
		||||
		private final Set<TransferSimpSubscription> subscriptions;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Default constructor for JSON deserialization.
 | 
			
		||||
		 */
 | 
			
		||||
| 
						 | 
				
			
			@ -450,10 +445,10 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * SimpSubscription that can be (de)serialized and broadcast to other servers.
 | 
			
		||||
	 */
 | 
			
		||||
	@SuppressWarnings("unused")
 | 
			
		||||
	private static class TransferSimpSubscription implements SimpSubscription {
 | 
			
		||||
 | 
			
		||||
		private String id;
 | 
			
		||||
| 
						 | 
				
			
			@ -462,10 +457,10 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
 | 
			
		||||
		private String destination;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Default constructor for JSON deserialization.
 | 
			
		||||
		 */
 | 
			
		||||
		@SuppressWarnings("unused")
 | 
			
		||||
		public TransferSimpSubscription() {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -477,7 +472,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
 | 
			
		|||
			this.destination = subscription.getDestination();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		public void setId(String id) {
 | 
			
		||||
			this.id = id;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -941,7 +941,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
 | 
			
		|||
			try {
 | 
			
		||||
				contentId = URLEncoder.encode(contentId, "UTF-8");
 | 
			
		||||
			}
 | 
			
		||||
			catch (UnsupportedEncodingException e) {
 | 
			
		||||
			catch (UnsupportedEncodingException ex) {
 | 
			
		||||
				// ignore
 | 
			
		||||
			}
 | 
			
		||||
			return CID + contentId;
 | 
			
		||||
| 
						 | 
				
			
			@ -952,7 +952,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
 | 
			
		|||
				URI uri = new URI(elementNamespace);
 | 
			
		||||
				return uri.getHost();
 | 
			
		||||
			}
 | 
			
		||||
			catch (URISyntaxException e) {
 | 
			
		||||
			catch (URISyntaxException ex) {
 | 
			
		||||
				// ignore
 | 
			
		||||
			}
 | 
			
		||||
			return dataHandler.getName();
 | 
			
		||||
| 
						 | 
				
			
			@ -998,7 +998,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
 | 
			
		|||
				try {
 | 
			
		||||
					contentId = URLDecoder.decode(contentId, "UTF-8");
 | 
			
		||||
				}
 | 
			
		||||
				catch (UnsupportedEncodingException e) {
 | 
			
		||||
				catch (UnsupportedEncodingException ex) {
 | 
			
		||||
					// ignore
 | 
			
		||||
				}
 | 
			
		||||
				contentId = '<' + contentId + '>';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,8 +112,8 @@ public class MockAsyncContext implements AsyncContext {
 | 
			
		|||
			try {
 | 
			
		||||
				listener.onComplete(new AsyncEvent(this, this.request, this.response));
 | 
			
		||||
			}
 | 
			
		||||
			catch (IOException e) {
 | 
			
		||||
				throw new IllegalStateException("AsyncListener failure", e);
 | 
			
		||||
			catch (IOException ex) {
 | 
			
		||||
				throw new IllegalStateException("AsyncListener failure", ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,6 @@ package org.springframework.test.context.jdbc;
 | 
			
		|||
import java.lang.reflect.Method;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import javax.sql.DataSource;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.logging.Log;
 | 
			
		||||
| 
						 | 
				
			
			@ -216,10 +215,10 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
 | 
			
		|||
			DataSource dataSourceFromTxMgr = getDataSourceFromTransactionManager(transactionManager);
 | 
			
		||||
 | 
			
		||||
			// Ensure user configured an appropriate DataSource/TransactionManager pair.
 | 
			
		||||
			if ((dataSource != null) && (dataSourceFromTxMgr != null) && !dataSource.equals(dataSourceFromTxMgr)) {
 | 
			
		||||
				throw new IllegalStateException(String.format("Failed to execute SQL scripts for test context %s: "
 | 
			
		||||
						+ "the configured DataSource [%s] (named '%s') is not the one associated "
 | 
			
		||||
						+ "with transaction manager [%s] (named '%s').", testContext, dataSource.getClass().getName(),
 | 
			
		||||
			if (dataSource != null && dataSourceFromTxMgr != null && !dataSource.equals(dataSourceFromTxMgr)) {
 | 
			
		||||
				throw new IllegalStateException(String.format("Failed to execute SQL scripts for test context %s: " +
 | 
			
		||||
						"the configured DataSource [%s] (named '%s') is not the one associated with " +
 | 
			
		||||
						"transaction manager [%s] (named '%s').", testContext, dataSource.getClass().getName(),
 | 
			
		||||
					dsName, transactionManager.getClass().getName(), tmName));
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -231,8 +230,8 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
 | 
			
		|||
			}
 | 
			
		||||
 | 
			
		||||
			final DataSource finalDataSource = dataSource;
 | 
			
		||||
			int propagation = newTxRequired ? TransactionDefinition.PROPAGATION_REQUIRES_NEW
 | 
			
		||||
					: TransactionDefinition.PROPAGATION_REQUIRED;
 | 
			
		||||
			int propagation = (newTxRequired ? TransactionDefinition.PROPAGATION_REQUIRES_NEW :
 | 
			
		||||
					TransactionDefinition.PROPAGATION_REQUIRED);
 | 
			
		||||
 | 
			
		||||
			TransactionAttribute transactionAttribute = TestContextTransactionUtils.createDelegatingTransactionAttribute(
 | 
			
		||||
				testContext, new DefaultTransactionAttribute(propagation));
 | 
			
		||||
| 
						 | 
				
			
			@ -252,8 +251,8 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
 | 
			
		|||
				return (DataSource) obj;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e) {
 | 
			
		||||
			/* ignore */
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			// ignore
 | 
			
		||||
		}
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -293,9 +292,9 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
 | 
			
		|||
			return prefixedResourcePath;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			String msg = String.format("Could not detect default SQL script for test %s [%s]: "
 | 
			
		||||
					+ "%s does not exist. Either declare statements or scripts via @Sql or make the "
 | 
			
		||||
					+ "default SQL script available.", elementType, elementName, classPathResource);
 | 
			
		||||
			String msg = String.format("Could not detect default SQL script for test %s [%s]: " +
 | 
			
		||||
					"%s does not exist. Either declare statements or scripts via @Sql or make the " +
 | 
			
		||||
					"default SQL script available.", elementType, elementName, classPathResource);
 | 
			
		||||
			logger.error(msg);
 | 
			
		||||
			throw new IllegalStateException(msg);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,18 +52,12 @@ abstract class ActiveProfilesUtils {
 | 
			
		|||
	private static final Log logger = LogFactory.getLog(ActiveProfilesUtils.class);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	private ActiveProfilesUtils() {
 | 
			
		||||
		/* no-op */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Resolve <em>active bean definition profiles</em> for the supplied {@link Class}.
 | 
			
		||||
	 *
 | 
			
		||||
	 * <p>Note that the {@link ActiveProfiles#inheritProfiles inheritProfiles} flag of
 | 
			
		||||
	 * {@link ActiveProfiles @ActiveProfiles} will be taken into consideration.
 | 
			
		||||
	 * Specifically, if the {@code inheritProfiles} flag is set to {@code true}, profiles
 | 
			
		||||
	 * defined in the test class will be merged with those defined in superclasses.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param testClass the class for which to resolve the active profiles (must not be
 | 
			
		||||
	 * {@code null})
 | 
			
		||||
	 * @return the set of active profiles for the specified class, including active
 | 
			
		||||
| 
						 | 
				
			
			@ -78,12 +72,12 @@ abstract class ActiveProfilesUtils {
 | 
			
		|||
		final List<String[]> profileArrays = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
		Class<ActiveProfiles> annotationType = ActiveProfiles.class;
 | 
			
		||||
		AnnotationDescriptor<ActiveProfiles> descriptor = MetaAnnotationUtils.findAnnotationDescriptor(testClass,
 | 
			
		||||
			annotationType);
 | 
			
		||||
		AnnotationDescriptor<ActiveProfiles> descriptor =
 | 
			
		||||
				MetaAnnotationUtils.findAnnotationDescriptor(testClass, annotationType);
 | 
			
		||||
		if (descriptor == null && logger.isDebugEnabled()) {
 | 
			
		||||
			logger.debug(String.format(
 | 
			
		||||
				"Could not find an 'annotation declaring class' for annotation type [%s] and class [%s]",
 | 
			
		||||
				annotationType.getName(), testClass.getName()));
 | 
			
		||||
					"Could not find an 'annotation declaring class' for annotation type [%s] and class [%s]",
 | 
			
		||||
					annotationType.getName(), testClass.getName()));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		while (descriptor != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -92,8 +86,8 @@ abstract class ActiveProfilesUtils {
 | 
			
		|||
			ActiveProfiles annotation = descriptor.synthesizeAnnotation();
 | 
			
		||||
 | 
			
		||||
			if (logger.isTraceEnabled()) {
 | 
			
		||||
				logger.trace(String.format("Retrieved @ActiveProfiles [%s] for declaring class [%s].", annotation,
 | 
			
		||||
					declaringClass.getName()));
 | 
			
		||||
				logger.trace(String.format("Retrieved @ActiveProfiles [%s] for declaring class [%s].",
 | 
			
		||||
						annotation, declaringClass.getName()));
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			Class<? extends ActiveProfilesResolver> resolverClass = annotation.resolver();
 | 
			
		||||
| 
						 | 
				
			
			@ -101,22 +95,22 @@ abstract class ActiveProfilesUtils {
 | 
			
		|||
				resolverClass = DefaultActiveProfilesResolver.class;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			ActiveProfilesResolver resolver = null;
 | 
			
		||||
			ActiveProfilesResolver resolver;
 | 
			
		||||
			try {
 | 
			
		||||
				resolver = BeanUtils.instantiateClass(resolverClass, ActiveProfilesResolver.class);
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception e) {
 | 
			
		||||
				String msg = String.format("Could not instantiate ActiveProfilesResolver of "
 | 
			
		||||
						+ "type [%s] for test class [%s].", resolverClass.getName(), rootDeclaringClass.getName());
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				String msg = String.format("Could not instantiate ActiveProfilesResolver of type [%s] " +
 | 
			
		||||
						"for test class [%s].", resolverClass.getName(), rootDeclaringClass.getName());
 | 
			
		||||
				logger.error(msg);
 | 
			
		||||
				throw new IllegalStateException(msg, e);
 | 
			
		||||
				throw new IllegalStateException(msg, ex);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			String[] profiles = resolver.resolve(rootDeclaringClass);
 | 
			
		||||
			if (profiles == null) {
 | 
			
		||||
				String msg = String.format(
 | 
			
		||||
					"ActiveProfilesResolver [%s] returned a null array of bean definition profiles.",
 | 
			
		||||
					resolverClass.getName());
 | 
			
		||||
						"ActiveProfilesResolver [%s] returned a null array of bean definition profiles.",
 | 
			
		||||
						resolverClass.getName());
 | 
			
		||||
				logger.error(msg);
 | 
			
		||||
				throw new IllegalStateException(msg);
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +118,7 @@ abstract class ActiveProfilesUtils {
 | 
			
		|||
			profileArrays.add(profiles);
 | 
			
		||||
 | 
			
		||||
			descriptor = (annotation.inheritProfiles() ? MetaAnnotationUtils.findAnnotationDescriptor(
 | 
			
		||||
				rootDeclaringClass.getSuperclass(), annotationType) : null);
 | 
			
		||||
					rootDeclaringClass.getSuperclass(), annotationType) : null);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Reverse the list so that we can traverse "down" the hierarchy.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,6 @@ public class AopTestUtils {
 | 
			
		|||
	 * {@linkplain AopUtils#isAopProxy proxy}, the target of the proxy will
 | 
			
		||||
	 * be returned; otherwise, the {@code candidate} will be returned
 | 
			
		||||
	 * <em>as is</em>.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param candidate the instance to check (potentially a Spring AOP proxy);
 | 
			
		||||
	 * never {@code null}
 | 
			
		||||
	 * @return the target object or the {@code candidate}; never {@code null}
 | 
			
		||||
| 
						 | 
				
			
			@ -58,8 +57,8 @@ public class AopTestUtils {
 | 
			
		|||
				return (T) ((Advised) candidate).getTargetSource().getTarget();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e) {
 | 
			
		||||
			throw new IllegalStateException("Failed to unwrap proxied object.", e);
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			throw new IllegalStateException("Failed to unwrap proxied object", ex);
 | 
			
		||||
		}
 | 
			
		||||
		return (T) candidate;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +71,6 @@ public class AopTestUtils {
 | 
			
		|||
	 * {@linkplain AopUtils#isAopProxy proxy}, the ultimate target of all
 | 
			
		||||
	 * nested proxies will be returned; otherwise, the {@code candidate}
 | 
			
		||||
	 * will be returned <em>as is</em>.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param candidate the instance to check (potentially a Spring AOP proxy);
 | 
			
		||||
	 * never {@code null}
 | 
			
		||||
	 * @return the ultimate target object or the {@code candidate}; never
 | 
			
		||||
| 
						 | 
				
			
			@ -89,8 +87,8 @@ public class AopTestUtils {
 | 
			
		|||
				return (T) getUltimateTargetObject(((Advised) candidate).getTargetSource().getTarget());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e) {
 | 
			
		||||
			throw new IllegalStateException("Failed to unwrap proxied object.", e);
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			throw new IllegalStateException("Failed to unwrap proxied object", ex);
 | 
			
		||||
		}
 | 
			
		||||
		return (T) candidate;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@
 | 
			
		|||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package org.springframework.test.web.client.match;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
| 
						 | 
				
			
			@ -192,8 +193,8 @@ public class XpathRequestMatchers {
 | 
			
		|||
				MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
 | 
			
		||||
				matchInternal(mockRequest);
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception e) {
 | 
			
		||||
				throw new AssertionError("Failed to parse XML request content: " + e.getMessage());
 | 
			
		||||
			catch (Exception ex) {
 | 
			
		||||
				throw new AssertionError("Failed to parse XML request content: " + ex.getMessage());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,7 +126,7 @@ final class MockWebResponseBuilder {
 | 
			
		|||
		result.setExpiryDate(expires);
 | 
			
		||||
		result.setPath(cookie.getPath());
 | 
			
		||||
		result.setSecure(cookie.getSecure());
 | 
			
		||||
		if(cookie.isHttpOnly()) {
 | 
			
		||||
		if (cookie.isHttpOnly()) {
 | 
			
		||||
			result.setAttribute("httponly", "true");
 | 
			
		||||
		}
 | 
			
		||||
		return new com.gargoylesoftware.htmlunit.util.Cookie(result);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,6 +27,7 @@ import org.springframework.core.io.InputStreamResource;
 | 
			
		|||
import org.springframework.core.io.Resource;
 | 
			
		||||
import org.springframework.core.io.support.ResourceRegion;
 | 
			
		||||
import org.springframework.util.Assert;
 | 
			
		||||
import org.springframework.util.CollectionUtils;
 | 
			
		||||
import org.springframework.util.ObjectUtils;
 | 
			
		||||
import org.springframework.util.StringUtils;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -170,11 +171,11 @@ public abstract class HttpRange {
 | 
			
		|||
	 * @return the list of regions for the given resource
 | 
			
		||||
	 */
 | 
			
		||||
	public static List<ResourceRegion> toResourceRegions(List<HttpRange> ranges, Resource resource) {
 | 
			
		||||
		if(ranges == null || ranges.size() == 0) {
 | 
			
		||||
		if (CollectionUtils.isEmpty(ranges)) {
 | 
			
		||||
			return Collections.emptyList();
 | 
			
		||||
		}
 | 
			
		||||
		List<ResourceRegion> regions = new ArrayList<>(ranges.size());
 | 
			
		||||
		for(HttpRange range : ranges) {
 | 
			
		||||
		for (HttpRange range : ranges) {
 | 
			
		||||
			regions.add(range.toResourceRegion(resource));
 | 
			
		||||
		}
 | 
			
		||||
		return regions;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,9 @@ final class SimpleClientHttpResponse extends AbstractClientHttpResponse {
 | 
			
		|||
				StreamUtils.drain(this.responseStream);
 | 
			
		||||
				this.responseStream.close();
 | 
			
		||||
			}
 | 
			
		||||
			catch (IOException e) { }
 | 
			
		||||
			catch (IOException ex) {
 | 
			
		||||
				// ignore
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ public class ResourceRegionHttpMessageConverter extends AbstractGenericHttpMessa
 | 
			
		|||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			Collection<ResourceRegion> regions = (Collection<ResourceRegion>) object;
 | 
			
		||||
			if(regions.size() == 1) {
 | 
			
		||||
			if (regions.size() == 1) {
 | 
			
		||||
				writeResourceRegion(regions.iterator().next(), outputMessage);
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,8 +126,8 @@ public class ServletServerHttpResponse extends AbstractListenerServerHttpRespons
 | 
			
		|||
		try {
 | 
			
		||||
			outputStream().setWriteListener(writeListener);
 | 
			
		||||
		}
 | 
			
		||||
		catch (IOException e) {
 | 
			
		||||
			throw new UncheckedIOException(e);
 | 
			
		||||
		catch (IOException ex) {
 | 
			
		||||
			throw new UncheckedIOException(ex);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,14 +47,13 @@ import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
 | 
			
		|||
 *
 | 
			
		||||
 * @author Rossen Stoyanchev
 | 
			
		||||
 * @since 3.1
 | 
			
		||||
 *
 | 
			
		||||
 * @see DefaultServletHandlerConfigurer
 | 
			
		||||
 */
 | 
			
		||||
public class ResourceHandlerRegistry {
 | 
			
		||||
 | 
			
		||||
	private final ServletContext servletContext;
 | 
			
		||||
 | 
			
		||||
	private final ApplicationContext appContext;
 | 
			
		||||
	private final ApplicationContext applicationContext;
 | 
			
		||||
 | 
			
		||||
	private final ContentNegotiationManager contentNegotiationManager;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,26 +68,30 @@ public class ResourceHandlerRegistry {
 | 
			
		|||
 | 
			
		||||
	public ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext,
 | 
			
		||||
			ContentNegotiationManager contentNegotiationManager) {
 | 
			
		||||
 | 
			
		||||
		Assert.notNull(applicationContext, "ApplicationContext is required");
 | 
			
		||||
		this.appContext = applicationContext;
 | 
			
		||||
		this.applicationContext = applicationContext;
 | 
			
		||||
		this.servletContext = servletContext;
 | 
			
		||||
		this.contentNegotiationManager = contentNegotiationManager;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Add a resource handler for serving static resources based on the specified URL path patterns.
 | 
			
		||||
	 * The handler will be invoked for every incoming request that matches to one of the specified path patterns.
 | 
			
		||||
	 * @return A {@link ResourceHandlerRegistration} to use to further configure the registered resource handler.
 | 
			
		||||
	 * Add a resource handler for serving static resources based on the specified URL path
 | 
			
		||||
	 * patterns. The handler will be invoked for every incoming request that matches to
 | 
			
		||||
	 * one of the specified path patterns.
 | 
			
		||||
	 * @return A {@link ResourceHandlerRegistration} to use to further configure the
 | 
			
		||||
	 * registered resource handler
 | 
			
		||||
	 */
 | 
			
		||||
	public ResourceHandlerRegistration addResourceHandler(String... pathPatterns) {
 | 
			
		||||
		ResourceHandlerRegistration registration = new ResourceHandlerRegistration(this.appContext, pathPatterns);
 | 
			
		||||
		ResourceHandlerRegistration registration =
 | 
			
		||||
				new ResourceHandlerRegistration(this.applicationContext, pathPatterns);
 | 
			
		||||
		this.registrations.add(registration);
 | 
			
		||||
		return registration;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Whether a resource handler has already been registered for the given pathPattern.
 | 
			
		||||
	 * Whether a resource handler has already been registered for the given path pattern.
 | 
			
		||||
	 */
 | 
			
		||||
	public boolean hasMappingForPattern(String pathPattern) {
 | 
			
		||||
		for (ResourceHandlerRegistration registration : this.registrations) {
 | 
			
		||||
| 
						 | 
				
			
			@ -100,8 +103,9 @@ public class ResourceHandlerRegistry {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Specify the order to use for resource handling relative to other {@link HandlerMapping}s configured in
 | 
			
		||||
	 * the Spring MVC application context. The default value used is {@code Integer.MAX_VALUE-1}.
 | 
			
		||||
	 * Specify the order to use for resource handling relative to other {@link HandlerMapping}s
 | 
			
		||||
	 * configured in the Spring MVC application context.
 | 
			
		||||
	 * <p>The default value used is {@code Integer.MAX_VALUE-1}.
 | 
			
		||||
	 */
 | 
			
		||||
	public ResourceHandlerRegistry setOrder(int order) {
 | 
			
		||||
		this.order = order;
 | 
			
		||||
| 
						 | 
				
			
			@ -109,10 +113,11 @@ public class ResourceHandlerRegistry {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Return a handler mapping with the mapped resource handlers; or {@code null} in case of no registrations.
 | 
			
		||||
	 * Return a handler mapping with the mapped resource handlers; or {@code null} in case
 | 
			
		||||
	 * of no registrations.
 | 
			
		||||
	 */
 | 
			
		||||
	protected AbstractHandlerMapping getHandlerMapping() {
 | 
			
		||||
		if (registrations.isEmpty()) {
 | 
			
		||||
		if (this.registrations.isEmpty()) {
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -121,13 +126,13 @@ public class ResourceHandlerRegistry {
 | 
			
		|||
			for (String pathPattern : registration.getPathPatterns()) {
 | 
			
		||||
				ResourceHttpRequestHandler handler = registration.getRequestHandler();
 | 
			
		||||
				handler.setServletContext(this.servletContext);
 | 
			
		||||
				handler.setApplicationContext(this.appContext);
 | 
			
		||||
				handler.setApplicationContext(this.applicationContext);
 | 
			
		||||
				handler.setContentNegotiationManager(this.contentNegotiationManager);
 | 
			
		||||
				try {
 | 
			
		||||
					handler.afterPropertiesSet();
 | 
			
		||||
				}
 | 
			
		||||
				catch (Exception e) {
 | 
			
		||||
					throw new BeanInitializationException("Failed to init ResourceHttpRequestHandler", e);
 | 
			
		||||
				catch (Exception ex) {
 | 
			
		||||
					throw new BeanInitializationException("Failed to init ResourceHttpRequestHandler", ex);
 | 
			
		||||
				}
 | 
			
		||||
				urlMap.put(pathPattern, handler);
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -275,7 +275,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
 | 
			
		|||
		if (this.resourceHttpMessageConverter == null) {
 | 
			
		||||
			this.resourceHttpMessageConverter = new ResourceHttpMessageConverter();
 | 
			
		||||
		}
 | 
			
		||||
		if(this.resourceRegionHttpMessageConverter == null) {
 | 
			
		||||
		if (this.resourceRegionHttpMessageConverter == null) {
 | 
			
		||||
			this.resourceRegionHttpMessageConverter = new ResourceRegionHttpMessageConverter();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -372,7 +372,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
 | 
			
		|||
			try {
 | 
			
		||||
				List<HttpRange> httpRanges = inputMessage.getHeaders().getRange();
 | 
			
		||||
				response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
 | 
			
		||||
				if(httpRanges.size() == 1) {
 | 
			
		||||
				if (httpRanges.size() == 1) {
 | 
			
		||||
					ResourceRegion resourceRegion = httpRanges.get(0).toResourceRegion(resource);
 | 
			
		||||
					this.resourceRegionHttpMessageConverter.write(resourceRegion, mediaType, outputMessage);
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -181,8 +181,8 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
 | 
			
		|||
			try {
 | 
			
		||||
				pageContext.getOut().print(url);
 | 
			
		||||
			}
 | 
			
		||||
			catch (IOException e) {
 | 
			
		||||
				throw new JspException(e);
 | 
			
		||||
			catch (IOException ex) {
 | 
			
		||||
				throw new JspException(ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2012 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -25,8 +25,8 @@ import org.springframework.util.StringUtils;
 | 
			
		|||
 | 
			
		||||
/**
 | 
			
		||||
 * Convenient super class for many html tags that render content using the databinding
 | 
			
		||||
 * features of the {@link AbstractHtmlElementTag AbstractHtmlElementTag}. The only thing sub tags
 | 
			
		||||
 * need to do is override {@link #renderDefaultContent(TagWriter)}.
 | 
			
		||||
 * features of the {@link AbstractHtmlElementTag AbstractHtmlElementTag}. The only thing
 | 
			
		||||
 * sub-tags need to do is override {@link #renderDefaultContent(TagWriter)}.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Rob Harrop
 | 
			
		||||
 * @author Juergen Hoeller
 | 
			
		||||
| 
						 | 
				
			
			@ -136,8 +136,8 @@ public abstract class AbstractHtmlElementBodyTag extends AbstractHtmlElementTag
 | 
			
		|||
		try {
 | 
			
		||||
			bodyContent.writeOut(bodyContent.getEnclosingWriter());
 | 
			
		||||
		}
 | 
			
		||||
		catch (IOException e) {
 | 
			
		||||
			throw new JspException("Unable to write buffered body content.", e);
 | 
			
		||||
		catch (IOException ex) {
 | 
			
		||||
			throw new JspException("Unable to write buffered body content.", ex);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2012 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -13,6 +13,7 @@
 | 
			
		|||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package org.springframework.web.servlet.view.tiles3;
 | 
			
		||||
 | 
			
		||||
import java.util.Locale;
 | 
			
		||||
| 
						 | 
				
			
			@ -46,8 +47,8 @@ public class SpringLocaleResolver extends DefaultLocaleResolver {
 | 
			
		|||
				return RequestContextUtils.getLocale(servletRequest);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		catch (NotAServletEnvironmentException e) {
 | 
			
		||||
			// Ignore
 | 
			
		||||
		catch (NotAServletEnvironmentException ex) {
 | 
			
		||||
			// ignore
 | 
			
		||||
		}
 | 
			
		||||
		return super.resolveLocale(request);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,8 +117,8 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
 | 
			
		|||
					}
 | 
			
		||||
					this.client.start();
 | 
			
		||||
				}
 | 
			
		||||
				catch (Exception e) {
 | 
			
		||||
					throw new IllegalStateException("Failed to start Jetty client", e);
 | 
			
		||||
				catch (Exception ex) {
 | 
			
		||||
					throw new IllegalStateException("Failed to start Jetty client", ex);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -134,8 +134,8 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
 | 
			
		|||
					}
 | 
			
		||||
					this.client.stop();
 | 
			
		||||
				}
 | 
			
		||||
				catch (Exception e) {
 | 
			
		||||
					logger.error("Error stopping Jetty WebSocketClient", e);
 | 
			
		||||
				catch (Exception ex) {
 | 
			
		||||
					logger.error("Error stopping Jetty WebSocketClient", ex);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2013 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -24,9 +24,11 @@ import org.springframework.web.socket.WebSocketHandler;
 | 
			
		|||
import org.springframework.web.socket.WebSocketSession;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A convenient base class for {@link WebSocketHandler} implementation that process binary
 | 
			
		||||
 * messages only. Text messages are rejected with {@link CloseStatus#NOT_ACCEPTABLE}. All
 | 
			
		||||
 * other methods have empty implementations.
 | 
			
		||||
 * A convenient base class for {@link WebSocketHandler} implementations
 | 
			
		||||
 * that process binary messages only.
 | 
			
		||||
 *
 | 
			
		||||
 * <p>Text messages are rejected with {@link CloseStatus#NOT_ACCEPTABLE}.
 | 
			
		||||
 * All other methods have empty implementations.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Rossen Stoyanchev
 | 
			
		||||
 * @author Phillip Webb
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +41,7 @@ public class BinaryWebSocketHandler extends AbstractWebSocketHandler {
 | 
			
		|||
		try {
 | 
			
		||||
			session.close(CloseStatus.NOT_ACCEPTABLE.withReason("Text messages not supported"));
 | 
			
		||||
		}
 | 
			
		||||
		catch (IOException e) {
 | 
			
		||||
		catch (IOException ex) {
 | 
			
		||||
			// ignore
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2002-2013 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -24,9 +24,11 @@ import org.springframework.web.socket.WebSocketHandler;
 | 
			
		|||
import org.springframework.web.socket.WebSocketSession;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A convenient base class for {@link WebSocketHandler} implementation that process text
 | 
			
		||||
 * messages only. Binary messages are rejected with {@link CloseStatus#NOT_ACCEPTABLE}. All
 | 
			
		||||
 * other methods have empty implementations.
 | 
			
		||||
 * A convenient base class for {@link WebSocketHandler} implementations
 | 
			
		||||
 * that process text messages only.
 | 
			
		||||
 *
 | 
			
		||||
 * <p>Binary messages are rejected with {@link CloseStatus#NOT_ACCEPTABLE}.
 | 
			
		||||
 * All other methods have empty implementations.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Rossen Stoyanchev
 | 
			
		||||
 * @author Phillip Webb
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,8 +82,8 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
 | 
			
		|||
				this.httpClient.start();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e) {
 | 
			
		||||
			throw new SockJsException("Failed to start " + this, e);
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			throw new SockJsException("Failed to start " + this, ex);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -94,8 +94,8 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
 | 
			
		|||
				this.httpClient.stop();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e) {
 | 
			
		||||
			throw new SockJsException("Failed to stop " + this, e);
 | 
			
		||||
		catch (Exception ex) {
 | 
			
		||||
			throw new SockJsException("Failed to stop " + this, ex);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -154,6 +154,7 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
 | 
			
		|||
				new ResponseEntity<>(responseHeaders, status));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	private static void addHttpHeaders(Request request, HttpHeaders headers) {
 | 
			
		||||
		for (String name : headers.keySet()) {
 | 
			
		||||
			for (String value : headers.get(name)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +195,6 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
 | 
			
		|||
 | 
			
		||||
		private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		public SockJsResponseListener(URI url, HttpHeaders headers,	XhrClientSockJsSession sockJsSession,
 | 
			
		||||
				SettableListenableFuture<WebSocketSession> connectFuture) {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -204,7 +204,6 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
 | 
			
		|||
			this.sockJsSession = sockJsSession;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
		public void onBegin(Response response) {
 | 
			
		||||
			if (response.getStatus() != 200) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue