Skip to content

Commit 5b74133

Browse files
authored
fix: singleton annotation locations (#1642)
### Motivation Some singleton annotations were located at the wrong places and should be moved to their respective factory methods. ### Modification The singleton annotation for the node configuration was located both on the implementation and the interface. This is not acceptable as scope annotations are not allowed on interfaces/abstract classes and the implementation is not relevant to the binding builder, therefore the annotation was ignored there anyway. Same applies to the wrapper configuration. ### Result The singleton scope annotations are now located at the factory methods rather than at locations where they don't have any effect.
1 parent 85defd7 commit 5b74133

File tree

4 files changed

+3
-5
lines changed

4 files changed

+3
-5
lines changed

node/api/src/main/java/eu/cloudnetservice/node/config/Configuration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
import eu.cloudnetservice.driver.cluster.NetworkClusterNode;
2121
import eu.cloudnetservice.driver.document.Document;
2222
import eu.cloudnetservice.driver.network.ssl.SSLConfiguration;
23-
import jakarta.inject.Singleton;
2423
import java.util.Collection;
2524
import java.util.Map;
2625
import lombok.NonNull;
2726

28-
@Singleton
2927
public interface Configuration {
3028

3129
boolean fileExists();

node/impl/src/main/java/eu/cloudnetservice/node/impl/config/JsonConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import java.util.function.Function;
4747
import lombok.NonNull;
4848

49-
@Singleton
5049
public final class JsonConfiguration implements Configuration {
5150

5251
public static final Path CONFIG_FILE_PATH = Path.of(
@@ -131,6 +130,7 @@ public JsonConfiguration() {
131130
}
132131

133132
@Factory
133+
@Singleton
134134
private static @NonNull Configuration loadFromFile(@NonNull DefaultInstallation installation) {
135135
if (Files.notExists(CONFIG_FILE_PATH)) {
136136
// register the setup if the file does not exist

wrapper-jvm/api/src/main/java/eu/cloudnetservice/wrapper/configuration/WrapperConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import eu.cloudnetservice.driver.network.ssl.SSLConfiguration;
2121
import eu.cloudnetservice.driver.service.ServiceConfiguration;
2222
import eu.cloudnetservice.driver.service.ServiceInfoSnapshot;
23-
import jakarta.inject.Singleton;
2423
import lombok.NonNull;
2524

2625
/**
@@ -29,7 +28,6 @@
2928
*
3029
* @since 4.0
3130
*/
32-
@Singleton
3331
public interface WrapperConfiguration {
3432

3533
/**

wrapper-jvm/impl/src/main/java/eu/cloudnetservice/wrapper/impl/configuration/DocumentWrapperConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import eu.cloudnetservice.driver.service.ServiceConfiguration;
2424
import eu.cloudnetservice.driver.service.ServiceInfoSnapshot;
2525
import eu.cloudnetservice.wrapper.configuration.WrapperConfiguration;
26+
import jakarta.inject.Singleton;
2627
import java.nio.file.Path;
2728
import lombok.NonNull;
2829

@@ -37,6 +38,7 @@ public record DocumentWrapperConfiguration(
3738
System.getProperty("cloudnet.wrapper.config.path", ".wrapper/wrapper.json"));
3839

3940
@Factory
41+
@Singleton
4042
public static @NonNull WrapperConfiguration load() {
4143
return DocumentFactory.json().parse(WRAPPER_CONFIG_PATH).toInstanceOf(DocumentWrapperConfiguration.class);
4244
}

0 commit comments

Comments
 (0)