use of jakarta.json.JsonReaderFactory in project resteasy by resteasy.
the class AbstractJsonpProvider method findReader.
protected JsonReader findReader(MediaType mediaType, InputStream is) {
ContextResolver<JsonReaderFactory> resolver = providers.getContextResolver(JsonReaderFactory.class, mediaType);
JsonReaderFactory factory = null;
if (resolver != null) {
factory = resolver.getContext(JsonReaderFactory.class);
}
if (factory == null) {
factory = readerFactory;
}
Charset charset = getCharset(mediaType);
return charset == null ? factory.createReader(is) : factory.createReader(is, charset);
}
use of jakarta.json.JsonReaderFactory in project helidon by oracle.
the class WeldFeature method weldProxyConfigurations.
static List<WeldProxyConfig> weldProxyConfigurations(DuringSetupAccess access) {
try {
ClassLoader classLoader = access.findClassByName("io.helidon.config.Config").getClassLoader();
Enumeration<URL> resources = classLoader.getResources("META-INF/helidon/native-image/weld-proxies.json");
JsonReaderFactory readerFactory = Json.createReaderFactory(Map.of());
List<WeldProxyConfig> weldProxies = new ArrayList<>();
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
JsonArray proxies;
try {
proxies = readerFactory.createReader(url.openStream()).readArray();
} catch (JsonParsingException e) {
throw new NativeImageException("Failed to read JSON config: " + url, e);
}
proxies.forEach(jsonValue -> {
weldProxies.add(new WeldProxyConfig((JsonObject) jsonValue));
});
}
return weldProxies;
} catch (IOException e) {
throw new IllegalStateException("Failed to get resources", e);
}
}
use of jakarta.json.JsonReaderFactory in project helidon by oracle.
the class HelidonReflectionConfiguration method load.
static HelidonReflectionConfiguration load(Feature.BeforeAnalysisAccess access, ClassLoader cl, NativeTrace tracer) {
try {
Enumeration<URL> resources = cl.getResources("META-INF/helidon/native-image/reflection-config.json");
HelidonReflectionConfiguration config = new HelidonReflectionConfiguration();
JsonReaderFactory readerFactory = Json.createReaderFactory(Map.of());
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
try {
JsonObject configurationJson = readerFactory.createReader(url.openStream()).readObject();
jsonArray(tracer, access, config.annotations, configurationJson.getJsonArray("annotated"), "Annotation");
jsonArray(tracer, access, config.hierarchy, configurationJson.getJsonArray("class-hierarchy"), "Class hierarchy");
jsonArray(tracer, access, config.fullHierarchy, configurationJson.getJsonArray("full-class-hierarchy"), "Full class hierarchy");
jsonArray(tracer, access, config.classes, configurationJson.getJsonArray("classes"), "Single");
jsonArray(tracer, access, config.excluded, configurationJson.getJsonArray("exclude"), "Exclude");
} catch (JsonParsingException e) {
System.err.println("Failed to process configuration file: " + url);
throw e;
}
}
return config;
} catch (Exception e) {
throw new IllegalStateException("Failed to process configuration from helidon-reflection-config.json files", e);
}
}
use of jakarta.json.JsonReaderFactory in project helidon by oracle.
the class ConfigMetadataMain method main.
/**
* Start the example.
* @param args ignored
*/
public static void main(String[] args) throws IOException {
JsonReaderFactory readerFactory = Json.createReaderFactory(Map.of());
Enumeration<URL> files = ConfigMetadataMain.class.getClassLoader().getResources("META-INF/helidon/config-metadata.json");
List<ConfiguredType> configuredTypes = new LinkedList<>();
Map<String, ConfiguredType> typesMap = new HashMap<>();
while (files.hasMoreElements()) {
URL url = files.nextElement();
try (InputStream is = url.openStream()) {
JsonReader reader = readerFactory.createReader(is, StandardCharsets.UTF_8);
processMetadataJson(configuredTypes, typesMap, reader.readArray());
}
}
for (ConfiguredType configuredType : configuredTypes) {
if (configuredType.standalone()) {
printType(configuredType, typesMap);
}
}
}
Aggregations