// Path: monica-framework/src/main/java/monica/framework/extension/ExtensionProvider.java
// public class ExtensionProvider {
// 	private static final String basePath = "META-INF/monica/internal";
// 
// 	public static Class<?> getDefaultExtension(Class<?> c) throws ClassNotFoundException {
// 		SPI cSpi = c.getAnnotation(SPI.class);
// 		String spiValue = cSpi.value();
// 		String fileName = c.getName();
// 		String className = loadFile(fileName, spiValue);
// 		return getClassLoader().loadClass(className);
// 	}
// 
// 	private static String loadFile(String fileName, String key) {
// 		URL url = getClassLoader().getResource(basePath + "/" + fileName);
// 		if (null != url) {
// 			try {
// 				BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));
// 				String line = "";
// 
// 				while ((line = reader.readLine()) != null) {
// 					int index = line.trim().indexOf("=");
// 					if (index > 0 && line.substring(0, index).equals(key)) {
// 						return line.substring(index + 1);
// 					}
// 				}
// 
// 			} catch (UnsupportedEncodingException e) {
// 				// TODO Auto-generated catch block
// 				e.printStackTrace();
// 			} catch (IOException e) {
// 				// TODO Auto-generated catch block
// 				e.printStackTrace();
// 			}
// 		}
// 
// 		return null;
// 	}
// 
// 	private static ClassLoader getClassLoader() {
// 		return ExtensionProvider.class.getClassLoader();
// 	}
// 
// 	public static void main(String args[]) {
// 		ExtensionProvider provider = new ExtensionProvider();
// 		//provider.getDefaultExtension(ConfigService.class);
// 	}
// }
// 
// Path: monica-registry/src/main/java/monica/registry/Registration.java
// @SPI(ZookeeperRegistration.NAME)
// public interface Registration {
// 	final Logger log = Logger.getLogger(Registration.class);
// 
// 	public void register(UriSpec uri, RegistryType type) throws Exception;
// 
// 	public boolean done();
// 
// }


import monica.framework.extension.ExtensionProvider;
import monica.registry.Registration;

package monica.registry.service;


/**
 * 
 * @author lucy@polarcoral.com
 *
 *         2017-08-29
 */

public class RegistrationFactory {

	public static Registration getRegistryService()
			throws InstantiationException, ClassNotFoundException, IllegalAccessException {

// Path: monica-framework/src/main/java/monica/framework/extension/ExtensionProvider.java
// public class ExtensionProvider {
// 	private static final String basePath = "META-INF/monica/internal";
// 
// 	public static Class<?> getDefaultExtension(Class<?> c) throws ClassNotFoundException {
// 		SPI cSpi = c.getAnnotation(SPI.class);
// 		String spiValue = cSpi.value();
// 		String fileName = c.getName();
// 		String className = loadFile(fileName, spiValue);
// 		return getClassLoader().loadClass(className);
// 	}
// 
// 	private static String loadFile(String fileName, String key) {
// 		URL url = getClassLoader().getResource(basePath + "/" + fileName);
// 		if (null != url) {
// 			try {
// 				BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));
// 				String line = "";
// 
// 				while ((line = reader.readLine()) != null) {
// 					int index = line.trim().indexOf("=");
// 					if (index > 0 && line.substring(0, index).equals(key)) {
// 						return line.substring(index + 1);
// 					}
// 				}
// 
// 			} catch (UnsupportedEncodingException e) {
// 				// TODO Auto-generated catch block
// 				e.printStackTrace();
// 			} catch (IOException e) {
// 				// TODO Auto-generated catch block
// 				e.printStackTrace();
// 			}
// 		}
// 
// 		return null;
// 	}
// 
// 	private static ClassLoader getClassLoader() {
// 		return ExtensionProvider.class.getClassLoader();
// 	}
// 
// 	public static void main(String args[]) {
// 		ExtensionProvider provider = new ExtensionProvider();
// 		//provider.getDefaultExtension(ConfigService.class);
// 	}
// }
// 
// Path: monica-registry/src/main/java/monica/registry/Registration.java
// @SPI(ZookeeperRegistration.NAME)
// public interface Registration {
// 	final Logger log = Logger.getLogger(Registration.class);
// 
// 	public void register(UriSpec uri, RegistryType type) throws Exception;
// 
// 	public boolean done();
// 
// }


// Path: monica-registry/src/main/java/monica/registry/service/RegistrationFactory.java
import monica.framework.extension.ExtensionProvider;
import monica.registry.Registration;

package monica.registry.service;


/**
 * 
 * @author lucy@polarcoral.com
 *
 *         2017-08-29
 */

public class RegistrationFactory {

	public static Registration getRegistryService()
			throws InstantiationException, ClassNotFoundException, IllegalAccessException {

		Registration service = (Registration) ExtensionProvider.getDefaultExtension(Registration.class).newInstance();
