提交 a9ae2c34 编写于 作者: J Juergen Hoeller

Polishing

上级 e566e25b
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 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.
...@@ -180,9 +180,9 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache { ...@@ -180,9 +180,9 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
try { try {
return serializeValue(storeValue); return serializeValue(storeValue);
} }
catch (Exception ex) { catch (Throwable ex) {
throw new IllegalArgumentException("Failed to serialize cache value '" throw new IllegalArgumentException("Failed to serialize cache value '" + userValue +
+ userValue + "'. Does it implement Serializable?", ex); "'. Does it implement Serializable?", ex);
} }
} }
else { else {
...@@ -207,9 +207,8 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache { ...@@ -207,9 +207,8 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
try { try {
return super.fromStoreValue(deserializeValue(storeValue)); return super.fromStoreValue(deserializeValue(storeValue));
} }
catch (Exception ex) { catch (Throwable ex) {
throw new IllegalArgumentException("Failed to deserialize cache value '" + throw new IllegalArgumentException("Failed to deserialize cache value '" + storeValue + "'", ex);
storeValue + "'", ex);
} }
} }
else { else {
......
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2017 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.
...@@ -22,12 +22,12 @@ import org.springframework.jms.listener.AbstractMessageListenerContainer; ...@@ -22,12 +22,12 @@ import org.springframework.jms.listener.AbstractMessageListenerContainer;
import org.springframework.jms.listener.MessageListenerContainer; import org.springframework.jms.listener.MessageListenerContainer;
import org.springframework.jms.listener.endpoint.JmsActivationSpecConfig; import org.springframework.jms.listener.endpoint.JmsActivationSpecConfig;
import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager; import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager;
import org.springframework.util.Assert;
/** /**
* Base model for a JMS listener endpoint * Base model for a JMS listener endpoint
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Juergen Hoeller
* @since 4.1 * @since 4.1
* @see MethodJmsListenerEndpoint * @see MethodJmsListenerEndpoint
* @see SimpleJmsListenerEndpoint * @see SimpleJmsListenerEndpoint
...@@ -150,7 +150,9 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint ...@@ -150,7 +150,9 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
private void setupMessageListener(MessageListenerContainer container) { private void setupMessageListener(MessageListenerContainer container) {
MessageListener messageListener = createMessageListener(container); MessageListener messageListener = createMessageListener(container);
Assert.state(messageListener != null, "Endpoint [" + this + "] must provide a non null message listener"); if (messageListener == null) {
throw new IllegalStateException("Endpoint [" + this + "] must provide a non-null message listener");
}
container.setupMessageListener(messageListener); container.setupMessageListener(messageListener);
} }
......
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 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.
...@@ -117,8 +117,7 @@ public class JmsListenerEndpointRegistrar implements BeanFactoryAware, Initializ ...@@ -117,8 +117,7 @@ public class JmsListenerEndpointRegistrar implements BeanFactoryAware, Initializ
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
if (beanFactory instanceof ConfigurableBeanFactory) { if (beanFactory instanceof ConfigurableBeanFactory) {
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory; this.mutex = ((ConfigurableBeanFactory) beanFactory).getSingletonMutex();
this.mutex = cbf.getSingletonMutex();
} }
} }
......
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 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.
...@@ -57,8 +57,6 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple ...@@ -57,8 +57,6 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple
private StringValueResolver embeddedValueResolver; private StringValueResolver embeddedValueResolver;
private BeanFactory beanFactory;
/** /**
* Set the actual bean instance to invoke this endpoint method on. * Set the actual bean instance to invoke this endpoint method on.
...@@ -122,11 +120,10 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple ...@@ -122,11 +120,10 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple
} }
/** /**
* Set the {@link BeanFactory} to use to resolve expressions (can be {@code null}). * Set the {@link BeanFactory} to use to resolve expressions (may be {@code null}).
*/ */
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
if (this.embeddedValueResolver == null && beanFactory instanceof ConfigurableBeanFactory) { if (this.embeddedValueResolver == null && beanFactory instanceof ConfigurableBeanFactory) {
this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory); this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
} }
......
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 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.
...@@ -23,8 +23,9 @@ import javax.jms.Session; ...@@ -23,8 +23,9 @@ import javax.jms.Session;
/** /**
* Callback for browsing the messages in a JMS queue. * Callback for browsing the messages in a JMS queue.
* *
* <p>To be used with JmsTemplate's callback methods that take a BrowserCallback * <p>To be used with {@link JmsTemplate}'s callback methods that take a
* argument, often implemented as an anonymous inner class. * {@link BrowserCallback} argument, often implemented as an anonymous
* inner class or as a lambda expression.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5.1 * @since 2.5.1
...@@ -35,11 +36,12 @@ import javax.jms.Session; ...@@ -35,11 +36,12 @@ import javax.jms.Session;
public interface BrowserCallback<T> { public interface BrowserCallback<T> {
/** /**
* Perform operations on the given {@link javax.jms.Session} and {@link javax.jms.QueueBrowser}. * Perform operations on the given {@link javax.jms.Session} and
* <p>The message producer is not associated with any destination. * {@link javax.jms.QueueBrowser}.
* @param session the JMS {@code Session} object to use * @param session the JMS {@code Session} object to use
* @param browser the JMS {@code QueueBrowser} object to use * @param browser the JMS {@code QueueBrowser} object to use
* @return a result object from working with the {@code Session}, if any (can be {@code null}) * @return a result object from working with the {@code Session}, if any
* (or {@code null} if none)
* @throws javax.jms.JMSException if thrown by JMS API methods * @throws javax.jms.JMSException if thrown by JMS API methods
*/ */
T doInJms(Session session, QueueBrowser browser) throws JMSException; T doInJms(Session session, QueueBrowser browser) throws JMSException;
......
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 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.
...@@ -23,8 +23,9 @@ import javax.jms.Session; ...@@ -23,8 +23,9 @@ import javax.jms.Session;
/** /**
* Callback for sending a message to a JMS destination. * Callback for sending a message to a JMS destination.
* *
* <p>To be used with JmsTemplate's callback methods that take a ProducerCallback * <p>To be used with {@link JmsTemplate}'s callback methods that take a
* argument, often implemented as an anonymous inner class. * {@link ProducerCallback} argument, often implemented as an anonymous
* inner class or as a lambda expression.
* *
* <p>The typical implementation will perform multiple operations on the * <p>The typical implementation will perform multiple operations on the
* supplied JMS {@link Session} and {@link MessageProducer}. * supplied JMS {@link Session} and {@link MessageProducer}.
...@@ -44,7 +45,8 @@ public interface ProducerCallback<T> { ...@@ -44,7 +45,8 @@ public interface ProducerCallback<T> {
* when specified in the JmsTemplate call. * when specified in the JmsTemplate call.
* @param session the JMS {@code Session} object to use * @param session the JMS {@code Session} object to use
* @param producer the JMS {@code MessageProducer} object to use * @param producer the JMS {@code MessageProducer} object to use
* @return a result object from working with the {@code Session}, if any (can be {@code null}) * @return a result object from working with the {@code Session}, if any
* (or {@code null} if none)
* @throws javax.jms.JMSException if thrown by JMS API methods * @throws javax.jms.JMSException if thrown by JMS API methods
*/ */
T doInJms(Session session, MessageProducer producer) throws JMSException; T doInJms(Session session, MessageProducer producer) throws JMSException;
......
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 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.
...@@ -20,11 +20,10 @@ import javax.jms.JMSException; ...@@ -20,11 +20,10 @@ import javax.jms.JMSException;
import javax.jms.Session; import javax.jms.Session;
/** /**
* Callback for executing any number of operations on a provided * Callback for executing any number of operations on a provided {@link Session}.
* {@link Session}.
* *
* <p>To be used with the {@link JmsTemplate#execute(SessionCallback)} * <p>To be used with the {@link JmsTemplate#execute(SessionCallback)} method,
* method, often implemented as an anonymous inner class. * often implemented as an anonymous inner class or as a lambda expression.
* *
* @author Mark Pollack * @author Mark Pollack
* @since 1.1 * @since 1.1
...@@ -34,10 +33,11 @@ import javax.jms.Session; ...@@ -34,10 +33,11 @@ import javax.jms.Session;
public interface SessionCallback<T> { public interface SessionCallback<T> {
/** /**
* Execute any number of operations against the supplied JMS * Execute any number of operations against the supplied JMS {@link Session},
* {@link Session}, possibly returning a result. * possibly returning a result.
* @param session the JMS {@code Session} * @param session the JMS {@code Session}
* @return a result object from working with the {@code Session}, if any (so can be {@code null}) * @return a result object from working with the {@code Session}, if any
* (or {@code null} if none)
* @throws javax.jms.JMSException if thrown by JMS API methods * @throws javax.jms.JMSException if thrown by JMS API methods
*/ */
T doInJms(Session session) throws JMSException; T doInJms(Session session) throws JMSException;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册