1 package org.eclipse.aether.internal.impl;
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 import javax.inject.Named;
24 import javax.inject.Singleton;
25
26 import java.util.Objects;
27
28 import org.eclipse.aether.RepositorySystemSession;
29 import org.eclipse.aether.repository.LocalRepository;
30 import org.eclipse.aether.repository.LocalRepositoryManager;
31 import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
32 import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
33 import org.eclipse.aether.spi.locator.Service;
34 import org.eclipse.aether.spi.locator.ServiceLocator;
35
36 import static java.util.Objects.requireNonNull;
37
38
39
40
41 @Singleton
42 @Named( "simple" )
43 public class SimpleLocalRepositoryManagerFactory
44 implements LocalRepositoryManagerFactory, Service
45 {
46 private float priority;
47
48 private LocalPathComposer localPathComposer;
49
50 public SimpleLocalRepositoryManagerFactory()
51 {
52
53 this.localPathComposer = new DefaultLocalPathComposer();
54 }
55
56 @Inject
57 public SimpleLocalRepositoryManagerFactory( final LocalPathComposer localPathComposer )
58 {
59 this.localPathComposer = requireNonNull( localPathComposer );
60 }
61
62 @Override
63 public void initService( final ServiceLocator locator )
64 {
65 this.localPathComposer = Objects.requireNonNull( locator.getService( LocalPathComposer.class ) );
66 }
67
68 @Override
69 public LocalRepositoryManager newInstance( RepositorySystemSession session, LocalRepository repository )
70 throws NoLocalRepositoryManagerException
71 {
72 requireNonNull( session, "session cannot be null" );
73 requireNonNull( repository, "repository cannot be null" );
74
75 if ( "".equals( repository.getContentType() ) || "simple".equals( repository.getContentType() ) )
76 {
77 return new SimpleLocalRepositoryManager( repository.getBasedir(), "simple", localPathComposer );
78 }
79 else
80 {
81 throw new NoLocalRepositoryManagerException( repository );
82 }
83 }
84
85 @Override
86 public float getPriority()
87 {
88 return priority;
89 }
90
91
92
93
94
95
96
97 public SimpleLocalRepositoryManagerFactory setPriority( float priority )
98 {
99 this.priority = priority;
100 return this;
101 }
102
103 }