-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
core/src/main/java/ch/cyberduck/core/serviceloader/AnnotationAutoServiceLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ch.cyberduck.core.serviceloader; | ||
|
||
/* | ||
* Copyright (c) 2002-2024 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import java.util.HashSet; | ||
import java.util.ServiceLoader; | ||
import java.util.Set; | ||
|
||
public class AnnotationAutoServiceLoader<T> implements AutoServiceLoader<T> { | ||
|
||
@Override | ||
public Set<T> load(final Class<T> type) { | ||
final ServiceLoader<T> loader = ServiceLoader.load(type); | ||
final Set<T> services = new HashSet<>(); | ||
for(T t : loader) { | ||
services.add(t); | ||
} | ||
return services; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
core/src/main/java/ch/cyberduck/core/serviceloader/AutoServiceLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ch.cyberduck.core.serviceloader; | ||
|
||
/* | ||
* Copyright (c) 2002-2024 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import java.util.Set; | ||
|
||
public interface AutoServiceLoader<T> { | ||
Set<T> load(Class<T> type); | ||
} |
32 changes: 32 additions & 0 deletions
32
core/src/main/java/ch/cyberduck/core/serviceloader/AutoServiceLoaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ch.cyberduck.core.serviceloader; | ||
|
||
/* | ||
* Copyright (c) 2012 David Kocher. All rights reserved. | ||
* http://cyberduck.ch/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* Bug fixes, suggestions and comments should be sent to: | ||
* dkocher@cyberduck.ch | ||
*/ | ||
|
||
import ch.cyberduck.core.Factory; | ||
|
||
public class AutoServiceLoaderFactory extends Factory<AutoServiceLoader> { | ||
|
||
private AutoServiceLoaderFactory() { | ||
super("factory.autoserviceloader.class"); | ||
} | ||
|
||
public static <T> AutoServiceLoader<T> get() { | ||
return new AutoServiceLoaderFactory().create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters