-
Notifications
You must be signed in to change notification settings - Fork 12
Getting Started!
grouchal edited this page Dec 20, 2011
·
5 revisions
- Add Maven Dependency
<dependency>
<groupId>de.devsurf.injection.guice.scanner</groupId>
<artifactId>de.devsurf.injection.guice.scanner.asm</artifactId>
<version>0.8.7</version>
</dependency>
- Create one Interface
public interface WorldSpeaker {
String speak();
}
- Create one Implementation
@Bind
public class SayHelloWorld implements WorldSpeaker {
@Override
public String speak() {
return "Hello World!";
}
}
- Choose Package to scan
PackageFilter filter = new PackageFilter("de.devsurf", "true"); //or use one of the PackageFilter.create(..)-Methods
- Choose Classpath Scanner Implementation & Create Startup Module
StartupModule startup= StartupModule.create(ASMClasspathScanner.class, filter);
- Add additional Features (optional)
startup.addFeature(InterceptorFeature.class);
- Create Injector
Injector injector = Guice.createInjector(startup);
- That's it...
There is no big difference. The only thing is, that you have to annotate your Implemenations. The rest is just magic... :)