- if (resolvedID.startsWith("class:"))
- {
- String className = resolvedID.substring(6);
- tryLoadComponentClass(className);
- ComponentSupplier componentSupplier = componentSuppliers.get(className);
- if (componentSupplier != null)
- return componentSupplier.create(model, params, name);
- throw new IllegalArgumentException("Component supplier not found for ID " + id + " (resolved: " + resolvedID + ")");
- } else
- // we know id has to start with "file:" here
- // because standardComponentIDs only contains strings starting with "class:" or "file:"
- if (params != null && !JsonNull.INSTANCE.equals(params))
- throw new IllegalArgumentException("Can't give params to a component deserialized from a JSON file");
+ // don't use parts[1], because the path could contain ':'
+ jsonContents = JsonHandler.readJson(resolvedID.substring("jsonfile:".length()), JsonObject.class);
+ }
+ catch (IOException e)
+ {
+ throw new UncheckedIOException("Error loading JSON file", e);
+ }
+ return loadComponentFromJsonObject(model, id, name, jsonContents);
+ }
+ ResourceLoader loader;
+ String resTypeID;
+ String resID;
+ if (firstPart.equals("resloader"))
+ {
+ String loaderID = parts[1];
+ loader = resourceLoaders.get(loaderID);
+ if (loader == null)
+ tryLoadResourceLoader(loaderID);
+ loader = resourceLoaders.get(loaderID);
+ if (loader == null)
+ throw new IllegalArgumentException(
+ "Unknown resource loader: " + loaderID + " (but class was found. Probably the static initializer is missing)");
+ resTypeID = parts[2];
+ resID = parts[3];
+ } else
+ {
+ loader = defaultResourceLoader;
+ resTypeID = parts[0];
+ resID = parts[1];
+ }
+ if (resTypeID.equals("jsonres"))
+ {
+ JsonObject jsonContents;
+ try
+ {
+ @SuppressWarnings("resource") // jsonStream is closed in JsonHandler
+ InputStream jsonStream = Objects.requireNonNull(loader.loadResource(resID), "Error loading JSON resource: Not found");
+ jsonContents = JsonHandler.readJson(jsonStream, JsonObject.class);
+ }
+ catch (IOException e)
+ {
+ throw new UncheckedIOException("Error loading JSON resource", e);
+ }
+ return loadComponentFromJsonObject(model, id, name, jsonContents);
+ } else if (resTypeID.equals("class"))
+ {
+ ComponentSupplier componentSupplier = componentSuppliers.get(resID);
+ if (componentSupplier == null)