Polishing

This commit is contained in:
Juergen Hoeller
2014-07-24 18:35:49 +02:00
parent fca72f6b65
commit 6e95b2613e
78 changed files with 467 additions and 463 deletions

View File

@@ -94,7 +94,7 @@ public abstract class AbstractExceptionHandlerMethodResolver {
*/
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
for(Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
if (mappedException.isAssignableFrom(exceptionType)) {
matches.add(mappedException);
}

View File

@@ -39,7 +39,7 @@ import org.springframework.util.CollectionUtils;
* @since 4.0
*/
public abstract class AbstractBrokerMessageHandler
implements MessageHandler, SmartLifecycle, ApplicationEventPublisherAware {
implements MessageHandler, ApplicationEventPublisherAware, SmartLifecycle {
protected final Log logger = LogFactory.getLog(getClass());
@@ -51,10 +51,10 @@ public abstract class AbstractBrokerMessageHandler
private boolean autoStartup = true;
private Object lifecycleMonitor = new Object();
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
public AbstractBrokerMessageHandler() {
this(Collections.<String>emptyList());
@@ -95,7 +95,6 @@ public abstract class AbstractBrokerMessageHandler
/**
* Check whether this message handler is currently running.
*
* <p>Note that even when this message handler is running the
* {@link #isBrokerAvailable()} flag may still independently alternate between
* being on and off depending on the concrete sub-class implementation.
@@ -107,23 +106,6 @@ public abstract class AbstractBrokerMessageHandler
}
}
/**
* Whether the message broker is currently available and able to process messages.
*
* <p>Note that this is in addition to the {@link #isRunning()} flag, which
* indicates whether this message handler is running. In other words the message
* handler must first be running and then the {@link #isBrokerAvailable()} flag
* may still independently alternate between being on and off depending on the
* concrete sub-class implementation.
*
* <p>Application components may implement
* {@link org.springframework.context.ApplicationListener<BrokerAvailabilityEvent>>}
* to receive notifications when broker becomes available and unavailable.
*/
public boolean isBrokerAvailable() {
return this.brokerAvailable.get();
}
@Override
public final void start() {
synchronized (this.lifecycleMonitor) {
@@ -166,6 +148,22 @@ public abstract class AbstractBrokerMessageHandler
}
}
/**
* Whether the message broker is currently available and able to process messages.
* <p>Note that this is in addition to the {@link #isRunning()} flag, which
* indicates whether this message handler is running. In other words the message
* handler must first be running and then the {@code #isBrokerAvailable()} flag
* may still independently alternate between being on and off depending on the
* concrete sub-class implementation.
* <p>Application components may implement
* {@code org.springframework.context.ApplicationListener&lt;BrokerAvailabilityEvent&gt;}
* to receive notifications when broker becomes available and unavailable.
*/
public boolean isBrokerAvailable() {
return this.brokerAvailable.get();
}
@Override
public final void handleMessage(Message<?> message) {
if (!this.running) {

View File

@@ -316,7 +316,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
public void addSubscription(String destination, String subscriptionId) {
Set<String> subs = this.subscriptions.get(destination);
if (subs == null) {
synchronized(this.monitor) {
synchronized (this.monitor) {
subs = this.subscriptions.get(destination);
if (subs == null) {
subs = new HashSet<String>(4);
@@ -331,7 +331,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
for (String destination : this.subscriptions.keySet()) {
Set<String> subscriptionIds = this.subscriptions.get(destination);
if (subscriptionIds.remove(subscriptionId)) {
synchronized(this.monitor) {
synchronized (this.monitor) {
if (subscriptionIds.isEmpty()) {
this.subscriptions.remove(destination);
}

View File

@@ -319,7 +319,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
protected Validator simpValidator() {
Validator validator = getValidator();
if (validator == null) {
if(this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) {
if (this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) {
validator = this.applicationContext.getBean(MVC_VALIDATOR_NAME, Validator.class);
}
else if (ClassUtils.isPresent("javax.validation.Validator", getClass().getClassLoader())) {

View File

@@ -192,7 +192,7 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
if (this.systemHeartbeatReceiveInterval != null) {
handler.setSystemHeartbeatReceiveInterval(this.systemHeartbeatReceiveInterval);
}
if(this.virtualHost != null) {
if (this.virtualHost != null) {
handler.setVirtualHost(this.virtualHost);
}