1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.apache.onami.autobind.example.starter; |
17 | |
|
18 | |
import java.util.Set; |
19 | |
|
20 | |
import org.apache.onami.autobind.scanner.PackageFilter; |
21 | |
import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner; |
22 | |
|
23 | |
import com.google.inject.Guice; |
24 | |
import com.google.inject.Injector; |
25 | |
import com.google.inject.Key; |
26 | |
import com.google.inject.TypeLiteral; |
27 | |
|
28 | |
|
29 | 0 | public class ExampleStarter { |
30 | |
public static void main(String[] args) { |
31 | 0 | Injector injector = Guice.createInjector(new ExampleStartupModule(ASMClasspathScanner.class, PackageFilter.create("de.devsurf.injection.guice"))); |
32 | |
|
33 | 0 | Key<Set<ExampleApplication>> key = Key.get(new TypeLiteral<Set<ExampleApplication>>() { |
34 | |
}); |
35 | 0 | Set<ExampleApplication> apps = injector.getInstance(key); |
36 | 0 | for (ExampleApplication app : apps) { |
37 | 0 | System.out.println("Starting App: " + app.getClass().getName()); |
38 | 0 | app.run(); |
39 | 0 | System.out.println(); |
40 | |
} |
41 | 0 | System.out.println("Run " + apps.size() + " Applications."); |
42 | 0 | } |
43 | |
} |