Skip to content

Commit

Permalink
Merge pull request #1296 from onobc
Browse files Browse the repository at this point in the history
* pr/1296:
  Polish "Enable Spring Pulsar with Spring Boot 3.2.x"
  Enable Spring Pulsar with Spring Boot 3.2.x

Closes gh-1296
  • Loading branch information
snicoll committed Sep 21, 2023
2 parents ddaf9e6 + a74c15e commit 16754ae
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public SimpleDockerServiceResolver() {
this.dockerServices.put("mysql", mysql());
this.dockerServices.put("oracle", oracle());
this.dockerServices.put("postgres", postgres());
this.dockerServices.put("pulsar", pulsar());
this.dockerServices.put("rabbit", rabbit());
this.dockerServices.put("redis", redis());
this.dockerServices.put("sqlServer", sqlServer());
Expand Down Expand Up @@ -103,6 +104,15 @@ private static DockerService postgres() {
.build();
}

private static DockerService pulsar() {
// The latest tag they provide is not the 'latest' GA
return DockerService.withImageAndTag("apachepulsar/pulsar:3.1.0")
.website("https://hub.docker.com/r/apachepulsar/pulsar")
.command("bin/pulsar standalone")
.ports(8080, 6650)
.build();
}

private static DockerService rabbit() {
return DockerService.withImageAndTag("rabbitmq")
.website("https://hub.docker.com/_/rabbitmq")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,71 @@

package io.spring.start.site.extension.dependency.springpulsar;

import java.util.Map;

import io.spring.initializr.generator.buildsystem.Dependency;
import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion;
import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency;
import io.spring.initializr.generator.condition.ProjectGenerationCondition;
import io.spring.initializr.generator.project.ProjectDescription;
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.start.site.container.ComposeFileCustomizer;
import io.spring.start.site.container.DockerServiceResolver;
import io.spring.start.site.container.ServiceConnections;
import io.spring.start.site.container.ServiceConnectionsCustomizer;
import io.spring.start.site.extension.dependency.springpulsar.SpringPulsarProjectGenerationConfiguration.OnPulsarDependencyCondition;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
* Configuration for generation of projects that depend on Pulsar.
*
* @author Chris Bono
*/
@ProjectGenerationConfiguration
@ConditionalOnRequestedDependency("pulsar")
@Conditional(OnPulsarDependencyCondition.class)
class SpringPulsarProjectGenerationConfiguration {

private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.PulsarContainer";

@Bean
@ConditionalOnPlatformVersion("3.2.0-M3")
@ConditionalOnRequestedDependency("testcontainers")
ServiceConnectionsCustomizer pulsarServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) {
return (serviceConnections) -> serviceResolver.doWith("pulsar",
(service) -> serviceConnections.addServiceConnection(ServiceConnections.ServiceConnection
.ofContainer("pulsar", service, TESTCONTAINERS_CLASS_NAME, false)));
}

@Bean
@ConditionalOnPlatformVersion("3.2.0-M3")
@ConditionalOnRequestedDependency("docker-compose")
ComposeFileCustomizer pulsarComposeFileCustomizer(DockerServiceResolver serviceResolver) {
return (composeFile) -> serviceResolver.doWith("pulsar",
(service) -> composeFile.services().add("pulsar", service));
}

@Bean
@ConditionalOnPlatformVersion("[3.0.0,3.2.0-M1)")
@ConditionalOnRequestedDependency("cloud-stream")
SpringPulsarBinderBuildCustomizer pulsarBinderBuildCustomizer(InitializrMetadata metadata,
ProjectDescription description) {
return new SpringPulsarBinderBuildCustomizer(metadata, description);
}

static class OnPulsarDependencyCondition extends ProjectGenerationCondition {

@Override
protected boolean matches(ProjectDescription description, ConditionContext context,
AnnotatedTypeMetadata metadata) {
Map<String, Dependency> requestedDependencies = description.getRequestedDependencies();
return requestedDependencies.containsKey("pulsar") || requestedDependencies.containsKey("pulsar-reactive");
}

}

}
28 changes: 14 additions & 14 deletions start-site/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -786,30 +786,30 @@ initializr:
href: https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/index.html#messaging.jms.artemis
- name: Spring for Apache Pulsar
id: pulsar
compatibilityRange: "[3.0.0,3.2.0-M1)"
mappings:
- compatibilityRange: "[3.0.0,3.2.0-M1)"
version: 0.2.0
compatibilityRange: "3.0.0"
description: Build messaging applications with Apache Pulsar
groupId: org.springframework.pulsar
artifactId: spring-pulsar-spring-boot-starter
links:
- rel: reference
href: https://docs.spring.io/spring-pulsar/docs/0.2.x/reference/html/
- name: Spring for Apache Pulsar (Reactive)
id: pulsar-reactive
compatibilityRange: "[3.0.0,3.2.0-M1)"
href: https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/index.html#messaging.pulsar
mappings:
- compatibilityRange: "[3.0.0,3.2.0-M1)"
- compatibilityRange: "[3.0.0,3.2.0-M3)"
version: 0.2.0
groupId: org.springframework.pulsar
artifactId: spring-pulsar-spring-boot-starter
- name: Spring for Apache Pulsar (Reactive)
id: pulsar-reactive
compatibilityRange: "3.0.0"
description: Build reactive messaging applications with Apache Pulsar
facets:
- reactive
groupId: org.springframework.pulsar
artifactId: spring-pulsar-reactive-spring-boot-starter
links:
- rel: reference
href: https://docs.spring.io/spring-pulsar/docs/0.2.x/reference/html/#reactive-pulsar
href: https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/index.html#messaging.pulsar
mappings:
- compatibilityRange: "[3.0.0,3.2.0-M1)"
version: 0.2.0
groupId: org.springframework.pulsar
artifactId: spring-pulsar-reactive-spring-boot-starter
- name: WebSocket
id: websocket
description: Build Servlet-based WebSocket applications with SockJS and STOMP.
Expand Down

This file was deleted.

Loading

0 comments on commit 16754ae

Please sign in to comment.