Skip to content

Instantly share code, notes, and snippets.

@garyrussell
Last active August 29, 2015 13:57
Show Gist options
  • Save garyrussell/9767493 to your computer and use it in GitHub Desktop.
Save garyrussell/9767493 to your computer and use it in GitHub Desktop.
Spring Integration Groovy DSL and Spring Boot
doWithSpringIntegration {
namespaces('int-http')
springXml {
'int-http:inbound-gateway'(id:'events-inbound-gateway',
'request-channel':'events-request-inbound-channel',
'path':'/examples/eventsFlow',
'supported-methods':'GET'
)
'si:channel'(id:'events-request-inbound-channel')
'si:service-activator'('input-channel':'events-request-inbound-channel',
'expression':'42')
}
}
/*
* Copyright 2014 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 foo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.integration.dsl.groovy.builder.IntegrationBuilder;
import org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport;
/**
* @author Gary Russell
* @since 4.0
*
*/
@EnableAutoConfiguration
@ImportResource("classpath:foo/siboot.xml")
public class Groovy {
private ApplicationContext ctx;
public static void main(String[] args) throws Exception {
SpringApplication.run(Groovy.class, args);
}
/**
* Promote the endpoint from the DSL context to the root context.
*/
@Bean
public HttpRequestHandlingEndpointSupport http() {
IntegrationBuilder builder = new IntegrationBuilder();
builder.build(new ClassPathResource("foo/foo.groovy"));
this.ctx = builder.getApplicationContext();
return ctx.getBean(HttpRequestHandlingEndpointSupport.class);
}
}
<?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-http="http://www.springframework.org/schema/integration/http"
xsi:schemaLocation="http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
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">
<int:channel id="dummy" />
<int-http:inbound-channel-adapter auto-startup="false" channel="dummy" path="/foo" />
<!-- dummy adapter needed at the top level to get the handler mapping enabled -->
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment