package io.bootique.curator;

import com.google.inject.Provides;
import io.bootique.ConfigModule;
import io.bootique.config.ConfigurationFactory;
import io.bootique.log.BootLogger;
import io.bootique.shutdown.ShutdownManager;
import org.apache.curator.framework.CuratorFramework;

public class CuratorModule extends ConfigModule {

	public CuratorModule(String configPrefix) {
		super(configPrefix);
	}

	public CuratorModule() {
	}

	@Provides
	public CuratorFramework createCurator(ConfigurationFactory configFactory, BootLogger bootLogger,
										  ShutdownManager shutdownManager) {
		CuratorFramework client = configFactory.config(CuratorFrameworkFactory.class, configPrefix).createZkClient();

		shutdownManager.addShutdownHook(() -> {
			bootLogger.trace(() -> "shutting down Curator...");
			client.close();
		});

		client.start();

		return client;
	}
}

@@ -58,16 +58,52 @@
 ovides;%0A
+import com.google.inject.Singleton;%0A
 import i
@@ -474,16 +474,28 @@
 rovides%0A
+%09@Singleton%0A
 %09public 

Curator instance should be a singleton