Sonar: repeated literals

* Polishing - PR Comments

* GatewayParser: Restore suppress warnings; remove size from `toArray()`.

* Merge conflict resolution
This commit is contained in:
Gary Russell
2019-05-03 12:39:02 -04:00
committed by Artem Bilan
parent 444cd1e8df
commit 6d7bc1fc39
38 changed files with 382 additions and 281 deletions

View File

@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiFunction;
import org.springframework.integration.acks.AcknowledgmentCallback;
import org.springframework.lang.Nullable;
@@ -66,6 +67,9 @@ public class IntegrationMessageHeaderAccessor extends MessageHeaderAccessor {
public static final String ACKNOWLEDGMENT_CALLBACK = "acknowledgmentCallback";
private static final BiFunction<String, String, String> TYPE_VERIFY_MESSAGE_FUNCTION =
(name, trailer) -> "The '" + name + trailer;
private Set<String> readOnlyHeaders = new HashSet<>();
public IntegrationMessageHeaderAccessor(@Nullable Message<?> message) {
@@ -168,22 +172,22 @@ public class IntegrationMessageHeaderAccessor extends MessageHeaderAccessor {
if (headerName != null && headerValue != null) {
super.verifyType(headerName, headerValue);
if (IntegrationMessageHeaderAccessor.EXPIRATION_DATE.equals(headerName)) {
Assert.isTrue(headerValue instanceof Date || headerValue instanceof Long, "The '" + headerName
+ "' header value must be a Date or Long.");
Assert.isTrue(headerValue instanceof Date || headerValue instanceof Long,
TYPE_VERIFY_MESSAGE_FUNCTION.apply(headerName, "' header value must be a Date or Long."));
}
else if (IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER.equals(headerName)
|| IntegrationMessageHeaderAccessor.SEQUENCE_SIZE.equals(headerName)
|| IntegrationMessageHeaderAccessor.PRIORITY.equals(headerName)) {
Assert.isTrue(Number.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
+ "' header value must be a Number.");
Assert.isTrue(Number.class.isAssignableFrom(headerValue.getClass()),
TYPE_VERIFY_MESSAGE_FUNCTION.apply(headerName, "' header value must be a Number."));
}
else if (IntegrationMessageHeaderAccessor.ROUTING_SLIP.equals(headerName)) {
Assert.isTrue(Map.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
+ "' header value must be a Map.");
Assert.isTrue(Map.class.isAssignableFrom(headerValue.getClass()),
TYPE_VERIFY_MESSAGE_FUNCTION.apply(headerName, "' header value must be a Map."));
}
else if (IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE.equals(headerName)) {
Assert.isTrue(Boolean.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
+ "' header value must be an Boolean.");
Assert.isTrue(Boolean.class.isAssignableFrom(headerValue.getClass()),
TYPE_VERIFY_MESSAGE_FUNCTION.apply(headerName, "' header value must be an Boolean."));
}
}
}

View File

@@ -47,6 +47,8 @@ import org.springframework.util.xml.DomUtils;
*/
public class EnricherParser extends AbstractConsumerEndpointParser {
private static final String TYPE_ATTRIBUTE = "type";
@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ContentEnricher.class);
@@ -65,8 +67,8 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
String name = subElement.getAttribute("name");
String value = subElement.getAttribute("value");
String type = subElement.getAttribute("type");
String expression = subElement.getAttribute("expression");
String type = subElement.getAttribute(TYPE_ATTRIBUTE);
String expression = subElement.getAttribute(EXPRESSION_ATTRIBUTE);
String nullResultExpression = subElement.getAttribute("null-result-expression");
boolean hasAttributeValue = StringUtils.hasText(value);
boolean hasAttributeExpression = StringUtils.hasText(expression);
@@ -131,13 +133,13 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
String name = subElement.getAttribute("name");
String nullResultHeaderExpression = subElement.getAttribute("null-result-expression");
String valueElementValue = subElement.getAttribute("value");
String expressionElementValue = subElement.getAttribute("expression");
String expressionElementValue = subElement.getAttribute(EXPRESSION_ATTRIBUTE);
boolean hasAttributeValue = StringUtils.hasText(valueElementValue);
boolean hasAttributeExpression = StringUtils.hasText(expressionElementValue);
boolean hasAttributeNullResultExpression = StringUtils.hasText(nullResultHeaderExpression);
if (hasAttributeValue && hasAttributeExpression) {
parserContext.getReaderContext().error("Only one of '" + "value" + "' or '"
+ "expression" + "' is allowed", subElement);
+ EXPRESSION_ATTRIBUTE + "' is allowed", subElement);
}
if (!hasAttributeValue && !hasAttributeExpression && !hasAttributeNullResultExpression) {
@@ -151,11 +153,12 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
}
else if (hasAttributeExpression) {
expressionDef =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("expression", subElement);
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined(EXPRESSION_ATTRIBUTE,
subElement);
}
if (StringUtils.hasText(subElement.getAttribute("expression"))
&& StringUtils.hasText(subElement.getAttribute("type"))) {
if (StringUtils.hasText(subElement.getAttribute(EXPRESSION_ATTRIBUTE))
&& StringUtils.hasText(subElement.getAttribute(TYPE_ATTRIBUTE))) {
parserContext.getReaderContext()
.warning("The use of a 'type' attribute is deprecated since 4.0 "
+ "when using 'expression'", subElement);
@@ -164,8 +167,9 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
BeanDefinitionBuilder valueProcessorBuilder = BeanDefinitionBuilder
.genericBeanDefinition(ExpressionEvaluatingHeaderValueMessageProcessor.class)
.addConstructorArgValue(expressionDef)
.addConstructorArgValue(subElement.getAttribute("type"));
IntegrationNamespaceUtils.setValueIfAttributeDefined(valueProcessorBuilder, subElement, "overwrite");
.addConstructorArgValue(subElement.getAttribute(TYPE_ATTRIBUTE));
IntegrationNamespaceUtils.setValueIfAttributeDefined(valueProcessorBuilder, subElement,
"overwrite");
expressions.put(name, valueProcessorBuilder.getBeanDefinition());
}
if (hasAttributeNullResultExpression) {
@@ -174,7 +178,7 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
BeanDefinitionBuilder nullResultValueProcessorBuilder = BeanDefinitionBuilder
.genericBeanDefinition(ExpressionEvaluatingHeaderValueMessageProcessor.class)
.addConstructorArgValue(nullResultExpressionDefinition)
.addConstructorArgValue(subElement.getAttribute("type"));
.addConstructorArgValue(subElement.getAttribute(TYPE_ATTRIBUTE));
IntegrationNamespaceUtils.setValueIfAttributeDefined(nullResultValueProcessorBuilder, subElement,
"overwrite");
nullResultHeaderExpressions.put(name, nullResultValueProcessorBuilder.getBeanDefinition());

View File

@@ -56,7 +56,8 @@ public class GatewayParser implements BeanDefinitionParser {
boolean isNested = parserContext.isNested();
final Map<String, Object> gatewayAttributes = new HashMap<String, Object>();
gatewayAttributes.put("name", element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE));
gatewayAttributes.put(AbstractBeanDefinitionParser.NAME_ATTRIBUTE,
element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE));
gatewayAttributes.put("defaultPayloadExpression", element.getAttribute("default-payload-expression"));
gatewayAttributes.put("defaultRequestChannel",
element.getAttribute(isNested ? "request-channel" : "default-request-channel"));
@@ -84,19 +85,20 @@ public class GatewayParser implements BeanDefinitionParser {
List<Map<String, Object>> headers = new ArrayList<Map<String, Object>>(headerElements.size());
for (Element e : headerElements) {
Map<String, Object> header = new HashMap<String, Object>();
header.put("name", e.getAttribute("name"));
header.put(AbstractBeanDefinitionParser.NAME_ATTRIBUTE,
e.getAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE));
header.put("value", e.getAttribute("value"));
header.put("expression", e.getAttribute("expression"));
headers.add(header);
}
gatewayAttributes.put("defaultHeaders", headers.toArray(new Map[headers.size()]));
gatewayAttributes.put("defaultHeaders", headers.toArray(new Map[0]));
}
List<Element> methodElements = DomUtils.getChildElementsByTagName(element, "method");
if (!CollectionUtils.isEmpty(methodElements)) {
Map<String, BeanDefinition> methodMetadataMap = new ManagedMap<String, BeanDefinition>();
for (Element methodElement : methodElements) {
String methodName = methodElement.getAttribute("name");
String methodName = methodElement.getAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE);
BeanDefinitionBuilder methodMetadataBuilder = BeanDefinitionBuilder.genericBeanDefinition(
GatewayMethodMetadata.class);
methodMetadataBuilder.addPropertyValue("requestChannelName",
@@ -122,7 +124,8 @@ public class GatewayParser implements BeanDefinitionParser {
.createExpressionDefinitionFromValueOrExpression("value", "expression", parserContext,
headerElement, true);
headerExpressions.put(headerElement.getAttribute("name"), expressionDef);
headerExpressions.put(headerElement.getAttribute(AbstractBeanDefinitionParser.NAME_ATTRIBUTE),
expressionDef);
}
methodMetadataBuilder.addPropertyValue("headerExpressions", headerExpressions);
}

View File

@@ -55,6 +55,8 @@ import org.springframework.util.xml.DomUtils;
*/
public abstract class HeaderEnricherParserSupport extends AbstractTransformerParser {
private static final String TYPE_ATTRIBUTE = "type";
private static final Map<String, String[][]> cannedHeaderElementExpressions = new HashMap<>(); // NOSONAR lower case
private final Map<String, String> elementToNameMap = new HashMap<>();
@@ -114,14 +116,14 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
else {
headerName = this.elementToNameMap.get(elementName);
headerType = this.elementToTypeMap.get(elementName);
if (headerType != null && StringUtils.hasText(headerElement.getAttribute("type"))) {
if (headerType != null && StringUtils.hasText(headerElement.getAttribute(TYPE_ATTRIBUTE))) {
parserContext.getReaderContext().error("The " + elementName
+ " header does not accept a 'type' attribute. The required type is ["
+ headerType + "]", element);
}
}
if (headerType == null) {
headerType = headerElement.getAttribute("type");
headerType = headerElement.getAttribute(TYPE_ATTRIBUTE);
}
if (headerName == null) {
String ttlExpression = headerElement.getAttribute("time-to-live-expression");
@@ -261,7 +263,7 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
valueProcessorBuilder.addConstructorArgValue(headerType);
}
else if (isCustomBean) {
if (StringUtils.hasText(headerElement.getAttribute("type"))) {
if (StringUtils.hasText(headerElement.getAttribute(TYPE_ATTRIBUTE))) {
parserContext.getReaderContext().error(
"The 'type' attribute cannot be used with an inner bean.", element);
}
@@ -280,7 +282,7 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
}
}
else {
if (StringUtils.hasText(headerElement.getAttribute("type"))) {
if (StringUtils.hasText(headerElement.getAttribute(TYPE_ATTRIBUTE))) {
parserContext.getReaderContext().error(
"The 'type' attribute cannot be used with the 'ref' attribute.", element);
}

View File

@@ -255,7 +255,7 @@ public abstract class IntegrationNamespaceUtils {
public static void configurePollerMetadata(Element pollerElement, BeanDefinitionBuilder targetBuilder,
ParserContext parserContext) {
if (pollerElement.hasAttribute("ref")) {
if (pollerElement.hasAttribute(REF_ATTRIBUTE)) {
int numberOfAttributes = pollerElement.getAttributes().getLength();
if (numberOfAttributes != 1) {
/*
@@ -273,7 +273,7 @@ public abstract class IntegrationNamespaceUtils {
parserContext.getReaderContext().error(
"A 'poller' element that provides a 'ref' must have no child elements.", pollerElement);
}
targetBuilder.addPropertyReference("pollerMetadata", pollerElement.getAttribute("ref"));
targetBuilder.addPropertyReference("pollerMetadata", pollerElement.getAttribute(REF_ATTRIBUTE));
}
else {
BeanDefinition beanDefinition = parserContext.getDelegate().parseCustomElement(pollerElement,
@@ -519,7 +519,7 @@ public abstract class IntegrationNamespaceUtils {
parserContext.registerBeanComponent(new BeanComponentDefinition(holder)); // NOSONAR never null
adviceChain.add(new RuntimeBeanReference(holder.getBeanName()));
}
else if ("ref".equals(localName)) {
else if (REF_ATTRIBUTE.equals(localName)) {
String ref = childElement.getAttribute("bean");
adviceChain.add(new RuntimeBeanReference(ref));
}

View File

@@ -46,6 +46,8 @@ import org.springframework.util.xml.DomUtils;
*/
public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
private static final String PAYLOAD = "payload";
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
BeanDefinitionBuilder rootBuilder = BeanDefinitionBuilder.genericBeanDefinition(
@@ -54,7 +56,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
.genericBeanDefinition(MethodNameMappingPublisherMetadataSource.class);
Map<String, Map<?, ?>> mappings = this
.getMappings(element, element.getAttribute("default-channel"), parserContext);
spelSourceBuilder.addConstructorArgValue(mappings.get("payload"));
spelSourceBuilder.addConstructorArgValue(mappings.get(PAYLOAD));
if (mappings.get("headers") != null) {
spelSourceBuilder.addPropertyValue("headerExpressionMap", mappings.get("headers"));
}
@@ -81,8 +83,8 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
// set payloadMap
String methodPattern = StringUtils.hasText(mapping.getAttribute("pattern")) ?
mapping.getAttribute("pattern") : "*";
String payloadExpression = StringUtils.hasText(mapping.getAttribute("payload")) ?
mapping.getAttribute("payload") : "#return";
String payloadExpression = StringUtils.hasText(mapping.getAttribute(PAYLOAD)) ?
mapping.getAttribute(PAYLOAD) : "#return";
payloadExpressionMap.put(methodPattern, payloadExpression);
// set headersMap
@@ -125,7 +127,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
if (payloadExpressionMap.size() == 0) {
payloadExpressionMap.put("*", "#return");
}
interceptorMappings.put("payload", payloadExpressionMap);
interceptorMappings.put(PAYLOAD, payloadExpressionMap);
if (headersExpressionMap.size() > 0) {
interceptorMappings.put("headers", headersExpressionMap);
}

View File

@@ -29,26 +29,28 @@ import org.springframework.util.StringUtils;
* Parser for 'resource-inbound-channel-adapter'
*
* @author Oleg Zhurakousky
* @author Gary Russell
* @since 2.1
*/
public class ResourceInboundChannelAdapterParser extends AbstractPollingInboundChannelAdapterParser {
private static final String FILTER = "filter";
@Override
protected BeanMetadataElement parseSource(Element element, ParserContext parserContext) {
BeanDefinitionBuilder sourceBuilder = BeanDefinitionBuilder.genericBeanDefinition(ResourceRetrievingMessageSource.class);
sourceBuilder.addConstructorArgValue(element.getAttribute("pattern"));
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(sourceBuilder, element, "pattern-resolver");
boolean hasFilter = element.hasAttribute("filter");
boolean hasFilter = element.hasAttribute(FILTER);
if (hasFilter) {
String filterValue = element.getAttribute("filter");
String filterValue = element.getAttribute(FILTER);
if (StringUtils.hasText(filterValue)) {
sourceBuilder.addPropertyReference("filter", filterValue);
sourceBuilder.addPropertyReference(FILTER, filterValue);
}
}
else {
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.genericBeanDefinition(AcceptOnceCollectionFilter.class);
sourceBuilder.addPropertyValue("filter", filterBuilder.getBeanDefinition());
sourceBuilder.addPropertyValue(FILTER, filterBuilder.getBeanDefinition());
}
return sourceBuilder.getBeanDefinition();
}

View File

@@ -35,6 +35,8 @@ import org.springframework.util.Assert;
*/
public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMessagingOperations {
private static final String UNCHECKED = "unchecked";
private volatile AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
@@ -90,19 +92,19 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncReceiveAndConvert() {
return this.executor.submit(() -> (R) receiveAndConvert(Object.class));
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncReceiveAndConvert(final PollableChannel channel) {
return this.executor.submit(() -> (R) receiveAndConvert(channel, Object.class));
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncReceiveAndConvert(final String channelName) {
return this.executor.submit(() -> (R) receiveAndConvert(channelName, Object.class));
}
@@ -123,32 +125,32 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncConvertSendAndReceive(final Object request) {
return this.executor.submit(() -> (R) convertSendAndReceive(request, Object.class));
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncConvertSendAndReceive(final MessageChannel channel, final Object request) {
return this.executor.submit(() -> (R) convertSendAndReceive(channel, request, Object.class));
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncConvertSendAndReceive(final String channelName, final Object request) {
return this.executor.submit(() -> (R) convertSendAndReceive(channelName, request, Object.class));
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncConvertSendAndReceive(final Object request,
final MessagePostProcessor requestPostProcessor) {
return this.executor.submit(() -> (R) convertSendAndReceive(request, Object.class, requestPostProcessor));
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncConvertSendAndReceive(final MessageChannel channel, final Object request,
final MessagePostProcessor requestPostProcessor) {
return this.executor
@@ -156,7 +158,7 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <R> Future<R> asyncConvertSendAndReceive(final String channelName, final Object request,
final MessagePostProcessor requestPostProcessor) {
return this.executor

View File

@@ -56,6 +56,8 @@ import reactor.util.function.Tuple2;
*/
public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec, MessageTransformingHandler> {
private static final String HEADERS_MUST_NOT_BE_NULL = "'headers' must not be null";
private final Map<String, HeaderValueMessageProcessor<?>> headerToAdd = new HashMap<>();
private final HeaderEnricher headerEnricher = new HeaderEnricher(this.headerToAdd);
@@ -150,7 +152,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec.
*/
public HeaderEnricherSpec headers(MapBuilder<?, String, Object> headers, Boolean overwrite) {
Assert.notNull(headers, "'headers' must not be null");
Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL);
return headers(headers.get(), overwrite);
}
@@ -176,7 +178,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec.
*/
public HeaderEnricherSpec headers(Map<String, Object> headers, Boolean overwrite) {
Assert.notNull(headers, "'headers' must not be null");
Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL);
for (Entry<String, Object> entry : headers.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
@@ -214,7 +216,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec.
*/
public HeaderEnricherSpec headerExpressions(MapBuilder<?, String, String> headers, Boolean overwrite) {
Assert.notNull(headers, "'headers' must not be null");
Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL);
return headerExpressions(headers.get(), overwrite);
}
@@ -283,7 +285,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec.
*/
public HeaderEnricherSpec headerExpressions(Map<String, String> headers, Boolean overwrite) {
Assert.notNull(headers, "'headers' must not be null");
Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL);
for (Entry<String, String> entry : headers.entrySet()) {
AbstractHeaderValueMessageProcessor<Object> processor =
new ExpressionEvaluatingHeaderValueMessageProcessor<>(entry.getValue(), null);

View File

@@ -115,6 +115,12 @@ import reactor.util.function.Tuple2;
*/
public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinition<B>> {
private static final String UNCHECKED = "unchecked";
private static final String FUNCTION_MUST_NOT_BE_NULL = "'function' must not be null";
private static final String MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL = "'messageProcessorSpec' must not be null";
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
private static final Set<MessageProducer> REFERENCED_REPLY_PRODUCERS = new HashSet<>();
@@ -582,7 +588,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
*/
public B transform(MessageProcessorSpec<?> messageProcessorSpec,
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null");
Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL);
MessageProcessor<?> processor = messageProcessorSpec.get();
return addComponent(processor)
.transform(new MethodInvokingTransformer(processor), endpointConfigurer);
@@ -814,7 +820,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
* @return the current {@link IntegrationFlowDefinition}.
*/
public B filter(MessageProcessorSpec<?> messageProcessorSpec, Consumer<FilterEndpointSpec> endpointConfigurer) {
Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null");
Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL);
MessageProcessor<?> processor = messageProcessorSpec.get();
return addComponent(processor)
.filter(new MethodInvokingSelector(processor), endpointConfigurer);
@@ -1133,7 +1139,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
*/
public B handle(MessageProcessorSpec<?> messageProcessorSpec,
Consumer<GenericEndpointSpec<ServiceActivatingHandler>> endpointConfigurer) {
Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null");
Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL);
MessageProcessor<?> processor = messageProcessorSpec.get();
return addComponent(processor)
.handle(new ServiceActivatingHandler(processor), endpointConfigurer);
@@ -1518,7 +1524,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
*/
public B split(MessageProcessorSpec<?> messageProcessorSpec,
Consumer<SplitterEndpointSpec<MethodInvokingSplitter>> endpointConfigurer) {
Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null");
Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL);
MessageProcessor<?> processor = messageProcessorSpec.get();
return addComponent(processor)
.split(new MethodInvokingSplitter(processor), endpointConfigurer);
@@ -2056,7 +2062,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
*/
public B route(MessageProcessorSpec<?> messageProcessorSpec,
Consumer<RouterSpec<Object, MethodInvokingRouter>> routerConfigurer) {
Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null");
Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL);
MessageProcessor<?> processor = messageProcessorSpec.get();
addComponent(processor);
@@ -2371,7 +2377,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
* @see #wireTap(WireTapSpec)
*/
public <P> B log(Function<Message<P>, Object> function) {
Assert.notNull(function, "'function' must not be null");
Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL);
return log(new FunctionExpression<>(function));
}
@@ -2488,7 +2494,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
* @see #wireTap(WireTapSpec)
*/
public <P> B log(LoggingHandler.Level level, String category, Function<Message<P>, Object> function) {
Assert.notNull(function, "'function' must not be null");
Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL);
return log(level, category, new FunctionExpression<>(function));
}
@@ -2632,7 +2638,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
* @see #bridge()
*/
public <P> IntegrationFlow logAndReply(Function<Message<P>, Object> function) {
Assert.notNull(function, "'function' must not be null");
Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL);
return logAndReply(new FunctionExpression<>(function));
}
@@ -2757,7 +2763,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
public <P> IntegrationFlow logAndReply(LoggingHandler.Level level, String category,
Function<Message<P>, Object> function) {
Assert.notNull(function, "'function' must not be null");
Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL);
return logAndReply(level, category, new FunctionExpression<>(function));
}
@@ -2961,7 +2967,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
* @param <O> the output type.
* @return the current {@link IntegrationFlowDefinition}.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <I, O> B fluxTransform(Function<? super Flux<Message<I>>, ? extends Publisher<O>> fluxFunction) {
if (!(this.currentMessageChannel instanceof FluxMessageChannel)) {
channel(new FluxMessageChannel());
@@ -2984,7 +2990,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
* @param <T> the expected {@code payload} type
* @return the Reactive Streams {@link Publisher}
*/
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
public <T> Publisher<Message<T>> toReactivePublisher() {
MessageChannel channelForPublisher = this.currentMessageChannel;
Publisher<Message<T>> publisher;
@@ -3022,7 +3028,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
.get();
}
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
private <S extends ConsumerEndpointSpec<S, ? extends MessageHandler>> B register(S endpointSpec,
Consumer<S> endpointConfigurer) {
@@ -3113,7 +3119,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
return false;
}
@SuppressWarnings("unchecked")
@SuppressWarnings(UNCHECKED)
protected final B _this() { // NOSONAR name
return (B) this;
}

View File

@@ -52,6 +52,9 @@ public final class MessageHistory implements List<Properties>, Serializable {
private static final Log logger = LogFactory.getLog(MessageHistory.class);
private static final UnsupportedOperationException UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE =
new UnsupportedOperationException("MessageHistory is immutable.");
public static final String HEADER_NAME = "history";
public static final String NAME_PROPERTY = "name";
@@ -215,52 +218,52 @@ public final class MessageHistory implements List<Properties>, Serializable {
@Override
public boolean add(Properties e) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public void add(int index, Properties element) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public boolean addAll(Collection<? extends Properties> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public boolean addAll(int index, Collection<? extends Properties> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public Properties set(int index, Properties element) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public Properties remove(int index) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public boolean remove(Object o) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}
@Override
public void clear() {
throw new UnsupportedOperationException("MessageHistory is immutable.");
throw UNSUPPORTED_OPERATION_EXCEPTION_IMMUTABLE;
}

View File

@@ -55,6 +55,8 @@ import org.springframework.util.DefaultPropertiesPersister;
public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStore, InitializingBean, DisposableBean,
Closeable, Flushable {
private static final String KEY_CANNOT_BE_NULL = "'key' cannot be null";
private final Log logger = LogFactory.getLog(getClass());
private final Properties metadata = new Properties();
@@ -111,7 +113,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
@Override
public void put(String key, String value) {
Assert.notNull(key, "'key' cannot be null");
Assert.notNull(key, KEY_CANNOT_BE_NULL);
Assert.notNull(value, "'value' cannot be null");
Lock lock = this.lockRegistry.obtain(key);
lock.lock();
@@ -126,7 +128,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
@Override
public String get(String key) {
Assert.notNull(key, "'key' cannot be null");
Assert.notNull(key, KEY_CANNOT_BE_NULL);
Lock lock = this.lockRegistry.obtain(key);
lock.lock();
try {
@@ -139,7 +141,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
@Override
public String remove(String key) {
Assert.notNull(key, "'key' cannot be null");
Assert.notNull(key, KEY_CANNOT_BE_NULL);
Lock lock = this.lockRegistry.obtain(key);
lock.lock();
try {
@@ -153,7 +155,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
@Override
public String putIfAbsent(String key, String value) {
Assert.notNull(key, "'key' cannot be null");
Assert.notNull(key, KEY_CANNOT_BE_NULL);
Assert.notNull(value, "'value' cannot be null");
Lock lock = this.lockRegistry.obtain(key);
lock.lock();
@@ -175,7 +177,7 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
@Override
public boolean replace(String key, String oldValue, String newValue) {
Assert.notNull(key, "'key' cannot be null");
Assert.notNull(key, KEY_CANNOT_BE_NULL);
Assert.notNull(oldValue, "'oldValue' cannot be null");
Assert.notNull(newValue, "'newValue' cannot be null");
Lock lock = this.lockRegistry.obtain(key);

View File

@@ -40,6 +40,8 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupStore implements MessageStore {
private static final String GROUP_ID_MUST_NOT_BE_NULL = "'groupId' must not be null";
protected static final String MESSAGE_KEY_PREFIX = "MESSAGE_";
protected static final String MESSAGE_GROUP_KEY_PREFIX = "MESSAGE_GROUP_";
@@ -193,7 +195,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
@Override
public MessageGroupMetadata getGroupMetadata(Object groupId) {
Assert.notNull(groupId, "'groupId' must not be null");
Assert.notNull(groupId, GROUP_ID_MUST_NOT_BE_NULL);
Object mgm = this.doRetrieve(this.groupPrefix + groupId);
if (mgm != null) {
Assert.isInstanceOf(MessageGroupMetadata.class, mgm);
@@ -204,7 +206,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
@Override
public void addMessagesToGroup(Object groupId, Message<?>... messages) {
Assert.notNull(groupId, "'groupId' must not be null");
Assert.notNull(groupId, GROUP_ID_MUST_NOT_BE_NULL);
Assert.notNull(messages, "'messages' must not be null");
MessageGroupMetadata metadata = getGroupMetadata(groupId);
@@ -239,7 +241,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
@Override
public void removeMessagesFromGroup(Object groupId, Collection<Message<?>> messages) {
Assert.notNull(groupId, "'groupId' must not be null");
Assert.notNull(groupId, GROUP_ID_MUST_NOT_BE_NULL);
Assert.notNull(messages, "'messages' must not be null");
Object mgm = doRetrieve(this.groupPrefix + groupId);
@@ -268,7 +270,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
@Override
public void completeGroup(Object groupId) {
Assert.notNull(groupId, "'groupId' must not be null");
Assert.notNull(groupId, GROUP_ID_MUST_NOT_BE_NULL);
MessageGroupMetadata metadata = getGroupMetadata(groupId);
if (metadata != null) {
metadata.complete();
@@ -282,7 +284,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
*/
@Override
public void removeMessageGroup(Object groupId) {
Assert.notNull(groupId, "'groupId' must not be null");
Assert.notNull(groupId, GROUP_ID_MUST_NOT_BE_NULL);
Object mgm = doRemove(this.groupPrefix + groupId);
if (mgm != null) {
Assert.isInstanceOf(MessageGroupMetadata.class, mgm);
@@ -300,7 +302,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
@Override
public void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber) {
Assert.notNull(groupId, "'groupId' must not be null");
Assert.notNull(groupId, GROUP_ID_MUST_NOT_BE_NULL);
MessageGroupMetadata metadata = getGroupMetadata(groupId);
if (metadata == null) {
SimpleMessageGroup messageGroup = new SimpleMessageGroup(groupId);

View File

@@ -50,6 +50,12 @@ import org.springframework.util.CollectionUtils;
public class SimpleMessageStore extends AbstractMessageGroupStore
implements MessageStore, ChannelMessageStore {
private static final String MESSAGE_GROUP_FOR_GROUP_ID = "MessageGroup for groupId '";
private static final String UPPER_BOUND_MUST_NOT_BE_NULL = "'upperBound' must not be null.";
private static final String INTERRUPTED_WHILE_OBTAINING_LOCK = "Interrupted while obtaining lock";
private final ConcurrentMap<UUID, Message<?>> idToMessage = new ConcurrentHashMap<UUID, Message<?>>();
private final ConcurrentMap<Object, MessageGroup> groupIdToMessageGroup =
@@ -256,7 +262,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MessagingException("Interrupted while obtaining lock", e);
throw new MessagingException(INTERRUPTED_WHILE_OBTAINING_LOCK, e);
}
}
@@ -291,7 +297,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
else {
upperBound = this.groupToUpperBound.get(groupId);
Assert.state(upperBound != null, "'upperBound' must not be null.");
Assert.state(upperBound != null, UPPER_BOUND_MUST_NOT_BE_NULL);
for (Message<?> message : messages) {
lock.unlock();
if (!upperBound.tryAcquire(this.upperBoundTimeout)) {
@@ -313,7 +319,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MessagingException("Interrupted while obtaining lock", e);
throw new MessagingException(INTERRUPTED_WHILE_OBTAINING_LOCK, e);
}
}
@@ -326,7 +332,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
MessageGroup messageGroup = this.groupIdToMessageGroup.remove(groupId);
if (messageGroup != null) {
UpperBound upperBound = this.groupToUpperBound.remove(groupId);
Assert.state(upperBound != null, "'upperBound' must not be null.");
Assert.state(upperBound != null, UPPER_BOUND_MUST_NOT_BE_NULL);
upperBound.release(this.groupCapacity);
}
}
@@ -336,7 +342,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MessagingException("Interrupted while obtaining lock", e);
throw new MessagingException(INTERRUPTED_WHILE_OBTAINING_LOCK, e);
}
}
@@ -347,10 +353,10 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
lock.lockInterruptibly();
try {
MessageGroup group = this.groupIdToMessageGroup.get(groupId);
Assert.notNull(group, "MessageGroup for groupId '" + groupId + "' " +
Assert.notNull(group, MESSAGE_GROUP_FOR_GROUP_ID + groupId + "' " +
"can not be located while attempting to remove Message(s) from the MessageGroup");
UpperBound upperBound = this.groupToUpperBound.get(groupId);
Assert.state(upperBound != null, "'upperBound' must not be null.");
Assert.state(upperBound != null, UPPER_BOUND_MUST_NOT_BE_NULL);
boolean modified = false;
for (Message<?> messageToRemove : messages) {
if (group.remove(messageToRemove)) {
@@ -368,7 +374,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MessagingException("Interrupted while obtaining lock", e);
throw new MessagingException(INTERRUPTED_WHILE_OBTAINING_LOCK, e);
}
}
@@ -384,7 +390,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
lock.lockInterruptibly();
try {
MessageGroup group = this.groupIdToMessageGroup.get(groupId);
Assert.notNull(group, "MessageGroup for groupId '" + groupId + "' " +
Assert.notNull(group, MESSAGE_GROUP_FOR_GROUP_ID + groupId + "' " +
"can not be located while attempting to set 'lastReleasedSequenceNumber'");
group.setLastReleasedMessageSequenceNumber(sequenceNumber);
group.setLastModified(System.currentTimeMillis());
@@ -395,7 +401,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MessagingException("Interrupted while obtaining lock", e);
throw new MessagingException(INTERRUPTED_WHILE_OBTAINING_LOCK, e);
}
}
@@ -406,7 +412,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
lock.lockInterruptibly();
try {
MessageGroup group = this.groupIdToMessageGroup.get(groupId);
Assert.notNull(group, "MessageGroup for groupId '" + groupId + "' " +
Assert.notNull(group, MESSAGE_GROUP_FOR_GROUP_ID + groupId + "' " +
"can not be located while attempting to complete the MessageGroup");
group.complete();
group.setLastModified(System.currentTimeMillis());
@@ -417,7 +423,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MessagingException("Interrupted while obtaining lock", e);
throw new MessagingException(INTERRUPTED_WHILE_OBTAINING_LOCK, e);
}
}
@@ -460,12 +466,12 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
lock.lockInterruptibly();
try {
MessageGroup group = this.groupIdToMessageGroup.get(groupId);
Assert.notNull(group, "MessageGroup for groupId '" + groupId + "' " +
Assert.notNull(group, MESSAGE_GROUP_FOR_GROUP_ID + groupId + "' " +
"can not be located while attempting to complete the MessageGroup");
group.clear();
group.setLastModified(System.currentTimeMillis());
UpperBound upperBound = this.groupToUpperBound.get(groupId);
Assert.state(upperBound != null, "'upperBound' must not be null.");
Assert.state(upperBound != null, UPPER_BOUND_MUST_NOT_BE_NULL);
upperBound.release(this.groupCapacity);
}
finally {
@@ -474,7 +480,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new MessagingException("Interrupted while obtaining lock", e);
throw new MessagingException(INTERRUPTED_WHILE_OBTAINING_LOCK, e);
}
}

View File

@@ -59,6 +59,8 @@ import org.springframework.util.MultiValueMap;
public class SmartLifecycleRoleController implements ApplicationListener<AbstractLeaderEvent>,
ApplicationContextAware {
private static final String IN_ROLE = " in role ";
private static final Log logger = LogFactory.getLog(SmartLifecycleRoleController.class);
private final MultiValueMap<String, SmartLifecycle> lifecycles = new LinkedMultiValueMap<String, SmartLifecycle>();
@@ -162,7 +164,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
componentsInRole = new ArrayList<>(componentsInRole);
componentsInRole.sort(Comparator.comparingInt(Phased::getPhase));
if (logger.isDebugEnabled()) {
logger.debug("Starting " + componentsInRole + " in role " + role);
logger.debug("Starting " + componentsInRole + IN_ROLE + role);
}
componentsInRole.forEach(lifecycle -> {
@@ -170,7 +172,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
lifecycle.start();
}
catch (Exception e) {
logger.error("Failed to start " + lifecycle + " in role " + role, e);
logger.error("Failed to start " + lifecycle + IN_ROLE + role, e);
}
});
}
@@ -194,7 +196,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
componentsInRole = new ArrayList<>(componentsInRole);
componentsInRole.sort((o1, o2) -> Integer.compare(o2.getPhase(), o1.getPhase()));
if (logger.isDebugEnabled()) {
logger.debug("Stopping " + componentsInRole + " in role " + role);
logger.debug("Stopping " + componentsInRole + IN_ROLE + role);
}
componentsInRole.forEach(lifecycle -> {
@@ -202,7 +204,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
lifecycle.stop();
}
catch (Exception e) {
logger.error("Failed to stop " + lifecycle + " in role " + role, e);
logger.error("Failed to stop " + lifecycle + IN_ROLE + role, e);
}
});
}

View File

@@ -43,6 +43,9 @@ import org.springframework.util.StringUtils;
public class TransactionSynchronizationFactoryBean implements FactoryBean<DefaultTransactionSynchronizationFactory>,
BeanFactoryAware {
private static final String EXPRESSION_OR_CHANNEL_NEEDED =
"At least one attribute ('expression' and/or 'messageChannel') must be defined";
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
private final AtomicInteger counter = new AtomicInteger();
@@ -77,13 +80,13 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
/**
* Specify the {@link DestinationResolver} strategy to use.
* The default is a BeanFactoryChannelResolver.
* @param channelResolver The channel resolver.
* @param resolver The channel resolver.
* @return current TransactionSynchronizationFactoryBean
* @since 4.1.3
*/
public TransactionSynchronizationFactoryBean channelResolver(DestinationResolver<MessageChannel> channelResolver) {
Assert.notNull(channelResolver, "'channelResolver' must not be null");
this.channelResolver = channelResolver;
public TransactionSynchronizationFactoryBean channelResolver(DestinationResolver<MessageChannel> resolver) {
Assert.notNull(resolver, "'channelResolver' must not be null");
this.channelResolver = resolver;
return this;
}
@@ -94,7 +97,7 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
public TransactionSynchronizationFactoryBean beforeCommit(String expression, String messageChannel) {
Assert.state(StringUtils.hasText(expression) || StringUtils.hasText(messageChannel),
"At least one attribute ('expression' and/or 'messageChannel') must be defined");
EXPRESSION_OR_CHANNEL_NEEDED);
this.beforeCommitExpression = expression;
this.beforeCommitChannelName = messageChannel;
this.beforeCommitChannel = null;
@@ -107,7 +110,7 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
public TransactionSynchronizationFactoryBean beforeCommit(String expression, MessageChannel messageChannel) {
Assert.state(StringUtils.hasText(expression) || messageChannel != null,
"At least one attribute ('expression' and/or 'messageChannel') must be defined");
EXPRESSION_OR_CHANNEL_NEEDED);
this.beforeCommitExpression = expression;
this.beforeCommitChannel = messageChannel;
this.beforeCommitChannelName = null;
@@ -120,7 +123,7 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
public TransactionSynchronizationFactoryBean afterCommit(String expression, String messageChannel) {
Assert.state(StringUtils.hasText(expression) || StringUtils.hasText(messageChannel),
"At least one attribute ('expression' and/or 'messageChannel') must be defined");
EXPRESSION_OR_CHANNEL_NEEDED);
this.afterCommitExpression = expression;
this.afterCommitChannelName = messageChannel;
this.afterCommitChannel = null;
@@ -133,7 +136,7 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
public TransactionSynchronizationFactoryBean afterCommit(String expression, MessageChannel messageChannel) {
Assert.state(StringUtils.hasText(expression) || messageChannel != null,
"At least one attribute ('expression' and/or 'messageChannel') must be defined");
EXPRESSION_OR_CHANNEL_NEEDED);
this.afterCommitExpression = expression;
this.afterCommitChannel = messageChannel;
this.afterCommitChannelName = null;
@@ -146,7 +149,7 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
public TransactionSynchronizationFactoryBean afterRollback(String expression, String messageChannel) {
Assert.state(StringUtils.hasText(expression) || StringUtils.hasText(messageChannel),
"At least one attribute ('expression' and/or 'messageChannel') must be defined");
EXPRESSION_OR_CHANNEL_NEEDED);
this.afterRollbackExpression = expression;
this.afterRollbackChannelName = messageChannel;
this.afterRollbackChannel = null;
@@ -159,7 +162,7 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
public TransactionSynchronizationFactoryBean afterRollback(String expression, MessageChannel messageChannel) {
Assert.state(StringUtils.hasText(expression) || messageChannel != null,
"At least one attribute ('expression' and/or 'messageChannel') must be defined");
EXPRESSION_OR_CHANNEL_NEEDED);
this.afterRollbackExpression = expression;
this.afterRollbackChannel = messageChannel;
this.afterRollbackChannelName = null;