From cde6f5e23e1858e15d4a36d533dc012fe59c6497 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Wed, 3 Sep 2008 04:38:24 +0000 Subject: [PATCH] Added Transformer strategy interface and TransformerEndpoint. --- .../integration/transformer/Transformer.java | 30 +++++++++++++ .../transformer/TransformerEndpoint.java | 42 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 org.springframework.integration/src/main/java/org/springframework/integration/transformer/Transformer.java create mode 100644 org.springframework.integration/src/main/java/org/springframework/integration/transformer/TransformerEndpoint.java diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/transformer/Transformer.java b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/Transformer.java new file mode 100644 index 0000000000..f1cfb65792 --- /dev/null +++ b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/Transformer.java @@ -0,0 +1,30 @@ +/* + * Copyright 2002-2008 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.transformer; + +import org.springframework.integration.message.Message; + +/** + * Strategy interface for transforming a {@link Message}. + * + * @author Mark Fisher + */ +public interface Transformer { + + Message transform(Message message); + +} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/transformer/TransformerEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/TransformerEndpoint.java new file mode 100644 index 0000000000..f8aa0529cd --- /dev/null +++ b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/TransformerEndpoint.java @@ -0,0 +1,42 @@ +/* + * Copyright 2002-2008 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.transformer; + +import org.springframework.integration.endpoint.AbstractInOutEndpoint; +import org.springframework.integration.message.Message; +import org.springframework.util.Assert; + +/** + * @author Mark Fisher + */ +public class TransformerEndpoint extends AbstractInOutEndpoint { + + private final Transformer transformer; + + + public TransformerEndpoint(Transformer transformer) { + Assert.notNull(transformer, "transformer must not be null"); + this.transformer = transformer; + } + + + @Override + protected Message handle(Message message) { + return transformer.transform(message); + } + +}