#9 - Removed Spring Integration integration module.

This commit is contained in:
Oliver Gierke
2014-05-01 19:11:00 +02:00
parent 4ce00cc87d
commit 5c962ba287
18 changed files with 3 additions and 929 deletions

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
</parent>
<artifactId>spring-plugin-integration</artifactId>
<name>Spring Plugin - Spring Integration integration</name>
<properties>
<spring.integration.version>2.1.4.RELEASE</spring.integration.version>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>${spring.integration.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,295 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.GenericTypeResolver;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.expression.Expression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.Plugin;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
/**
* Dynamic service activator that uses a {@link PluginRegistry} to delegate execution to one or more plugins matching a
* delimiter.
*
* @author Oliver Gierke
*/
public class PluginRegistryAwareMessageHandler extends AbstractReplyProducingMessageHandler {
private static final Log LOG = LogFactory.getLog(PluginRegistryAwareMessageHandler.class);
private final PluginRegistry<? extends Plugin<?>, Object> registry;
private final Class<? extends Plugin<?>> pluginType;
private final Class<?> delimiterType;
private final SpelExpressionParser parser = new SpelExpressionParser();
private Expression delimiterExpression;
private Expression invocationArgumentsExpression;
private String serviceMethodName;
private PluginLookupMethod pluginLookupMethod = PluginLookupMethod.getDefault();
/**
* Creates a new {@link PluginRegistryAwareMessageHandler} for the given {@link PluginRegistry}, pluginType and a
* method name to call.
*
* @param registry
* @param pluginType
* @param serviceMethodName
*/
@SuppressWarnings("unchecked")
public PluginRegistryAwareMessageHandler(PluginRegistry<? extends Plugin<?>, ?> registry,
Class<? extends Plugin<?>> pluginType, String serviceMethodName) {
Assert.notNull(registry);
Assert.notNull(pluginType);
Assert.hasText(serviceMethodName);
this.registry = (PluginRegistry<? extends Plugin<?>, Object>) registry;
this.serviceMethodName = serviceMethodName;
this.pluginType = pluginType;
this.delimiterType = GenericTypeResolver.resolveTypeArgument(pluginType, Plugin.class);
verify();
}
private final void verify() {
boolean methodFound = false;
for (Method candidate : pluginType.getMethods()) {
if (candidate.getName().equals(serviceMethodName)) {
methodFound = true;
break;
}
}
if (!methodFound) {
throw new IllegalArgumentException(String.format("Not method %s found for type %s!", serviceMethodName,
pluginType));
}
}
/**
* Sets the SpEL expression to extract the delimiter from the {@link Message}.
*
* @param delimiterExpression the delimiterExpression to set
*/
public void setDelimiterExpression(String expression) {
Assert.hasText(expression);
this.delimiterExpression = parser.parseExpression(expression);
}
/**
* Sets the SpEL expression to extract the method arguments for the actual plugin method invocation from the
* {@link Message}.
*
* @param invocationArgumentsExpression the invocationArgumentsExpression to set
*/
public void setInvocationArgumentsExpression(String expression) {
Assert.hasText(expression);
this.invocationArgumentsExpression = parser.parseExpression(expression);
}
/**
* Configures the method to be used when looking up plugins to invoke.
*
* @see PluginLookupMethod
* @param pluginLookupMethod the invocationMethod to set
*/
public void setPluginLookupMethod(PluginLookupMethod pluginLookupMethod) {
this.pluginLookupMethod = pluginLookupMethod == null ? PluginLookupMethod.getDefault() : pluginLookupMethod;
}
/*
* (non-Javadoc)
*
* @see
* org.springframework.integration.handler.AbstractReplyProducingMessageHandler
* #handleRequestMessage(org.springframework.integration.Message)
*/
@SuppressWarnings("unchecked")
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
Object delimiter = getDelimiter(requestMessage);
switch (pluginLookupMethod) {
case ALL:
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Looking up plugins for delimiter %s", delimiter));
}
return invokePlugins(registry.getPluginsFor(delimiter), requestMessage);
case ONE:
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Looking up plugin for delimiter %s", delimiter));
}
List<Object> results = invokePlugins(Arrays.asList(registry.getPluginFor(delimiter)), requestMessage);
return results.isEmpty() ? null : results.get(0);
default:
throw new IllegalStateException(String.format("Unsupported plugin lookup method %s!", pluginLookupMethod));
}
}
private List<Object> invokePlugins(Collection<? extends Plugin<?>> plugins, Message<?> message) {
List<Object> results = new ArrayList<Object>();
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Invoking plugin(s) %s with message %s",
StringUtils.collectionToCommaDelimitedString(plugins), message));
}
for (Plugin<?> plugin : plugins) {
Object[] invocationArguments = getInvocationArguments(message);
Class<?>[] types = getTypes(invocationArguments);
Method businessMethod = ReflectionUtils.findMethod(pluginType, serviceMethodName, types);
if (businessMethod == null) {
throw new MessageHandlingException(message, String.format(
"Did not find a method %s on %s taking the following parameters %s", serviceMethodName,
pluginType.getName(), Arrays.toString(types)));
}
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Invoke plugin method %s using arguments %s", businessMethod,
Arrays.toString(invocationArguments)));
}
Object result = ReflectionUtils.invokeMethod(businessMethod, plugin, invocationArguments);
if (!businessMethod.getReturnType().equals(void.class)) {
results.add(result);
}
}
return results;
}
/**
* Returns the delimiter object to be used for the given {@link Message}. Will use the configured delimiter expression
* if configured.
*
* @param message
* @return
*/
private Object getDelimiter(Message<?> message) {
Object delimiter = message;
if (delimiterExpression != null) {
StandardEvaluationContext context = new StandardEvaluationContext(message);
delimiter = delimiterExpression.getValue(context);
}
Assert.isInstanceOf(delimiterType, delimiter, String.format("Delimiter expression did "
+ "not return a suitable delimiter! Make sure the expression evaluates to a suitable "
+ "type! Got %s but need %s", delimiter.getClass(), delimiterType));
return delimiter;
}
/**
* Returns the actual arguments to be used for the plugin method invocation. Will apply the configured invocation
* argument expression to the given {@link Message}.
*
* @param message
* @return
*/
private Object[] getInvocationArguments(Message<?> message) {
if (invocationArgumentsExpression == null) {
return new Object[] { message };
}
StandardEvaluationContext context = new StandardEvaluationContext(message);
Object result = delimiterExpression.getValue(context);
return ObjectUtils.isArray(result) ? ObjectUtils.toObjectArray(result) : new Object[] { result };
}
/**
* Returns an array of types for the given objects. Inspects each element of the array for its type. will return
* {@literal null} for {@literal null} source values.
*
* @param source
* @return
*/
private Class<?>[] getTypes(Object[] source) {
Class<?>[] result = new Class<?>[source.length];
for (int i = 0; i < source.length; i++) {
Object sourceElement = source[i];
result[i] = sourceElement == null ? null : sourceElement.getClass();
}
return result;
}
/**
* Lookup methods for plugins.
*
* @author Oliver Gierke
*/
private enum PluginLookupMethod {
/**
* The first plugin supporting a given delimiter found will be invoked.
*/
ONE,
/**
* All plugins supporting a given delimiter will be invoked. Plugin order will be considered.
*
* @see OrderAwarePluginRegistry
* @see Order
* @see Ordered
*/
ALL;
/**
* Returns the default {@link PluginLookupMethod}.
*
* @return
*/
static PluginLookupMethod getDefault() {
return ONE;
}
}
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration.config;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractConsumerEndpointParser;
import org.springframework.plugin.core.support.PluginRegistryFactoryBean;
import org.springframework.plugin.integration.PluginRegistryAwareMessageHandler;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
/**
* {@link BeanDefinitionParser} to create {@link PluginRegistryAwareMessageHandler} beans.
*
* @author Oliver Gierke
*/
public class DynamicServiceActivatorParser extends AbstractConsumerEndpointParser {
/*
* (non-Javadoc)
* @see org.springframework.integration.config.xml.AbstractConsumerEndpointParser#parseHandler(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
*/
@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);
String pluginType = element.getAttribute("plugin-type");
String method = element.getAttribute("method");
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(PluginRegistryAwareMessageHandler.class);
builder.addConstructorArgValue(getRegistryBeanDefinition(pluginType, source));
builder.addConstructorArgValue(pluginType);
builder.addConstructorArgValue(method);
String delimiter = element.getAttribute("delimiter");
if (StringUtils.hasText(delimiter)) {
builder.addPropertyValue("delimiterExpression", delimiter);
}
String invocationArguments = element.getAttribute("invocation-arguments");
if (StringUtils.hasText(invocationArguments)) {
builder.addPropertyValue("invocationArgumentsExpression", invocationArguments);
}
AbstractBeanDefinition definition = builder.getBeanDefinition();
definition.setSource(source);
return builder;
}
/**
* Creates a {@link BeanDefinition} for a {@link PluginRegistryFactoryBean}.
*
* @param pluginType
* @param source
* @return
*/
private AbstractBeanDefinition getRegistryBeanDefinition(String pluginType, Object source) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(PluginRegistryFactoryBean.class);
builder.addPropertyValue("type", pluginType);
AbstractBeanDefinition definition = builder.getBeanDefinition();
definition.setSource(source);
return definition;
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration.config;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.NamespaceHandler;
import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler;
/**
* {@link NamespaceHandler} to register {@link BeanDefinitionParser}s.
*
* @author Oliver Gierke
*/
public class SpringPluginSpringIntegrationNamespaceHandler extends AbstractIntegrationNamespaceHandler {
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.xml.NamespaceHandler#init()
*/
public void init() {
registerBeanDefinitionParser("dynamic-service-activator", new DynamicServiceActivatorParser());
}
}

View File

@@ -1 +0,0 @@
http\://www.springframework.org/schema/plugin/integration=org.springframework.plugin.integration.config.SpringPluginSpringIntegrationNamespaceHandler

View File

@@ -1 +0,0 @@
http\://www.springframework.org/schema/plugin/integration/spring-plugin-integration.xsd=org/springframework/plugin/integration/config/spring-plugin-integration.xsd

View File

@@ -1,4 +0,0 @@
# Tooling related information for the Spring Plugin Integration namespace
http\://www.springframework.org/schema/plugin/integration@name=Spring Plugin Spring Integration Namespace
http\://www.springframework.org/schema/plugin/integration@prefix=int-plugin
http\://www.springframework.org/schema/plugin/integration@icon=org/springframework/beans/factory/xml/spring-beans.gif

View File

@@ -1,90 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns="http://www.springframework.org/schema/plugin/integration" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
targetNamespace="http://www.springframework.org/schema/plugin/integration" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/tool" />
<xsd:element name="dynamic-service-activator">
<xsd:annotation>
<xsd:appinfo>
<xsd:documentation>
This service activator will be backed by a Hera Plugin registry that
allows dynamic invocation of Spring beans implementing the plugin
interface defined in "plugin-type". We will dynamically pick up all
Spring beans implementing that interface and create a PluginRegistry
of those. See org.springframework.plugin.integration.PluginRegistryAwareMessageHandler for
details.
</xsd:documentation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="input-channel" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>The input channel to listen to.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="plugin-type" type="classType" use="required">
<xsd:annotation>
<xsd:documentation>The type of Spring beans to dynamically pick up.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="method" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>The method to be invoked on the plugin(s) selected.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="output-channel" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The output channel to publish invocation results to.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="delimiter" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
A SpEL expression to extract the delimiter to be used from the
incoming Message. If not set the entire Message will be used as
delimiter.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="invocation-arguments" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
A SpEL expression to extract the arguments for the actual method
invocation.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="plugin-lookup-method" type="pluginLookupMethod" default="one">
<xsd:annotation>
<xsd:documentation>
Defines whether to invoke the first plugin matching the delimiter
(default) or all found. Order of the plugins will be considered.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="pluginLookupMethod">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="one" />
<xsd:enumeration value="all" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="classType">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="direct">
<tool:expected-type type="java.lang.Class" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string" />
</xsd:simpleType>
</xsd:schema>

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.plugin.integration.PluginRegistryAwareMessageHandler;
import org.springframework.plugin.integration.sample.FirstSamplePluginImpl;
import org.springframework.plugin.integration.sample.SamplePlugin;
import org.springframework.plugin.integration.sample.SecondSamplePluginImpl;
/**
* Unit tests for {@link PluginRegistryAwareMessageHandler}.
*
* @author Oliver Gierke
*/
@RunWith(MockitoJUnitRunner.class)
public class PluginRegistryAwareMessageHandlerUnitTest {
PluginRegistry<SamplePlugin, String> registry;
PluginRegistryAwareMessageHandler handler;
@Mock
MessageChannel outputChannel;
@Before
public void setUp() {
registry = OrderAwarePluginRegistry
.create(Arrays.asList(new FirstSamplePluginImpl(), new SecondSamplePluginImpl()));
handler = new PluginRegistryAwareMessageHandler(registry, SamplePlugin.class, "myBusinessMethod");
handler.setOutputChannel(outputChannel);
}
@Test
@SuppressWarnings("rawtypes")
public void routesInvocationToFirstpluginIfConfiguredToDoSo() {
handler.setDelimiterExpression("payload");
handler.setInvocationArgumentsExpression("payload");
handler.afterPropertiesSet();
Message<String> message = MessageBuilder.withPayload("FOO").build();
when(outputChannel.send(Mockito.any(Message.class))).thenReturn(true);
handler.handleMessage(message);
ArgumentCaptor<Message> resultMessage = ArgumentCaptor.forClass(Message.class);
verify(outputChannel).send(resultMessage.capture());
assertThat(resultMessage.getValue().getPayload().toString(), is("First"));
}
@Test(expected = MessageHandlingException.class)
public void failsHandlingMessageIfDelimiterTypeDoesNotMatch() {
Message<String> message = MessageBuilder.withPayload("FOO").build();
handler.handleMessage(message);
}
@Test(expected = IllegalArgumentException.class)
public void rejectsInvalidMethodName() {
new PluginRegistryAwareMessageHandler(registry, SamplePlugin.class, "foo");
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.handler.LoggingHandler;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Integration test for the namespace.
*
* @author Oliver Gierke
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:dynamic-service-activator-test-context.xml")
public class DynamicServiceActivatorNamespaceIntegrationTest {
@Autowired
@Qualifier("sampleChannel")
MessageChannel channel;
@Autowired
@Qualifier("foo")
SubscribableChannel sink;
@Test
public void invokesPluginBasedOnPayload() {
sink.subscribe(new LoggingHandler("DEBUG"));
Message<String> message = MessageBuilder.withPayload("FOO").build();
channel.send(message);
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration.sample;
/**
* @author Oliver Gierke
*/
public class FirstSamplePluginImpl implements SamplePlugin {
/*
* (non-Javadoc)
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
*/
public boolean supports(String delimiter) {
return "FOO".equals(delimiter);
}
/*
* (non-Javadoc)
* @see org.springframework.plugin.integration.sample.SamplePlugin#myBusinessMethod()
*/
public String myBusinessMethod(String message) {
System.out.println("First plugin invoked! " + message);
return "First";
}
}

View File

@@ -1,26 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration.sample;
import org.springframework.plugin.core.Plugin;
/**
* @author Oliver Gierke
*/
public interface SamplePlugin extends Plugin<String> {
String myBusinessMethod(String message);
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration.sample;
import org.springframework.core.annotation.Order;
/**
* Sample implementation of {@link SamplePlugin} supporting {@code BAR} delimiter.
*
* @author Oliver Gierke
*/
@Order(10)
public class SecondSamplePluginImpl implements SamplePlugin {
/*
* (non-Javadoc)
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
*/
public boolean supports(String delimiter) {
return "BAR".equals(delimiter);
}
/*
* (non-Javadoc)
* @see org.springframework.plugin.integration.sample.SamplePlugin#myBusinessMethod()
*/
public String myBusinessMethod(String message) {
System.out.println("Second plugin invoked! " + message);
return "Second";
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright 2011-2012 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.plugin.integration.sample;
import org.springframework.core.annotation.Order;
/**
* Third sample implementation of {@link SamplePlugin} also supporting {@code BAR) but with lower precendence.
*
* @author Oliver Gierke
*/
@Order(20)
class ThirdSamplePluginImpl implements SamplePlugin {
/*
* (non-Javadoc)
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
*/
public boolean supports(String delimiter) {
return "BAR".equals(delimiter);
}
/*
* (non-Javadoc)
* @see org.springframework.plugin.integration.sample.SamplePlugin#myBusinessMethod()
*/
public String myBusinessMethod(String message) {
System.out.println("Second plugin invoked! " + message);
return "Third";
}
}

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-plugin="http://www.springframework.org/schema/plugin/integration"
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
http://www.springframework.org/schema/plugin/integration http://www.springframework.org/schema/plugin/integration/spring-plugin-integration.xsd">
<bean class="org.springframework.plugin.integration.sample.FirstSamplePluginImpl" />
<bean class="org.springframework.plugin.integration.sample.SecondSamplePluginImpl" />
<int-plugin:dynamic-service-activator
input-channel="sampleChannel"
output-channel="foo"
plugin-type="org.springframework.plugin.integration.sample.SamplePlugin"
method="myBusinessMethod"
delimiter="payload"
invocation-arguments="payload" />
<int:channel id="sampleChannel" />
<int:channel id="foo" />
</beans>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %5p %40.40c:%4L - %m%n</pattern>
</encoder>
</appender>
<!--
<logger name="org.springframework" level="debug" />
-->
<root level="warn">
<appender-ref ref="console" />
</root>
</configuration>

View File

@@ -1,14 +0,0 @@
Bundle-ManifestVersion: 2
Bundle-SymbolicName: ${project.artifactId}
Bundle-Name: ${project.name}
Bundle-Vendor: SpringSource, a division of VMware
Bundle-Version: ${project.version}
Bundle-RequiredExecutionEnvironment: J2SE-1.6
Export-Template:
org.springframework.plugin.integration.*;version="${project.version}"
Import-Template:
org.apache.commons.logging.*;version="[1.1.0,2.0.0)",
org.springframework.*;version="${spring.version:[=.=.=.=,+1.0.0)}",
org.springframework.integration.*;version="${spring.integration.version:[=.=.=.=,+1.0.0)}",
org.springframework.plugin.core.*;version="${project.version:[=.=.=.=,+1.0.0)}",
org.w3c.dom.*;version="0"

View File

@@ -41,7 +41,6 @@
<modules>
<module>core</module>
<module>metadata</module>
<module>integration</module>
</modules>
<properties>
@@ -63,7 +62,7 @@
<timezone>+1</timezone>
</developer>
</developers>
<dependencies>
<!-- Common test dependencies -->
@@ -79,7 +78,7 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
@@ -203,7 +202,7 @@
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-plugins-release</id>