package cruzgtug.example.guice; import com.google.inject.Inject; import com.google.inject.name.Named; /** * This is an example implementation, which provides an API for saying * hello. * * @author esmiley * */ public class HelloImpl implements Hello { private String hello; /** * This constructor has an @Inject annotation so it will get injected by * Guice. * * But where does its hello parameter come from? * Well, the String parameter has an @Named annotation, so a Provider will * furnish a matching string. * * That gives the injection for its modules the * ability to distinguish between different instances of the same object * (String) used for different purposes. * @param hello */ @Inject HelloImpl(@Named("HelloString") String hello){ this.hello = hello; } /** * The implementation logic, such as it is. */ public void hello() { System.out.println(hello); } }