1 package org.apache.maven.resolver.examples.guice;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Collections;
23 import java.util.HashSet;
24 import java.util.Set;
25
26 import javax.inject.Named;
27 import javax.inject.Singleton;
28
29 import org.apache.maven.repository.internal.MavenAetherModule;
30 import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
31 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
32 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
33 import org.eclipse.aether.transport.file.FileTransporterFactory;
34 import org.eclipse.aether.transport.http.HttpTransporterFactory;
35
36 import com.google.inject.AbstractModule;
37 import com.google.inject.Provides;
38 import com.google.inject.name.Names;
39
40 class DemoResolverModule
41 extends AbstractModule
42 {
43
44 @Override
45 protected void configure()
46 {
47 install( new MavenAetherModule() );
48
49 bind( RepositoryConnectorFactory.class ).annotatedWith( Names.named( "basic" ) ).to( BasicRepositoryConnectorFactory.class );
50 bind( TransporterFactory.class ).annotatedWith( Names.named( "file" ) ).to( FileTransporterFactory.class );
51 bind( TransporterFactory.class ).annotatedWith( Names.named( "http" ) ).to( HttpTransporterFactory.class );
52 }
53
54 @Provides
55 @Singleton
56 Set<RepositoryConnectorFactory> provideRepositoryConnectorFactories( @Named( "basic" ) RepositoryConnectorFactory basic )
57 {
58 Set<RepositoryConnectorFactory> factories = new HashSet<RepositoryConnectorFactory>();
59 factories.add( basic );
60 return Collections.unmodifiableSet( factories );
61 }
62
63 @Provides
64 @Singleton
65 Set<TransporterFactory> provideTransporterFactories( @Named( "file" ) TransporterFactory file,
66 @Named( "http" ) TransporterFactory http )
67 {
68 Set<TransporterFactory> factories = new HashSet<TransporterFactory>();
69 factories.add( file );
70 factories.add( http );
71 return Collections.unmodifiableSet( factories );
72 }
73
74 }