Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Commit

Permalink
upgraded to SI 2.2.0 and changed http outbound to use url-expression …
Browse files Browse the repository at this point in the history
…attribute if url is a closure
  • Loading branch information
David Turanski committed Nov 6, 2012
1 parent 71f9d93 commit 2fe95cc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
4 changes: 1 addition & 3 deletions gradle.properties
Expand Up @@ -2,7 +2,5 @@ version = 1.0.0.BUILD-SNAPSHOT
junitVersion = 4.8.2
log4jVersion = 1.2.14
mockitoVersion = 1.9.0
#springIntegrationVersion = 2.2.0.RC1
springIntegrationVersion = 2.1.3.RELEASE

springIntegrationVersion = 2.2.0.RC2
groovyVersion = 2.0.5
Expand Up @@ -53,24 +53,22 @@ class HttpOutboundDomBuilder extends IntegrationComponentDomBuilder {

Closure urlExpression

attributes.url = component.url

if (component.url instanceof Closure) {
urlExpression = component.url
attributes.url = '{url}'
def beanName = "${component.name}_closureInvokingHandler"
BeanDefinitionBuilder handlerBuilder =
BeanDefinitionBuilder.genericBeanDefinition(ClosureInvokingMessageProcessor)
handlerBuilder.addConstructorArgValue(urlExpression)
def bdh = new BeanDefinitionHolder(handlerBuilder.getBeanDefinition(),beanName)
BeanDefinitionReaderUtils.registerBeanDefinition(bdh, (BeanDefinitionRegistry) applicationContext)

attributes.'url-expression' = "@${beanName}.processMessage(#this)"
} else {
attributes.url = component.url
}


builder.'int-http:outbound-gateway'(attributes) {
if (urlExpression){
def beanName = "${component.name}_closureInvokingHandler"
BeanDefinitionBuilder handlerBuilder =
BeanDefinitionBuilder.genericBeanDefinition(ClosureInvokingMessageProcessor)
handlerBuilder.addConstructorArgValue(urlExpression)
def bdh = new BeanDefinitionHolder(handlerBuilder.getBeanDefinition(),beanName)
BeanDefinitionReaderUtils.registerBeanDefinition(bdh, (BeanDefinitionRegistry) applicationContext)

'int-http:uri-variable'(name:'url', expression:"@${beanName}.processMessage(#this)")
}
}
builder.'int-http:outbound-gateway'(attributes)
}
}
Expand Up @@ -12,15 +12,15 @@ public class HttpExamples {
static void main(String[] args) {
def builder = new IntegrationBuilder('http')
builder.setAutoCreateApplicationContext(false)

def ticker = 'VMW'

/*
* Demonstrates defining url as a closure
*/
def flow = builder.messageFlow {

httpGet(url:"http://www.google.com/finance/info?q=$ticker",responseType:String)
httpGet(url:{"http://www.google.com/finance/info?q=$it"},responseType:String)
}

def result = flow.sendAndReceive('')
def result = flow.sendAndReceive('VMW')
println result

}
Expand Down
Expand Up @@ -13,7 +13,7 @@
<!-- Loggers -->

<logger name="org.springframework.integration.dsl.groovy">
<level value="warn" />
<level value="debug" />
</logger>

<logger name="org.springframework.integration">
Expand Down

0 comments on commit 2fe95cc

Please sign in to comment.