|
24 | 24 | import io.spring.start.site.container.ServiceConnectionsCustomizer;
|
25 | 25 |
|
26 | 26 | import org.springframework.context.annotation.Bean;
|
| 27 | +import org.springframework.context.annotation.Configuration; |
27 | 28 |
|
28 | 29 | /**
|
29 | 30 | * Configuration for generation of projects that depend on Spring AMQP.
|
30 | 31 | *
|
31 | 32 | * @author Stephane Nicoll
|
32 |
| - * @author Stephane Nicoll |
33 | 33 | */
|
34 | 34 | @ProjectGenerationConfiguration
|
35 |
| -@ConditionalOnRequestedDependency("amqp") |
36 | 35 | class SpringAmqpProjectGenerationConfiguration {
|
37 | 36 |
|
38 |
| - private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.RabbitMQContainer"; |
| 37 | + @Configuration(proxyBeanMethods = false) |
| 38 | + @ConditionalOnRequestedDependency("amqp") |
| 39 | + static class AmqpConfiguration { |
39 | 40 |
|
40 |
| - @Bean |
41 |
| - SpringRabbitTestBuildCustomizer springAmqpTestBuildCustomizer() { |
42 |
| - return new SpringRabbitTestBuildCustomizer(); |
43 |
| - } |
| 41 | + private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.RabbitMQContainer"; |
| 42 | + |
| 43 | + @Bean |
| 44 | + SpringRabbitTestBuildCustomizer springAmqpTestBuildCustomizer() { |
| 45 | + return new SpringRabbitTestBuildCustomizer(); |
| 46 | + } |
| 47 | + |
| 48 | + @Bean |
| 49 | + @ConditionalOnRequestedDependency("testcontainers") |
| 50 | + ServiceConnectionsCustomizer rabbitServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { |
| 51 | + return (serviceConnections) -> serviceResolver.doWith("rabbit", |
| 52 | + (service) -> serviceConnections.addServiceConnection( |
| 53 | + ServiceConnection.ofContainer("rabbit", service, TESTCONTAINERS_CLASS_NAME, false))); |
| 54 | + } |
| 55 | + |
| 56 | + @Bean |
| 57 | + @ConditionalOnRequestedDependency("docker-compose") |
| 58 | + ComposeFileCustomizer rabbitComposeFileCustomizer(DockerServiceResolver serviceResolver) { |
| 59 | + return (composeFile) -> serviceResolver.doWith("rabbit", |
| 60 | + (service) -> composeFile.services() |
| 61 | + .add("rabbitmq", |
| 62 | + service.andThen((builder) -> builder.environment("RABBITMQ_DEFAULT_USER", "myuser") |
| 63 | + .environment("RABBITMQ_DEFAULT_PASS", "secret") |
| 64 | + .ports(5672)))); |
| 65 | + } |
44 | 66 |
|
45 |
| - @Bean |
46 |
| - @ConditionalOnRequestedDependency("testcontainers") |
47 |
| - ServiceConnectionsCustomizer rabbitServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { |
48 |
| - return (serviceConnections) -> serviceResolver.doWith("rabbit", (service) -> serviceConnections |
49 |
| - .addServiceConnection(ServiceConnection.ofContainer("rabbit", service, TESTCONTAINERS_CLASS_NAME, false))); |
50 | 67 | }
|
51 | 68 |
|
52 |
| - @Bean |
53 |
| - @ConditionalOnRequestedDependency("docker-compose") |
54 |
| - ComposeFileCustomizer rabbitComposeFileCustomizer(DockerServiceResolver serviceResolver) { |
55 |
| - return (composeFile) -> serviceResolver.doWith("rabbit", |
56 |
| - (service) -> composeFile.services() |
57 |
| - .add("rabbitmq", |
58 |
| - service.andThen((builder) -> builder.environment("RABBITMQ_DEFAULT_USER", "myuser") |
59 |
| - .environment("RABBITMQ_DEFAULT_PASS", "secret") |
60 |
| - .ports(5672)))); |
| 69 | + @ConditionalOnRequestedDependency("amqp-streams") |
| 70 | + @Configuration(proxyBeanMethods = false) |
| 71 | + static class AmqpStreamsConfiguration { |
| 72 | + |
| 73 | + @Bean |
| 74 | + SpringRabbitStreamsBuildCustomizer springRabbitStreamsBuildCustomizer() { |
| 75 | + return new SpringRabbitStreamsBuildCustomizer(); |
| 76 | + } |
| 77 | + |
61 | 78 | }
|
62 | 79 |
|
63 | 80 | }
|
0 commit comments