forked from swisspost/gateleen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDCISA-16147, swisspost#583] Quick-n-dirty just waste anothers threa…
…ds time for JSON serialization. Update: - Fix hard-to-trace vertxPromise NPE. Related: SDCISA-15633, SDCISA-15833, SDCISA-16147, swisspost/vertx-redisques#170, swisspost/vertx-redisques#177, swisspost/vertx-rest-storage#186, swisspost#577, swisspost/vertx-redisques#181, swisspost#493, swisspost/vertx-rest-storage#188, swisspost#583
- Loading branch information
1 parent
acbcdac
commit 0037164
Showing
3 changed files
with
187 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
gateleen-kafka/src/main/java/org/swisspush/gateleen/kafka/KafkaHandlerBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.swisspush.gateleen.kafka; | ||
|
||
import io.vertx.core.Vertx; | ||
import org.slf4j.Logger; | ||
import org.swisspush.gateleen.core.configuration.ConfigurationResourceManager; | ||
import org.swisspush.gateleen.core.exception.GateleenExceptionFactory; | ||
|
||
import java.util.Map; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
import static org.swisspush.gateleen.core.exception.GateleenExceptionFactory.newGateleenThriftyExceptionFactory; | ||
|
||
public class KafkaHandlerBuilder { | ||
|
||
private static final Logger log = getLogger(KafkaHandlerBuilder.class); | ||
private Vertx vertx; | ||
private GateleenExceptionFactory exceptionFactory; | ||
private ConfigurationResourceManager configurationResourceManager; | ||
private KafkaMessageValidator kafkaMessageValidator; | ||
private KafkaProducerRepository repository; | ||
private KafkaMessageSender kafkaMessageSender; | ||
private String configResourceUri; | ||
private String streamingPath; | ||
private Map<String, Object> properties; | ||
|
||
/** Use {@link KafkaHandler#builder()} */ | ||
KafkaHandlerBuilder() {/**/} | ||
|
||
public KafkaHandler build() { | ||
if (vertx == null) throw new NullPointerException("vertx missing"); | ||
if (exceptionFactory == null) exceptionFactory = newGateleenThriftyExceptionFactory(); | ||
if (repository == null) throw new NullPointerException("kafkaProducerRepository missing"); | ||
if (kafkaMessageSender == null) throw new NullPointerException("kafkaMessageSender missing"); | ||
if (streamingPath == null) log.warn("no 'streamingPath' given. Are you sure you want none?"); | ||
return new KafkaHandler( | ||
vertx, exceptionFactory, configurationResourceManager, kafkaMessageValidator, repository, | ||
kafkaMessageSender, configResourceUri, streamingPath, properties); | ||
} | ||
|
||
public KafkaHandlerBuilder withVertx(Vertx vertx) { | ||
this.vertx = vertx; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withExceptionFactory(GateleenExceptionFactory exceptionFactory) { | ||
this.exceptionFactory = exceptionFactory; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withConfigurationResourceManager(ConfigurationResourceManager configurationResourceManager) { | ||
this.configurationResourceManager = configurationResourceManager; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withKafkaMessageValidator(KafkaMessageValidator kafkaMessageValidator) { | ||
this.kafkaMessageValidator = kafkaMessageValidator; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withRepository(KafkaProducerRepository repository) { | ||
this.repository = repository; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withKafkaMessageSender(KafkaMessageSender kafkaMessageSender) { | ||
this.kafkaMessageSender = kafkaMessageSender; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withConfigResourceUri(String configResourceUri) { | ||
this.configResourceUri = configResourceUri; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withStreamingPath(String streamingPath) { | ||
this.streamingPath = streamingPath; | ||
return this; | ||
} | ||
|
||
public KafkaHandlerBuilder withProperties(Map<String, Object> properties) { | ||
this.properties = properties; | ||
return this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters