INT-1627 removed 'beanResolver' property from ExpressionControlBusFactoryBean

This commit is contained in:
Mark Fisher
2010-11-18 15:37:09 -05:00
parent f549ccbdd9
commit a46583d464
4 changed files with 8 additions and 118 deletions

View File

@@ -20,7 +20,6 @@ import java.util.List;
import org.springframework.context.Lifecycle;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.expression.BeanResolver;
import org.springframework.expression.MethodFilter;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.handler.ExpressionCommandMessageProcessor;
@@ -40,8 +39,6 @@ public class ExpressionControlBusFactoryBean extends AbstractSimpleMessageHandle
private volatile Long sendTimeout;
private volatile BeanResolver beanResolver;
private final MethodFilter methodFilter = new ControlBusMethodFilter();
@@ -49,16 +46,9 @@ public class ExpressionControlBusFactoryBean extends AbstractSimpleMessageHandle
this.sendTimeout = sendTimeout;
}
public void setBeanResolver(BeanResolver beanResolver) {
this.beanResolver = beanResolver;
}
protected MessageHandler createHandler() {
ExpressionCommandMessageProcessor processor = new ExpressionCommandMessageProcessor(this.methodFilter);
processor.setBeanFactory(this.getBeanFactory());
if (this.beanResolver != null) {
processor.setBeanResolver(this.beanResolver);
}
ServiceActivatingHandler handler = new ServiceActivatingHandler(processor);
if (this.sendTimeout != null) {
handler.setSendTimeout(this.sendTimeout);

View File

@@ -2781,30 +2781,20 @@ The list of component name patterns you want to track (e.g., tracked-components
<xsd:element name="control-bus">
<xsd:annotation>
<xsd:documentation>
<xsd:documentation><![CDATA[
Control bus that accepts messages in the form of SpEL expressions. The expressions should be provided
either as Expression or String payloads (that can be parsed into valid Expressions). in incoming messages.
The expressions can refer to beans in the context using the standard @beanName convention.
</xsd:documentation>
either as Expression or String payloads (that can be parsed into valid Expressions) in incoming messages.
The expressions can refer to beans in the context using the standard @beanName convention. The methods
that will be available include:
1) any that are annotated with @ManagedAttribute or @ManagedOperation
2) Lifecycle methods
3) get/set or shutdown methods on configurable TaskExecutors or TaskSchedulers
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:all minOccurs="0" maxOccurs="1">
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
</xsd:all>
<xsd:attribute name="bean-resolver" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.expression.BeanResolver" />
</tool:annotation>
</xsd:appinfo>
<xsd:documentation>
A refeerence to a bean in this Application Context that
impements BeanResolver that can be registered with SpEL evaluation context
to resolve <code>@myBeanName</code> still expressions[OPTIONAL].
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attributeGroup ref="inputOutputChannelGroup" />
</xsd:complexType>
</xsd:element>

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:groovy="http://www.springframework.org/schema/integration/groovy"
xsi:schemaLocation="http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<channel id="output">
<queue/>
</channel>
<control-bus input-channel="input" output-channel="output" bean-resolver="beanResolver"/>
<beans:bean id="beanResolver" class="org.springframework.integration.config.xml.ControlBusBeanResolverTests$TestBeanResolver" />
</beans:beans>

View File

@@ -1,73 +0,0 @@
/*
* Copyright 2002-2010 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.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.AccessException;
import org.springframework.expression.BeanResolver;
import org.springframework.expression.EvaluationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Dave Syer
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class ControlBusBeanResolverTests {
@Autowired
private MessageChannel input;
@Autowired
private PollableChannel output;
@Test
public void testDefaultEvaluationContext() {
Message<?> message = MessageBuilder.withPayload("@service.convert('aardvark')+headers.foo").setHeader("foo", "bar").build();
this.input.send(message);
assertEquals("catbar", output.receive(0).getPayload());
assertNull(output.receive(0));
}
public static class TestBeanResolver implements BeanResolver {
public Object resolve(EvaluationContext context, String beanName) throws AccessException {
return new Service();
}
}
public static class Service {
@ManagedOperation
public String convert(String input) {
return "cat";
}
}
}