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.
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user