Skip to content

Commit 1d7550e

Browse files
authored
add support for io-services (#1416)
1 parent da8dcc1 commit 1d7550e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

common-tools/clas-io/src/main/java/org/jlab/utils/ClaraYaml.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ public JSONObject filter(String serviceName) {
143143

144144
/**
145145
* Emulate the way CLARA parses the full YAML and presents it in EngineData.
146-
* The "global" and "service" subsections in the "configuration" section get
147-
* squashed into one namespace, and service-specific keys override any
148-
* globals of the same name.
146+
*
147+
* The YAML's "global" and "services" configuration sections get squashed
148+
* into one namespace, with service-specific parameters overriding globals
149+
* of the same name. Also, for the special services named "reader" and
150+
* "writer", the "io-services" section is searched instead of "services".
149151
*
150152
* @param claraJson the full CLARA YAML contents
151153
* @param serviceName the name of the service in CLARA YAML (not class name)
@@ -161,9 +163,10 @@ public static JSONObject filter(JSONObject claraJson, String serviceName) {
161163
ret.accumulate(key, globals.getString(key));
162164
}
163165
}
164-
if (config.has("services")) {
165-
if (config.getJSONObject("services").has(serviceName)) {
166-
JSONObject service = config.getJSONObject("services").getJSONObject(serviceName);
166+
String section = serviceName.equals("reader") || serviceName.equals("writer") ? "io-services" : "services";
167+
if (config.has(section)) {
168+
if (config.getJSONObject(section).has(serviceName)) {
169+
JSONObject service = config.getJSONObject(section).getJSONObject(serviceName);
167170
for (String key : service.keySet()) {
168171
ret.put(key, service.getString(key));
169172
}

0 commit comments

Comments
 (0)