1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.session.scope.internal;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23
24 import com.google.inject.AbstractModule;
25 import org.apache.maven.SessionScoped;
26 import org.apache.maven.execution.MavenSession;
27 import org.codehaus.plexus.PlexusContainer;
28 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
29 import org.eclipse.aether.RepositorySystemSession;
30
31
32
33
34 @Named
35 public class SessionScopeModule extends AbstractModule {
36 private final SessionScope scope;
37
38 @Inject
39 public SessionScopeModule() {
40 this(new SessionScope());
41 }
42
43 public SessionScopeModule(PlexusContainer container) throws ComponentLookupException {
44 this(container.lookup(SessionScope.class));
45 }
46
47 private SessionScopeModule(SessionScope scope) {
48 this.scope = scope;
49 }
50
51 @Override
52 protected void configure() {
53 bindScope(SessionScoped.class, scope);
54 bind(SessionScope.class).toInstance(scope);
55
56 bind(MavenSession.class).toProvider(SessionScope.seededKeyProvider()).in(scope);
57 bind(RepositorySystemSession.class)
58 .toProvider(SessionScope.seededKeyProvider())
59 .in(scope);
60 }
61 }