Skip to content

Commit

Permalink
[MRESOLVER-157] Drop Service Locator
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Oct 14, 2023
1 parent e767658 commit eb1aaf7
Show file tree
Hide file tree
Showing 71 changed files with 498 additions and 2,445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import javax.inject.Inject;
import javax.inject.Named;

import java.util.Collections;
import java.util.Map;

import org.eclipse.aether.RepositorySystemSession;
Expand All @@ -33,8 +32,6 @@
import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
import org.eclipse.aether.spi.connector.transport.TransporterProvider;
import org.eclipse.aether.spi.io.FileProcessor;
import org.eclipse.aether.spi.locator.Service;
import org.eclipse.aether.spi.locator.ServiceLocator;
import org.eclipse.aether.transfer.NoRepositoryConnectorException;

import static java.util.Objects.requireNonNull;
Expand All @@ -45,110 +42,36 @@
* {@link org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory repository layouts} for the transfers.
*/
@Named(BasicRepositoryConnectorFactory.NAME)
public final class BasicRepositoryConnectorFactory implements RepositoryConnectorFactory, Service {
public final class BasicRepositoryConnectorFactory implements RepositoryConnectorFactory {
public static final String NAME = "basic";
private TransporterProvider transporterProvider;
private final TransporterProvider transporterProvider;

private RepositoryLayoutProvider layoutProvider;
private final RepositoryLayoutProvider layoutProvider;

private ChecksumPolicyProvider checksumPolicyProvider;
private final ChecksumPolicyProvider checksumPolicyProvider;

private FileProcessor fileProcessor;
private final FileProcessor fileProcessor;

private Map<String, ProvidedChecksumsSource> providedChecksumsSources;
private final Map<String, ProvidedChecksumsSource> providedChecksumsSources;

private float priority;

/**
* Creates an (uninitialized) instance of this connector factory. <em>Note:</em> In case of manual instantiation by
* clients, the new factory needs to be configured via its various mutators before first use or runtime errors will
* occur.
*/
@Deprecated
public BasicRepositoryConnectorFactory() {
// enables default constructor
}

@Inject
public BasicRepositoryConnectorFactory(
TransporterProvider transporterProvider,
RepositoryLayoutProvider layoutProvider,
ChecksumPolicyProvider checksumPolicyProvider,
FileProcessor fileProcessor,
Map<String, ProvidedChecksumsSource> providedChecksumsSources) {
setTransporterProvider(transporterProvider);
setRepositoryLayoutProvider(layoutProvider);
setChecksumPolicyProvider(checksumPolicyProvider);
setFileProcessor(fileProcessor);
setProvidedChecksumSources(providedChecksumsSources);
}

public void initService(ServiceLocator locator) {
setTransporterProvider(locator.getService(TransporterProvider.class));
setRepositoryLayoutProvider(locator.getService(RepositoryLayoutProvider.class));
setChecksumPolicyProvider(locator.getService(ChecksumPolicyProvider.class));
setFileProcessor(locator.getService(FileProcessor.class));
setProvidedChecksumSources(Collections.emptyMap());
}

/**
* Sets the transporter provider to use for this component.
*
* @param transporterProvider The transporter provider to use, must not be {@code null}.
* @return This component for chaining, never {@code null}.
*/
public BasicRepositoryConnectorFactory setTransporterProvider(TransporterProvider transporterProvider) {
this.transporterProvider = requireNonNull(transporterProvider, "transporter provider cannot be null");
return this;
}

/**
* Sets the repository layout provider to use for this component.
*
* @param layoutProvider The repository layout provider to use, must not be {@code null}.
* @return This component for chaining, never {@code null}.
*/
public BasicRepositoryConnectorFactory setRepositoryLayoutProvider(RepositoryLayoutProvider layoutProvider) {
this.layoutProvider = requireNonNull(layoutProvider, "repository layout provider cannot be null");
return this;
}

/**
* Sets the checksum policy provider to use for this component.
*
* @param checksumPolicyProvider The checksum policy provider to use, must not be {@code null}.
* @return This component for chaining, never {@code null}.
*/
public BasicRepositoryConnectorFactory setChecksumPolicyProvider(ChecksumPolicyProvider checksumPolicyProvider) {
this.checksumPolicyProvider = requireNonNull(checksumPolicyProvider, "checksum policy provider cannot be null");
return this;
}

/**
* Sets the file processor to use for this component.
*
* @param fileProcessor The file processor to use, must not be {@code null}.
* @return This component for chaining, never {@code null}.
*/
public BasicRepositoryConnectorFactory setFileProcessor(FileProcessor fileProcessor) {
this.fileProcessor = requireNonNull(fileProcessor, "file processor cannot be null");
return this;
}

/**
* Sets the provided checksum sources to use for this component.
*
* @param providedChecksumsSources The provided checksum sources to use, must not be {@code null}.
* @return This component for chaining, never {@code null}.
* @since 1.8.0
*/
public BasicRepositoryConnectorFactory setProvidedChecksumSources(
Map<String, ProvidedChecksumsSource> providedChecksumsSources) {
this.providedChecksumsSources =
requireNonNull(providedChecksumsSources, "provided checksum sources cannot be null");
return this;
}

@Override
public float getPriority() {
return priority;
}
Expand All @@ -164,6 +87,7 @@ public BasicRepositoryConnectorFactory setPriority(float priority) {
return this;
}

@Override
public RepositoryConnector newInstance(RepositorySystemSession session, RemoteRepository repository)
throws NoRepositoryConnectorException {
requireNonNull(session, "session cannot be null");
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit eb1aaf7

Please sign in to comment.