1 package org.apache.maven.resolver.examples.sisu;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import javax.inject.Inject;
23
24 import com.google.inject.Binder;
25 import com.google.inject.Module;
26 import org.eclipse.sisu.bean.LifecycleModule;
27 import org.eclipse.sisu.inject.MutableBeanLocator;
28 import org.eclipse.sisu.wire.ParameterKeys;
29
30
31
32
33 public class SisuRepositorySystemDemoModule implements Module
34 {
35 @Override
36 public void configure( final Binder binder )
37 {
38 binder.install( new LifecycleModule() );
39
40 binder.bind( ParameterKeys.PROPERTIES ).toInstance( System.getProperties() );
41 binder.bind( ShutdownThread.class ).asEagerSingleton();
42 }
43
44 static final class ShutdownThread
45 extends Thread
46 {
47 private final MutableBeanLocator locator;
48
49 @Inject
50 ShutdownThread( final MutableBeanLocator locator )
51 {
52 this.locator = locator;
53 Runtime.getRuntime().addShutdownHook( this );
54 }
55
56 @Override
57 public void run()
58 {
59 locator.clear();
60 }
61 }
62 }