creating Guice install(new OptionsModule() { protected void configure() { option("f") .hasArg() .withLongOpt("filename") .annotatedWith(Filename.class); // no need to call create() } }) // Inject into any class
@Singleton public class MyService {
@Inject public MyService(@Filename String filename) { } } // You can also inject CommandLine directly
@Singleton public class MyService {
@Inject public MyService(CommandLine commandLine) { } } }
@author elandau
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.