Skip to content

Commit

Permalink
refactoring: combining Module and Provider for non-deprecated modules
Browse files Browse the repository at this point in the history
  • Loading branch information
andrus committed Nov 25, 2023
1 parent ad9d02b commit 0fc2d6c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@

package io.bootique.rabbitmq.client;

import io.bootique.ConfigModule;
import io.bootique.BQModuleProvider;
import io.bootique.bootstrap.BuiltModule;
import io.bootique.config.ConfigurationFactory;
import io.bootique.di.BQModule;
import io.bootique.di.Binder;
import io.bootique.di.Injector;
import io.bootique.di.Provides;
import io.bootique.log.BootLogger;
Expand All @@ -31,12 +34,26 @@

import javax.inject.Singleton;

public class RabbitMQModule extends ConfigModule {
public class RabbitMQModule implements BQModule, BQModuleProvider {

private static final String CONFIG_PREFIX = "rabbitmq";

@Override
public BuiltModule buildModule() {
return BuiltModule.of(this)
.description("Integrates RabbitMQ client library")
.config(CONFIG_PREFIX, RmqObjectsFactory.class)
.build();
}

@Override
public void configure(Binder binder) {
}

@Singleton
@Provides
RmqObjectsFactory provideRmqObjectsFactory(ConfigurationFactory configFactory) {
return config(RmqObjectsFactory.class, configFactory);
return configFactory.config(RmqObjectsFactory.class, CONFIG_PREFIX);
}

@Singleton
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
io.bootique.rabbitmq.client.RabbitMQModuleProvider
io.bootique.rabbitmq.client.RabbitMQModule
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
import io.bootique.junit5.BQModuleProviderChecker;
import org.junit.jupiter.api.Test;

public class RabbitMQModuleProviderTest {
public class RabbitMQModuleTest {

@Test
public void autoLoadable() {
BQModuleProviderChecker.testAutoLoadable(RabbitMQModuleProvider.class);
BQModuleProviderChecker.testAutoLoadable(RabbitMQModule.class);
}

@Test
public void metadata() {
BQModuleProviderChecker.testMetadata(RabbitMQModuleProvider.class);
BQModuleProviderChecker.testMetadata(RabbitMQModule.class);
}

}

0 comments on commit 0fc2d6c

Please sign in to comment.