// Path: java-plugin-architecture/java-spi/src/main/java/com/link_intersystems/blog/plugin/spi/GreetingService.java
// public interface GreetingService {
// 
// 	public String greet(Person person);
// }
// 
// Path: java-plugin-architecture/java-spi/src/main/java/com/link_intersystems/blog/plugin/spi/Person.java
// public interface Person {
// 	public String getFirstname();
// 
// 	public String getLastname();
// 
// 	public Gender getGender();
// }
// 
// Path: java-plugin-architecture/java-spi/src/main/java/com/link_intersystems/blog/plugin/spi/Gender.java
// public enum Gender {
// 	MALE, FEMALE, UNKNOWN;
// }


import java.text.MessageFormat;
import java.util.Iterator;
import java.util.ServiceLoader;
import com.link_intersystems.blog.plugin.spi.GreetingService;
import com.link_intersystems.blog.plugin.spi.Person;
import com.link_intersystems.blog.plugin.spi.Gender;
package com.link_intersystems.blog.plugin.client;



public class GreetingApp {

	public static void main(String[] args) {
		ServiceLoader<GreetingService> greetingServiceLoader = ServiceLoader.load(GreetingService.class);

		Iterator<GreetingService> greetingServices = greetingServiceLoader.iterator();
		if (!greetingServices.hasNext()) {
			throw new IllegalStateException("No GreetingService provider found");
		}

		Person person = new MainArgsPersonAdapter(args);

		while (greetingServices.hasNext()) {
			GreetingService greetingService = greetingServices.next();
			String greeting = greetingService.greet(person);
			Class<? extends GreetingService> serviceImplClass = greetingService.getClass();
			String simpleServiceName = serviceImplClass.getSimpleName();
			String msg = MessageFormat.format("Greeting by provider {0}: {1}", simpleServiceName, greeting);
			System.out.println(msg);
		}
	}

// Path: java-plugin-architecture/java-spi/src/main/java/com/link_intersystems/blog/plugin/spi/GreetingService.java
// public interface GreetingService {
// 
// 	public String greet(Person person);
// }
// 
// Path: java-plugin-architecture/java-spi/src/main/java/com/link_intersystems/blog/plugin/spi/Person.java
// public interface Person {
// 	public String getFirstname();
// 
// 	public String getLastname();
// 
// 	public Gender getGender();
// }
// 
// Path: java-plugin-architecture/java-spi/src/main/java/com/link_intersystems/blog/plugin/spi/Gender.java
// public enum Gender {
// 	MALE, FEMALE, UNKNOWN;
// }


// Path: java-plugin-architecture/java-spi-client/src/main/java/com/link_intersystems/blog/plugin/client/GreetingApp.java
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.ServiceLoader;
import com.link_intersystems.blog.plugin.spi.GreetingService;
import com.link_intersystems.blog.plugin.spi.Person;
import com.link_intersystems.blog.plugin.spi.Gender;

package com.link_intersystems.blog.plugin.client;



public class GreetingApp {

	public static void main(String[] args) {
		ServiceLoader<GreetingService> greetingServiceLoader = ServiceLoader.load(GreetingService.class);

		Iterator<GreetingService> greetingServices = greetingServiceLoader.iterator();
		if (!greetingServices.hasNext()) {
			throw new IllegalStateException("No GreetingService provider found");
		}

		Person person = new MainArgsPersonAdapter(args);

		while (greetingServices.hasNext()) {
			GreetingService greetingService = greetingServices.next();
			String greeting = greetingService.greet(person);
			Class<? extends GreetingService> serviceImplClass = greetingService.getClass();
			String simpleServiceName = serviceImplClass.getSimpleName();
			String msg = MessageFormat.format("Greeting by provider {0}: {1}", simpleServiceName, greeting);
			System.out.println(msg);
		}
	}

	public static class MainArgsPersonAdapter implements Person {