Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Started on AMQP support

  • Loading branch information...
commit d658099275fc7905fa56fd287bcbafac98ae8616 1 parent cca0e62
@dturanski dturanski authored
Showing with 420 additions and 20 deletions.
  1. +8 −0 build.gradle
  2. +1 −0  settings.gradle
  3. +25 −0 ...ration-dsl-groovy-amqp/src/main/groovy/org/springframework/integration/dsl/groovy/amqp/RabbitContext.groovy
  4. +43 −0 .../main/groovy/org/springframework/integration/dsl/groovy/amqp/builder/IntegrationBuilderModuleSupport.groovy
  5. +34 −0 ...oovy-amqp/src/main/groovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitAdminFactory.groovy
  6. +33 −0 ...c/main/groovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitConnectionFactoryFactory.groovy
  7. +31 −0 ...vy-amqp/src/main/groovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitContextFactory.groovy
  8. +48 −0 ...y-amqp/src/main/groovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitExchangeFactory.groovy
  9. +33 −0 ...oovy-amqp/src/main/groovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitQueueFactory.groovy
  10. +52 −0 ...l-groovy-amqp/src/test/groovy/org/springframework/integration/dsl/groovy/amqp/builder/AmqpUsageTests.groovy
  11. +29 −0 spring-integration-dsl-groovy-amqp/src/test/resources/log4j.xml
  12. +22 −0 ...ation-dsl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/SpringModuleContext.groovy
  13. +1 −0  spring-integration-dsl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/XMLBean.groovy
  14. +3 −2 ...sl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/IntegrationBuilder.groovy
  15. +8 −5 ...-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/IntegrationComponentFactory.groovy
  16. +3 −5 ...vy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/IntegrationContextFactory.groovy
  17. +1 −1  ...sl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/MessageFlowFactory.groovy
  18. +1 −1  ...ion-dsl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/PollerFactory.groovy
  19. +1 −1  ...n-dsl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/RouterFactories.groovy
  20. +1 −1  ...oovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/SimpleEndpointFactories.groovy
  21. +34 −0 ...vy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/SpringXmlComponentFactory.groovy
  22. +2 −2 ...on-dsl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/XMLBeanFactory.groovy
  23. +1 −1  ...l-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/XMLNamespaceFactory.groovy
  24. +3 −0  ...vy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/dom/IntegrationDomSupport.groovy
  25. +1 −1  ...core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/dom/SimpleEndpointDomBuilder.groovy
  26. +1 −0  ...-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/builder/dom/SpringXMLBuilder.groovy
View
8 build.gradle
@@ -75,6 +75,14 @@ project('spring-integration-dsl-groovy-jms') {
}
}
+project('spring-integration-dsl-groovy-amqp') {
+ description = 'Spring Integration Groovy DSL AMQP'
+ dependencies {
+ compile project(":spring-integration-dsl-groovy-core")
+ compile "org.springframework.integration:spring-integration-amqp:$springIntegrationVersion"
+ }
+}
+
project('spring-integration-dsl-groovy-http') {
description = 'Spring Integration Groovy DSL Http'
dependencies {
View
1  settings.gradle
@@ -1,5 +1,6 @@
rootProject.name = 'spring-integration-dsl-groovy'
include 'spring-integration-dsl-groovy-core'
+include 'spring-integration-dsl-groovy-amqp'
include 'spring-integration-dsl-groovy-http'
include 'spring-integration-dsl-groovy-jms'
include 'spring-integration-dsl-groovy-samples'
View
25 ...amqp/src/main/groovy/org/springframework/integration/dsl/groovy/amqp/RabbitContext.groovy
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp
+import org.springframework.integration.dsl.groovy.SpringModuleContext
+
+/**
+ * @author David Turanski
+ *
+ */
+public class RabbitContext extends SpringModuleContext {
+
+ @Override
+ protected String getNamespacePrefix() {
+ 'rabbit'
+ }}
View
43 ...pringframework/integration/dsl/groovy/amqp/builder/IntegrationBuilderModuleSupport.groovy
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp.builder;
+
+import org.springframework.integration.dsl.groovy.builder.AbstractIntegrationBuilderModuleSupport
+import org.springframework.integration.dsl.groovy.builder.IntegrationBuilder
+import org.springframework.integration.dsl.groovy.builder.dom.IntegrationDomSupport
+
+/**
+ * @author David Turanski
+ *
+ */
+class IntegrationBuilderModuleSupport extends AbstractIntegrationBuilderModuleSupport {
+
+ @Override
+ void registerBuilderFactories(IntegrationBuilder builder) {
+ builder.registerFactory 'rabbitDirectExchange', new RabbitExchangeFactory()
+ builder.registerFactory 'rabbitTopicExchange', new RabbitExchangeFactory()
+ builder.registerFactory 'rabbitFanoutExchange', new RabbitExchangeFactory()
+ builder.registerFactory 'rabbitHeadersExchange', new RabbitExchangeFactory()
+ builder.registerFactory 'rabbitFederatedExchange', new RabbitExchangeFactory()
+ builder.registerFactory 'rabbitConnectionFactory', new RabbitConnectionFactoryFactory()
+ builder.registerFactory 'rabbitQueue', new RabbitQueueFactory()
+ builder.registerFactory 'rabbitAdmin', new RabbitAdminFactory()
+ builder.registerFactory 'doWithRabbit', new RabbitContextFactory()
+ }
+
+ @Override
+ void registerDomBuilders(IntegrationDomSupport integrationDomSupport) {
+ integrationDomSupport.namespaceSupport.addIntegrationNamespace('int-amqp')
+ integrationDomSupport.namespaceSupport.addSpringNamespace('rabbit')
+ }
+}
View
34 .../groovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitAdminFactory.groovy
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp.builder
+import groovy.util.FactoryBuilderSupport
+import java.util.Map
+import org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory
+import org.springframework.integration.dsl.groovy.builder.SpringXmlComponentFactory
+
+/**
+ * @author David Turanski
+ *
+ */
+class RabbitAdminFactory extends SpringXmlComponentFactory {
+
+ /* (non-Javadoc)
+ * @see org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory#doNewInstance(groovy.util.FactoryBuilderSupport, java.lang.Object, java.lang.Object, java.util.Map)
+ */
+ @Override
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
+ String elementName = propertyNameToAttributeName(name).replace('rabbit-','rabbit:')
+ attributes.'connection-factory' ?:'connectionFactory'
+ builder.springXml{"$elementName"(attributes)}
+ }
+}
View
33 ...springframework/integration/dsl/groovy/amqp/builder/RabbitConnectionFactoryFactory.groovy
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp.builder
+import groovy.util.FactoryBuilderSupport
+import java.util.Map
+import org.springframework.integration.dsl.groovy.amqp.RabbitContext
+import org.springframework.integration.dsl.groovy.builder.SpringXmlComponentFactory
+
+/**
+ * @author David Turanski
+ *
+ */
+class RabbitConnectionFactoryFactory extends SpringXmlComponentFactory {
+
+ /* (non-Javadoc)
+ * @see org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory#doNewInstance(groovy.util.FactoryBuilderSupport, java.lang.Object, java.lang.Object, java.util.Map)
+ */
+ @Override
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
+ def id = attributes.name ?:'connectionFactory'
+ builder.springXml{"rabbit:connection-factory"(id:id)}
+ }
+}
View
31 ...roovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitContextFactory.groovy
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp.builder
+import groovy.util.FactoryBuilderSupport
+import java.util.Map
+import org.springframework.integration.dsl.groovy.amqp.RabbitContext
+import org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory
+import org.springframework.integration.dsl.groovy.builder.IntegrationContextFactory
+import org.springframework.integration.dsl.groovy.builder.SpringXmlComponentFactory
+
+/**
+ * @author David Turanski
+ *
+ */
+class RabbitContextFactory extends IntegrationContextFactory {
+
+ @Override
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
+ new RabbitContext()
+ }
+}
View
48 ...oovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitExchangeFactory.groovy
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp.builder
+import groovy.util.FactoryBuilderSupport
+import java.util.Map
+import org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory
+import org.springframework.integration.dsl.groovy.builder.SpringXmlComponentFactory
+
+/**
+ * @author David Turanski
+ *
+ */
+class RabbitExchangeFactory extends SpringXmlComponentFactory {
+
+ /* (non-Javadoc)
+ * @see org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory#doNewInstance(groovy.util.FactoryBuilderSupport, java.lang.Object, java.lang.Object, java.util.Map)
+ */
+ @Override
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
+ String elementName = propertyNameToAttributeName(name).replace('rabbit-','rabbit:')
+
+ def bindings
+ if (attributes.containsKey('bindings')){
+ bindings = attributes.remove('bindings')
+ }
+ builder.springXml{"$elementName"(attributes) {
+ if (bindings){
+ 'rabbit:bindings' {
+ // Expecting a list of Maps
+ bindings.each {Map binding ->
+ 'rabbit:binding'(binding)
+ }
+ }
+ }
+ }
+ }
+ }
+}
View
33 .../groovy/org/springframework/integration/dsl/groovy/amqp/builder/RabbitQueueFactory.groovy
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp.builder
+import groovy.util.FactoryBuilderSupport
+import java.util.Map
+import org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory
+import org.springframework.integration.dsl.groovy.builder.SpringXmlComponentFactory
+
+/**
+ * @author David Turanski
+ *
+ */
+class RabbitQueueFactory extends SpringXmlComponentFactory {
+
+ /* (non-Javadoc)
+ * @see org.springframework.integration.dsl.groovy.builder.IntegrationComponentFactory#doNewInstance(groovy.util.FactoryBuilderSupport, java.lang.Object, java.lang.Object, java.util.Map)
+ */
+ @Override
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
+ String elementName = propertyNameToAttributeName(name).replace('rabbit-','rabbit:')
+ builder.springXml{"$elementName"(attributes)}
+ }
+}
View
52 ...test/groovy/org/springframework/integration/dsl/groovy/amqp/builder/AmqpUsageTests.groovy
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.amqp.builder
+import static org.junit.Assert.*
+import org.junit.Test
+import org.springframework.integration.dsl.groovy.builder.IntegrationBuilder
+/**
+ * @author David Turanski
+ *
+ */
+class AmqpUsageTests {
+ def builder = new IntegrationBuilder('amqp')
+
+ @Test
+ void testConnectionFactory() {
+ builder.doWithSpringIntegration {
+ rabbitConnectionFactory()
+ }
+
+ builder.applicationContext.getBean('connectionFactory')
+ }
+
+ @Test
+ void testDirectExchange() {
+ builder.doWithSpringIntegration {
+ rabbitQueue('q1')
+ rabbitQueue('q2')
+ rabbitQueue('q3')
+ rabbitDirectExchange('myExchange',bindings:[[key:'t1',queue:'q1'],[key:'t2',queue:'q2'],[queue:'q3']])
+ }
+
+ builder.applicationContext.getBean('myExchange')
+ }
+
+ @Test
+ void testAdmin() {
+ builder.doWithSpringIntegration {
+ rabbitConnectionFactory('myConnectionFactory')
+ rabbitAdmin(connectionFactory:'myConnectionFactory')
+ }
+ }
+}
View
29 spring-integration-dsl-groovy-amqp/src/test/resources/log4j.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Loggers -->
+
+ <logger name="org.springframework.integration.dsl.groovy">
+ <level value="debug" />
+ </logger>
+
+ <logger name="org.springframework.integration">
+ <level value="debug" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
22 ...ore/src/main/groovy/org/springframework/integration/dsl/groovy/SpringModuleContext.groovy
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy
+
+/**
+ * @author David Turanski
+ *
+ * A marker for Spring module containers
+ */
+abstract class SpringModuleContext extends BaseIntegrationComposition {
+ protected abstract String getNamespacePrefix()
+}
View
1  ...dsl-groovy-core/src/main/groovy/org/springframework/integration/dsl/groovy/XMLBean.groovy
@@ -18,4 +18,5 @@ package org.springframework.integration.dsl.groovy
*/
class XMLBean extends IntegrationComponent {
Closure beanDefinitions
+ String builderName='springXml'
}
View
5 .../main/groovy/org/springframework/integration/dsl/groovy/builder/IntegrationBuilder.groovy
@@ -18,6 +18,7 @@ import org.springframework.context.ApplicationContext
import org.springframework.integration.dsl.groovy.BaseIntegrationComposition
import org.springframework.integration.dsl.groovy.IntegrationContext
import org.springframework.integration.dsl.groovy.MessageFlow
+import org.springframework.integration.dsl.groovy.SpringModuleContext
import org.springframework.integration.dsl.groovy.XMLBean
/**
@@ -218,12 +219,12 @@ class IntegrationBuilder extends FactoryBuilderSupport {
def node = dispathNodeCall(name,list as Object[])
}
- IntegrationBuilder springXml(Closure closure) {
+ def springXml(Closure closure) {
def parent = getCurrent()
assert parent && parent instanceof BaseIntegrationComposition, "'springXml' is not valid in this context"
parent.add(new XMLBean(builderName:"springXml",beanDefinitions:closure.dehydrate()))
closure = null
- return this
+ this
}
private getIntegrationBuilderModuleSupportInstances(String[] modules) {
View
13 ...ovy/org/springframework/integration/dsl/groovy/builder/IntegrationComponentFactory.groovy
@@ -14,6 +14,8 @@ package org.springframework.integration.dsl.groovy.builder
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
+import org.springframework.integration.dsl.groovy.BaseIntegrationComposition
+import org.springframework.integration.dsl.groovy.IntegrationComponent
import java.util.Map
import groovy.util.FactoryBuilderSupport
@@ -26,6 +28,7 @@ abstract class IntegrationComponentFactory extends AbstractFactory {
protected defaultAttributes(name, value, attributes) {
assert !(attributes.containsKey('name') && value), "$name cannot accept both a default value and a 'name' attribute"
+ assert !(attributes.containsKey('id') && value), "$name cannot accept both a default value and a 'id' attribute"
attributes = attributes ?: [:]
attributes.builderName = name
@@ -44,13 +47,13 @@ abstract class IntegrationComponentFactory extends AbstractFactory {
attributes = defaultAttributes(name, value, attributes)
def instance = doNewInstance(builder, name, value, attributes)
-
- def validationContext = instance.validateAttributes(attributes)
- assert !validationContext.hasErrors, validationContext.errorMessage
-
+ if (instance.respondsTo('validateAttributes')) {
+ def validationContext = instance.validateAttributes(attributes)
+ assert !validationContext.hasErrors, validationContext.errorMessage
+ }
instance
}
- protected abstract doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes)
+ protected abstract Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes)
}
View
8 ...roovy/org/springframework/integration/dsl/groovy/builder/IntegrationContextFactory.groovy
@@ -12,10 +12,8 @@
*/
package org.springframework.integration.dsl.groovy.builder
-import java.util.Map;
-
-import groovy.util.AbstractFactory
-import groovy.util.FactoryBuilderSupport;
+import java.util.Map
+import groovy.util.FactoryBuilderSupport
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
@@ -25,7 +23,7 @@ import org.apache.commons.logging.LogFactory
*
*/
class IntegrationContextFactory extends IntegrationComponentFactory {
- public Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
return builder.integrationContext;
}
View
2  .../main/groovy/org/springframework/integration/dsl/groovy/builder/MessageFlowFactory.groovy
@@ -20,7 +20,7 @@ import org.springframework.integration.dsl.groovy.MessageFlow
*/
class MessageFlowFactory extends IntegrationComponentFactory {
- public Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
def messageFlow = new MessageFlow(attributes)
if (!messageFlow.inputChannel) {
messageFlow.inputChannel = "${messageFlow.name}.inputChannel"
View
2  ...e/src/main/groovy/org/springframework/integration/dsl/groovy/builder/PollerFactory.groovy
@@ -21,7 +21,7 @@ import org.springframework.integration.dsl.groovy.SimpleEndpoint
*/
class PollerFactory extends IntegrationComponentFactory {
@Override
- Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
new Poller(attributes)
}
View
2  ...src/main/groovy/org/springframework/integration/dsl/groovy/builder/RouterFactories.groovy
@@ -24,7 +24,7 @@ import org.springframework.integration.dsl.groovy.WhenCondition
*/
class RouterCompositionFactory extends IntegrationComponentFactory {
- Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
new RouterComposition(attributes)
}
View
2  .../groovy/org/springframework/integration/dsl/groovy/builder/SimpleEndpointFactories.groovy
@@ -22,7 +22,7 @@ import org.springframework.integration.dsl.groovy.*
abstract class EndpointFactory extends IntegrationComponentFactory {
@Override
- Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
endpointInstance(attributes)
}
View
34 ...roovy/org/springframework/integration/dsl/groovy/builder/SpringXmlComponentFactory.groovy
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2002-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.integration.dsl.groovy.builder
+
+import org.springframework.integration.dsl.groovy.AttributeHelper
+import groovy.util.FactoryBuilderSupport
+import java.util.Map
+
+/**
+ * @author David Turanski
+ *
+ */
+@Mixin(AttributeHelper)
+abstract class SpringXmlComponentFactory extends IntegrationComponentFactory {
+
+ def newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException {
+ attributes = defaultAttributes(name, value, attributes)
+ attributes.remove('builderName')
+ Map xmlAttributes = [:]
+ attributes.each {k,v -> xmlAttributes[propertyNameToAttributeName(k)] = v }
+ def instance = doNewInstance(builder, name, value, xmlAttributes)
+ instance
+ }
+}
View
4 .../src/main/groovy/org/springframework/integration/dsl/groovy/builder/XMLBeanFactory.groovy
@@ -24,13 +24,13 @@ import org.springframework.integration.dsl.groovy.XMLBean
*/
class XMLBeanFactory extends IntegrationComponentFactory {
- Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) {
new XMLBean(builderName:name)
}
@Override
boolean isLeaf() {
- false
+ true
}
@Override
View
2  ...main/groovy/org/springframework/integration/dsl/groovy/builder/XMLNamespaceFactory.groovy
@@ -24,7 +24,7 @@ import org.springframework.integration.dsl.groovy.XMLNamespace
*/
class XMLNamespaceFactory extends IntegrationComponentFactory {
- Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
+ protected Object doNewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes){
assert value, "A value is required for '$name'. It contains a comma delimited list of namespace prefixes"
new XMLNamespace(name:value)
}
View
3  ...roovy/org/springframework/integration/dsl/groovy/builder/dom/IntegrationDomSupport.groovy
@@ -87,6 +87,9 @@ class IntegrationDomSupport {
namespaces << namespaceSupport.namespaceDeclarations
beans(namespaceSupport.schemaLocationDeclaration() ) {
integrationContext.components.each {component ->
+ if (logger.isDebugEnabled()) {
+ logger.debug("building ${component}")
+ }
domBuilder(component)?.build(builder, integrationContext.applicationContext, component)
}
}
View
2  ...vy/org/springframework/integration/dsl/groovy/builder/dom/SimpleEndpointDomBuilder.groovy
@@ -49,7 +49,7 @@ class SimpleEndpointDomBuilder extends IntegrationComponentDomBuilder {
attributes = buildAttributes(attributes, endpoint)
if (endpoint.hasProperty('action') && endpoint.action) {
- assert !(attributes.containsKey('ref')), 'endoint cannot provide a bean reference and a closure'
+ assert !(attributes.containsKey('ref')), 'endpoint cannot provide a bean reference and a closure'
attributes.method='processMessage'
def beanName = "${name}_closureInvokingHandler"
attributes.ref = beanName
View
1  ...ain/groovy/org/springframework/integration/dsl/groovy/builder/dom/SpringXMLBuilder.groovy
@@ -29,5 +29,6 @@ class SpringXMLBuilder extends IntegrationComponentDomBuilder {
Closure c = component.beanDefinitions
c.delegate = builder
c.call()
+ println "closure called on $builder"
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.