1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.eclipse.aether.transport.file;
20
21 import javax.inject.Named;
22
23 import org.eclipse.aether.RepositorySystemSession;
24 import org.eclipse.aether.repository.RemoteRepository;
25 import org.eclipse.aether.spi.connector.transport.Transporter;
26 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
27 import org.eclipse.aether.transfer.NoTransporterException;
28
29 import static java.util.Objects.requireNonNull;
30
31 /**
32 * A transporter factory for repositories using the {@code file:} protocol.
33 */
34 @Named(FileTransporterFactory.NAME)
35 public final class FileTransporterFactory implements TransporterFactory {
36 public static final String NAME = "file";
37
38 private float priority;
39
40 /**
41 * Creates an (uninitialized) instance of this transporter factory. <em>Note:</em> In case of manual instantiation
42 * by clients, the new factory needs to be configured via its various mutators before first use or runtime errors
43 * will occur.
44 */
45 public FileTransporterFactory() {
46 // enables default constructor
47 }
48
49 public float getPriority() {
50 return priority;
51 }
52
53 /**
54 * Sets the priority of this component.
55 *
56 * @param priority The priority.
57 * @return This component for chaining, never {@code null}.
58 */
59 public FileTransporterFactory setPriority(float priority) {
60 this.priority = priority;
61 return this;
62 }
63
64 public Transporter newInstance(RepositorySystemSession session, RemoteRepository repository)
65 throws NoTransporterException {
66 requireNonNull(session, "session cannot be null");
67 requireNonNull(repository, "repository cannot be null");
68
69 return new FileTransporter(repository);
70 }
71 }