Last active
August 29, 2015 13:57
-
-
Save garyrussell/9767493 to your computer and use it in GitHub Desktop.
Spring Integration Groovy DSL and Spring Boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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