diff --git a/src/main/java/io/bootique/curator/CuratorModule.java b/src/main/java/io/bootique/curator/CuratorModule.java index 540377f..4501fd1 100644 --- a/src/main/java/io/bootique/curator/CuratorModule.java +++ b/src/main/java/io/bootique/curator/CuratorModule.java @@ -19,8 +19,11 @@ package io.bootique.curator; -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.Provides; import io.bootique.log.BootLogger; import io.bootique.shutdown.ShutdownManager; @@ -28,7 +31,22 @@ import javax.inject.Singleton; -public class CuratorModule extends ConfigModule { +public class CuratorModule implements BQModule, BQModuleProvider { + + private static final String CONFIG_PREFIX = "curator"; + + @Override + public BuiltModule buildModule() { + return BuiltModule.of(new CuratorModule()) + .provider(this) + .description("Integrates Apache Curator Zookeeper client") + .config(CONFIG_PREFIX, CuratorFrameworkFactory.class) + .build(); + } + + @Override + public void configure(Binder binder) { + } @Provides @Singleton @@ -37,7 +55,7 @@ public CuratorFramework createCurator( BootLogger bootLogger, ShutdownManager shutdownManager) { - CuratorFramework client = config(CuratorFrameworkFactory.class, configFactory).createZkClient(); + CuratorFramework client = configFactory.config(CuratorFrameworkFactory.class, CONFIG_PREFIX).createZkClient(); shutdownManager.addShutdownHook(() -> { bootLogger.trace(() -> "shutting down Curator..."); diff --git a/src/main/java/io/bootique/curator/CuratorModuleProvider.java b/src/main/java/io/bootique/curator/CuratorModuleProvider.java deleted file mode 100644 index 55f91fd..0000000 --- a/src/main/java/io/bootique/curator/CuratorModuleProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to ObjectStyle LLC under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ObjectStyle LLC licenses - * this file to you 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 io.bootique.curator; - -import io.bootique.BQModuleProvider; -import io.bootique.bootstrap.BuiltModule; - -public class CuratorModuleProvider implements BQModuleProvider { - - @Override - public BuiltModule buildModule() { - return BuiltModule.of(new CuratorModule()) - .provider(this) - .description("Integrates Apache Curator Zookeeper client") - .config("curator", CuratorFrameworkFactory.class) - .build(); - } -} diff --git a/src/main/resources/META-INF/services/io.bootique.BQModuleProvider b/src/main/resources/META-INF/services/io.bootique.BQModuleProvider index 42dd688..ded8784 100644 --- a/src/main/resources/META-INF/services/io.bootique.BQModuleProvider +++ b/src/main/resources/META-INF/services/io.bootique.BQModuleProvider @@ -1 +1 @@ -io.bootique.curator.CuratorModuleProvider \ No newline at end of file +io.bootique.curator.CuratorModule \ No newline at end of file diff --git a/src/test/java/io/bootique/curator/CuratorModuleProviderTest.java b/src/test/java/io/bootique/curator/CuratorModuleTest.java similarity index 88% rename from src/test/java/io/bootique/curator/CuratorModuleProviderTest.java rename to src/test/java/io/bootique/curator/CuratorModuleTest.java index 0aeb090..6e533dd 100644 --- a/src/test/java/io/bootique/curator/CuratorModuleProviderTest.java +++ b/src/test/java/io/bootique/curator/CuratorModuleTest.java @@ -22,10 +22,10 @@ import io.bootique.junit5.BQModuleProviderChecker; import org.junit.jupiter.api.Test; -public class CuratorModuleProviderTest { +public class CuratorModuleTest { @Test public void autoLoadable() { - BQModuleProviderChecker.testAutoLoadable(CuratorModuleProvider.class); + BQModuleProviderChecker.testAutoLoadable(CuratorModule.class); } }