1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.inject.Singleton;
24
25 import org.eclipse.aether.RepositorySystemSession;
26 import org.eclipse.aether.repository.LocalRepository;
27 import org.eclipse.aether.repository.LocalRepositoryManager;
28 import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
29 import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
30
31 import static java.util.Objects.requireNonNull;
32
33
34
35
36 @Singleton
37 @Named(SimpleLocalRepositoryManagerFactory.NAME)
38 public class SimpleLocalRepositoryManagerFactory implements LocalRepositoryManagerFactory {
39 public static final String NAME = "simple";
40 private float priority;
41
42 private final LocalPathComposer localPathComposer;
43
44
45
46
47 public SimpleLocalRepositoryManagerFactory() {
48 this.localPathComposer = new DefaultLocalPathComposer();
49 }
50
51 @Inject
52 public SimpleLocalRepositoryManagerFactory(final LocalPathComposer localPathComposer) {
53 this.localPathComposer = requireNonNull(localPathComposer);
54 }
55
56 @Override
57 public LocalRepositoryManager newInstance(RepositorySystemSession session, LocalRepository repository)
58 throws NoLocalRepositoryManagerException {
59 requireNonNull(session, "session cannot be null");
60 requireNonNull(repository, "repository cannot be null");
61
62 if ("".equals(repository.getContentType()) || "simple".equals(repository.getContentType())) {
63 return new SimpleLocalRepositoryManager(repository.getBasedir(), "simple", localPathComposer);
64 } else {
65 throw new NoLocalRepositoryManagerException(repository);
66 }
67 }
68
69 @Override
70 public float getPriority() {
71 return priority;
72 }
73
74
75
76
77
78
79
80 public SimpleLocalRepositoryManagerFactory setPriority(float priority) {
81 this.priority = priority;
82 return this;
83 }
84 }