提交 473ed1a6 编写于 作者: J Juergen Hoeller

Polishing

上级 cc02269c
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
......@@ -17,7 +17,6 @@
package org.springframework.mail.javamail;
import java.beans.PropertyEditorSupport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
......
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
......@@ -17,7 +17,6 @@
package org.springframework.mail.javamail;
import java.util.Date;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
......
......@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -38,7 +38,6 @@ import org.springframework.messaging.support.InterceptableChannel;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
/**
* Abstract base class for a {@link MessageHandler} that broker messages to
* registered subscribers.
......@@ -51,7 +50,6 @@ public abstract class AbstractBrokerMessageHandler
protected final Log logger = LogFactory.getLog(getClass());
private final SubscribableChannel clientInboundChannel;
private final MessageChannel clientOutboundChannel;
......@@ -74,7 +72,7 @@ public abstract class AbstractBrokerMessageHandler
private final Object lifecycleMonitor = new Object();
private ChannelInterceptor unsentDisconnectInterceptor = new UnsentDisconnectChannelInterceptor();
private final ChannelInterceptor unsentDisconnectInterceptor = new UnsentDisconnectChannelInterceptor();
/**
......@@ -151,18 +149,6 @@ public abstract class AbstractBrokerMessageHandler
return Integer.MAX_VALUE;
}
/**
* 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.
*/
@Override
public final boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
}
@Override
public void start() {
......@@ -177,9 +163,7 @@ public abstract class AbstractBrokerMessageHandler
}
startInternal();
this.running = true;
if (logger.isInfoEnabled()) {
logger.info("Started.");
}
logger.info("Started.");
}
}
......@@ -199,9 +183,7 @@ public abstract class AbstractBrokerMessageHandler
((InterceptableChannel) this.clientInboundChannel).removeInterceptor(this.unsentDisconnectInterceptor);
}
this.running = false;
if (logger.isDebugEnabled()) {
logger.info("Stopped.");
}
logger.info("Stopped.");
}
}
......@@ -216,6 +198,19 @@ 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.
*/
@Override
public final boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
}
/**
* 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
......@@ -245,6 +240,7 @@ public abstract class AbstractBrokerMessageHandler
protected abstract void handleMessageInternal(Message<?> message);
protected boolean checkDestinationPrefix(String destination) {
if ((destination == null) || CollectionUtils.isEmpty(this.destinationPrefixes)) {
return true;
......@@ -294,4 +290,5 @@ public abstract class AbstractBrokerMessageHandler
}
}
}
}
......@@ -47,8 +47,8 @@ public interface ChannelInterceptor {
/**
* Invoked after the completion of a send regardless of any exception that
* have been raised thus allowing for proper resource cleanup.
* <p>Note that this will be invoked only if preSend successfully completed
* and returned a Message, i.e. it did not return {@code null}.
* <p>Note that this will be invoked only if {@link #preSend} successfully
* completed and returned a Message, i.e. it did not return {@code null}.
* @since 4.1
*/
void afterSendCompletion(Message<?> message, MessageChannel channel, boolean sent, Exception ex);
......@@ -70,7 +70,7 @@ public interface ChannelInterceptor {
/**
* Invoked after the completion of a receive regardless of any exception that
* have been raised thus allowing for proper resource cleanup.
* <p>Note that this will be invoked only if preReceive successfully
* <p>Note that this will be invoked only if {@link #preReceive} successfully
* completed and returned {@code true}.
* @since 4.1
*/
......
......@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.messaging.support;
import java.util.List;
......
......@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -33,6 +33,7 @@ import static org.mockito.Mockito.mock;
/**
* Test fixture for the use of {@link ChannelInterceptor}s.
*
* @author Rossen Stoyanchev
*/
public class ChannelInterceptorTests {
......@@ -184,8 +185,7 @@ public class ChannelInterceptorTests {
private static class TestMessageHandler implements MessageHandler {
private List<Message<?>> messages = new ArrayList<Message<?>>();
private final List<Message<?>> messages = new ArrayList<Message<?>>();
public List<Message<?>> getMessages() {
return this.messages;
......@@ -193,17 +193,17 @@ public class ChannelInterceptorTests {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
this.getMessages().add(message);
this.messages.add(message);
}
}
private abstract static class AbstractTestInterceptor extends ChannelInterceptorAdapter {
private AtomicInteger counter = new AtomicInteger();
private volatile boolean afterCompletionInvoked;
public AtomicInteger getCounter() {
return this.counter;
}
......@@ -225,13 +225,13 @@ public class ChannelInterceptorTests {
}
}
private static class PreSendInterceptor extends AbstractTestInterceptor {
private Message<?> messageToReturn;
private RuntimeException exceptionToRaise;
public void setMessageToReturn(Message<?> messageToReturn) {
this.messageToReturn = messageToReturn;
}
......@@ -250,6 +250,7 @@ public class ChannelInterceptorTests {
}
}
private static class NullReturningPreSendInterceptor extends AbstractTestInterceptor {
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册