INT-2935: Improve Event Inbound Adapter
Previously, the `ApplicationEventListeningMessageProducer` accepted
all `ApplicationEvent`'s and than filtered them.
This caused some `ApplicationEventMulticaster.retrieverCache` overhead.
* Improve `ApplicationEventListeningMessageProducer` to `implements SmartApplicationListener`.
This allows filtering earlier on first the appropriate `ApplicationEvent`
using `ApplicationEventListeningMessageProducer#supportsEventType`
and caching the `ApplicationListener` only for that `ApplicationEvent`.
* Re-register `ApplicationEventListeningMessageProducer` in the `ApplicationEventMulticaster`
when `ApplicationEventListeningMessageProducer#setEventTypes` is invoked
to clear the `ApplicationEventMulticaster.retrieverCache`.
* Move `org.springframework.integration.gemfire.inbound.SpelMessageProducerSupport` to core `ExpressionMessageProducerSupport`.
* Add test for the new logic int `ApplicationEventListeningMessageProducer` and its behavior with respect to the `ApplicationEventMulticaster.retrieverCache`.
JIRA: https://jira.springsource.org/browse/INT-2935
INT-2935: EMPS JavaDoc & AELMP ReadWriteLock
INT-2935: AELMP#eventTypes changing 'barrier'
INT-2935: avoid 'eventTypes' mutation afterwards
INT-2935: Polishing according PR comments
INT-2935: Fix NPE in the `setEventTypes`
Minor Polishing
Polish java docs/comments
Remove compiler warnings
This commit is contained in:
committed by
Gary Russell
parent
515d78f8ee
commit
116f4934c1
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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. You may obtain a copy of the License at
|
||||
*
|
||||
* 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration.endpoint;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
|
||||
/**
|
||||
* A {@link MessageProducerSupport} sub-class that provides {@linkplain #payloadExpression}
|
||||
* evaluation with result as a payload for Message to send.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
* @since 2.1
|
||||
*
|
||||
*/
|
||||
public abstract class ExpressionMessageProducerSupport extends MessageProducerSupport {
|
||||
|
||||
private final SpelExpressionParser parser = new SpelExpressionParser();
|
||||
|
||||
private volatile Expression payloadExpression;
|
||||
|
||||
public void setPayloadExpression(String payloadExpression) {
|
||||
if (payloadExpression == null) {
|
||||
this.payloadExpression = null;
|
||||
}
|
||||
else {
|
||||
this.payloadExpression = this.parser.parseExpression(payloadExpression);
|
||||
}
|
||||
}
|
||||
|
||||
protected Object evaluatePayloadExpression(Object payload){
|
||||
Object evaluationResult = payload;
|
||||
if (payloadExpression != null) {
|
||||
evaluationResult = payloadExpression.getValue(payload);
|
||||
}
|
||||
return evaluationResult;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user