Skip to content

Commit

Permalink
Load protocols using service loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Nov 25, 2024
1 parent a36283c commit b3016be
Show file tree
Hide file tree
Showing 36 changed files with 149 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.LoginOptions;
import ch.cyberduck.core.PathContainerService;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.text.DefaultLexicographicOrderComparator;

import java.util.Comparator;

import com.microsoft.azure.storage.core.Base64;
import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class AzureProtocol extends AbstractProtocol {

@Override
Expand Down
3 changes: 3 additions & 0 deletions backblaze/src/main/java/ch/cyberduck/core/b2/B2Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.PathContainerService;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.synchronization.ComparisonService;
import ch.cyberduck.core.synchronization.DefaultComparisonService;
import ch.cyberduck.core.synchronization.VersionIdComparisonService;
import ch.cyberduck.core.text.DefaultLexicographicOrderComparator;

import java.util.Comparator;
import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class B2Protocol extends AbstractProtocol {

@Override
Expand Down
3 changes: 3 additions & 0 deletions box/src/main/java/ch/cyberduck/core/box/BoxProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
*/

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.synchronization.ComparisonService;
import ch.cyberduck.core.synchronization.DefaultComparisonService;
import ch.cyberduck.core.synchronization.ETagComparisonService;
import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class BoxProtocol extends AbstractProtocol {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
import ch.cyberduck.core.Credentials;
import ch.cyberduck.core.CredentialsConfigurator;
import ch.cyberduck.core.LoginOptions;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.features.Pairing;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class BrickProtocol extends AbstractProtocol {

@Override
Expand Down
65 changes: 4 additions & 61 deletions cli/src/main/java/ch/cyberduck/cli/Terminal.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,25 @@
*/

import ch.cyberduck.core.*;
import ch.cyberduck.core.azure.AzureProtocol;
import ch.cyberduck.core.b2.B2Protocol;
import ch.cyberduck.core.box.BoxProtocol;
import ch.cyberduck.core.brick.BrickProtocol;
import ch.cyberduck.core.cdn.Distribution;
import ch.cyberduck.core.ctera.CteraProtocol;
import ch.cyberduck.core.dav.DAVProtocol;
import ch.cyberduck.core.dav.DAVSSLProtocol;
import ch.cyberduck.core.deepbox.DeepboxProtocol;
import ch.cyberduck.core.dropbox.DropboxProtocol;
import ch.cyberduck.core.editor.DefaultEditorListener;
import ch.cyberduck.core.editor.Editor;
import ch.cyberduck.core.editor.EditorFactory;
import ch.cyberduck.core.exception.AccessDeniedException;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.exception.NotfoundException;
import ch.cyberduck.core.ftp.FTPProtocol;
import ch.cyberduck.core.ftp.FTPTLSProtocol;
import ch.cyberduck.core.googledrive.DriveProtocol;
import ch.cyberduck.core.googlestorage.GoogleStorageProtocol;
import ch.cyberduck.core.hubic.HubicProtocol;
import ch.cyberduck.core.io.DisabledStreamListener;
import ch.cyberduck.core.irods.IRODSProtocol;
import ch.cyberduck.core.local.Application;
import ch.cyberduck.core.local.ApplicationFinder;
import ch.cyberduck.core.local.ApplicationFinderFactory;
import ch.cyberduck.core.local.TemporaryFileServiceFactory;
import ch.cyberduck.core.logging.LoggerPrintStream;
import ch.cyberduck.core.manta.MantaProtocol;
import ch.cyberduck.core.nextcloud.NextcloudProtocol;
import ch.cyberduck.core.nio.LocalProtocol;
import ch.cyberduck.core.onedrive.OneDriveProtocol;
import ch.cyberduck.core.onedrive.SharepointProtocol;
import ch.cyberduck.core.onedrive.SharepointSiteProtocol;
import ch.cyberduck.core.openstack.SwiftProtocol;
import ch.cyberduck.core.owncloud.OwncloudProtocol;
import ch.cyberduck.core.pool.SessionPool;
import ch.cyberduck.core.preferences.Preferences;
import ch.cyberduck.core.preferences.PreferencesFactory;
import ch.cyberduck.core.s3.S3Protocol;
import ch.cyberduck.core.sds.SDSProtocol;
import ch.cyberduck.core.sftp.SFTPProtocol;
import ch.cyberduck.core.smb.SMBProtocol;
import ch.cyberduck.core.spectra.SpectraProtocol;
import ch.cyberduck.core.ssl.CertificateStoreX509TrustManager;
import ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback;
import ch.cyberduck.core.ssl.PreferencesX509KeyManager;
import ch.cyberduck.core.storegate.StoregateProtocol;
import ch.cyberduck.core.threading.DisabledAlertCallback;
import ch.cyberduck.core.threading.DisconnectBackgroundAction;
import ch.cyberduck.core.threading.SessionBackgroundAction;
Expand Down Expand Up @@ -103,6 +74,7 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;

Expand Down Expand Up @@ -135,38 +107,9 @@ public Terminal(final TerminalPreferences defaults, final Options options, final
public Terminal(final ProtocolFactory protocols, final TerminalPreferences defaults, final Options options, final CommandLine input) {
this.protocols = protocols;
this.preferences = defaults.withDefaults(input);
this.protocols.register(
new FTPProtocol(),
new FTPTLSProtocol(),
new SFTPProtocol(),
new DAVProtocol(),
new DAVSSLProtocol(),
new SMBProtocol(),
new SwiftProtocol(),
new S3Protocol(),
new GoogleStorageProtocol(),
new AzureProtocol(),
new IRODSProtocol(),
new SpectraProtocol(),
new B2Protocol(),
new DriveProtocol(),
new HubicProtocol(),
new DropboxProtocol(),
new DropboxProtocol(),
new OneDriveProtocol(),
new SharepointProtocol(),
new SharepointSiteProtocol(),
new LocalProtocol(),
new SDSProtocol(),
new MantaProtocol(),
new StoregateProtocol(),
new BrickProtocol(),
new NextcloudProtocol(),
new OwncloudProtocol(),
new CteraProtocol(),
new BoxProtocol(),
new DeepboxProtocol()
);
for(Protocol p : ServiceLoader.load(Protocol.class)) {
protocols.register(p);
}
this.options = options;
log.info("Parsed options {} from input {}", options, input);
this.input = input;
Expand Down
5 changes: 5 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
<groupId>com.joyent.util</groupId>
<artifactId>fast-md5</artifactId>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.Credentials;
import ch.cyberduck.core.LoginOptions;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.dav.DAVSSLProtocol;
import ch.cyberduck.core.preferences.PreferencesFactory;
import ch.cyberduck.core.synchronization.ComparisonService;
import ch.cyberduck.core.synchronization.DefaultComparisonService;
import ch.cyberduck.core.synchronization.ETagComparisonService;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class CteraProtocol extends AbstractProtocol {

public static final String CTERA_REDIRECT_URI = String.format("%s:websso",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
*/

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class DeepboxProtocol extends AbstractProtocol {
@Override
public String getIdentifier() {
Expand Down
4 changes: 4 additions & 0 deletions dracoon/src/main/java/ch/cyberduck/core/sds/SDSProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.features.Pairing;
import ch.cyberduck.core.features.Scheduler;
Expand All @@ -29,6 +30,9 @@

import org.apache.commons.lang3.StringUtils;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class SDSProtocol extends AbstractProtocol {
@Override
public String getIdentifier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class DropboxProtocol extends AbstractProtocol {

@Override
Expand Down
4 changes: 4 additions & 0 deletions eue/src/main/java/ch/cyberduck/core/eue/EueProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
*/

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.synchronization.ComparisonService;
import ch.cyberduck.core.synchronization.DefaultComparisonService;
import ch.cyberduck.core.synchronization.ETagComparisonService;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class EueProtocol extends AbstractProtocol {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
*/

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.WebUrlProvider;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class FreenetProtocol extends AbstractProtocol {

@Override
Expand Down
4 changes: 4 additions & 0 deletions ftp/src/main/java/ch/cyberduck/core/ftp/FTPProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;

import org.apache.commons.lang3.StringUtils;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class FTPProtocol extends AbstractProtocol {

@Override
Expand Down
4 changes: 4 additions & 0 deletions ftp/src/main/java/ch/cyberduck/core/ftp/FTPTLSProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;

import org.apache.commons.lang3.StringUtils;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class FTPTLSProtocol extends AbstractProtocol {
@Override
public String getIdentifier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class DriveProtocol extends AbstractProtocol {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ch.cyberduck.core.DirectoryDelimiterPathContainerService;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.PathContainerService;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.features.Location;
import ch.cyberduck.core.synchronization.ChainedComparisonService;
Expand All @@ -38,6 +39,9 @@
import java.util.Set;
import java.util.stream.Collectors;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public final class GoogleStorageProtocol extends AbstractProtocol {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.openstack.SwiftProtocol;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class HubicProtocol extends AbstractProtocol {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;

import org.apache.commons.lang3.StringUtils;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public final class IRODSProtocol extends AbstractProtocol {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
*/

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class MantaProtocol extends AbstractProtocol {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@

import ch.cyberduck.core.AbstractProtocol;
import ch.cyberduck.core.CredentialsConfigurator;
import ch.cyberduck.core.Protocol;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.WindowsIntegratedCredentialsConfigurator;
import ch.cyberduck.core.dav.DAVSSLProtocol;
import ch.cyberduck.core.synchronization.ComparisonService;
import ch.cyberduck.core.synchronization.DefaultComparisonService;
import ch.cyberduck.core.synchronization.ETagComparisonService;

import com.google.auto.service.AutoService;

@AutoService(Protocol.class)
public class NextcloudProtocol extends AbstractProtocol {

@Override
Expand Down
Loading

0 comments on commit b3016be

Please sign in to comment.