[BS-48] Add autoconfigured JMS support
* Add ability to detect spring-jms on the path and create a JmsTemplate with ActiveMQConnectionFactory * Create tests showing autoconfigured JmsTemplate with ActiveMQ, but prove it backs off if a separate ConnectionFactory exists. * Add support to spring-boot-cli to that it detects JmsTemplate, DefaultMessageListenerContainer, or SimpleMessageListenerContainer, and turns on autoconfiguration as well as add proper @Grab's and import statements. * Write a jms.groovy test showing proper CLI support Simplify ActiveMQ configuration Update ActiveMQ to 5.7.0
This commit is contained in:
committed by
Dave Syer
parent
ecc4676fb3
commit
5801e422cf
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2012-2013 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.boot.cli.compiler.autoconfigure;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
import org.springframework.boot.cli.compiler.AstUtils;
|
||||
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring JMS.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
return AstUtils.hasAtLeastOneFieldOrMethod(classNode, "JmsTemplate",
|
||||
"DefaultMessageListenerContainer", "SimpleMessageListenerContainer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies.add("org.springframework", "spring-jms",
|
||||
dependencies.getProperty("spring.version")).add(
|
||||
"org.apache.geronimo.specs", "geronimo-jms_1.1_spec", "1.1");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("javax.jms", "org.springframework.jms.core",
|
||||
"org.springframework.jms.listener",
|
||||
"org.springframework.jms.listener.adapter");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ org.springframework.boot.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfigu
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.ReactorCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.JdbcCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.TransactionManagementCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringIntegrationCompilerAutoConfiguration
|
||||
org.springframework.boot.cli.compiler.autoconfigure.SpringSecurityCompilerAutoConfiguration
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.boot.cli;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -32,13 +36,11 @@ import org.springframework.boot.OutputCapture;
|
||||
import org.springframework.boot.cli.command.CleanCommand;
|
||||
import org.springframework.boot.cli.command.RunCommand;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests to exercise the samples.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class SampleIntegrationTests {
|
||||
|
||||
@@ -185,4 +187,13 @@ public class SampleIntegrationTests {
|
||||
assertTrue("Wrong output: " + output, output.contains("Foo count="));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jmsSample() throws Exception {
|
||||
start("samples/app.xml", "samples/jms.groovy");
|
||||
String output = this.outputCapture.getOutputAndRelease();
|
||||
assertTrue("Wrong output: " + output,
|
||||
output.contains("Received Greetings from Spring Boot via ActiveMQ"));
|
||||
FileUtil.forceDelete(new File("activemq-data")); // cleanup ActiveMQ cruft
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
||||
<!-- logger name="org.springframework.jdbc" level="DEBUG"/-->
|
||||
<!-- logger name="org.springframework.jms" level="DEBUG"/-->
|
||||
</configuration>
|
||||
|
||||
Reference in New Issue
Block a user