You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: core/common/boot/src/main/java/org/eclipse/dataspaceconnector/boot/system/DefaultServiceExtensionContext.java
+14-6
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ public class DefaultServiceExtensionContext implements ServiceExtensionContext {
@@ -51,6 +52,16 @@ public DefaultServiceExtensionContext(TypeManager typeManager, Monitor monitor,
51
52
registerService(Clock.class, Clock.systemUTC());
52
53
}
53
54
55
+
@Override
56
+
publicConfiggetConfig(Stringpath) {
57
+
returnconfig.getConfig(path);
58
+
}
59
+
60
+
@Override
61
+
publicvoidfreeze() {
62
+
isReadOnly = true;
63
+
}
64
+
54
65
@Override
55
66
publicStringgetConnectorId() {
56
67
returnconnectorId;
@@ -80,6 +91,9 @@ public <T> T getService(Class<T> type, boolean isOptional) {
80
91
81
92
@Override
82
93
public <T> voidregisterService(Class<T> type, Tservice) {
94
+
if (isReadOnly) {
95
+
thrownewEdcException("Cannot register service " + type.getName() + ", the ServiceExtensionContext is in read-only mode.");
96
+
}
83
97
if (hasService(type)) {
84
98
getMonitor().warning("A service of the type " + type.getCanonicalName() + " was already registered and has now been replaced with a " + service.getClass().getSimpleName() + " instance.");
Copy file name to clipboardexpand all lines: core/common/boot/src/test/java/org/eclipse/dataspaceconnector/boot/system/DefaultServiceExtensionContextTest.java
Copy file name to clipboardexpand all lines: extensions/common/junit/src/test/java/org/eclipse/dataspaceconnector/junit/extensions/EdcExtensionTest.java
* Freeze the context. It should mark the ServiceExtensionContext as read-only, preventing the registration
31
+
* of new services after the initialization phase
32
+
*/
33
+
defaultvoidfreeze() {
34
+
35
+
}
36
+
29
37
/**
30
38
* Fetches the unique ID of the connector. If the {@code dataspaceconnector.connector.name} config value has been set, that value is returned; otherwise a random
0 commit comments