private MetadataConfiguration getMetadataConfiguration() throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException { if (mdConfiguration != null) { return mdConfiguration; } JsonNode root = metadataNode; if (root == null) { try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(MetadataConfiguration.FILENAME)) { if (null == is) { throw new FileNotFoundException(MetadataConfiguration.FILENAME); } root = JsonUtils.json(is, true); } } LOGGER.debug("Config root:{}", root); JsonNode cfgClass = root.get("type"); if (cfgClass == null) { throw new IllegalStateException(MetadataConstants.ERR_CONFIG_NOT_FOUND + " - type"); } MetadataConfiguration cfg = (MetadataConfiguration) Thread.currentThread().getContextClassLoader().loadClass( cfgClass.asText()).newInstance(); injectDependencies(cfg); cfg.initializeFromJson(root); return mdConfiguration = cfg; }
private MetadataConfiguration getMetadataConfiguration() throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException { if (mdConfiguration != null) { return mdConfiguration; } JsonNode root = metadataNode; if (root == null) { try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(MetadataConfiguration.FILENAME)) { if (null == is) { throw new FileNotFoundException(MetadataConfiguration.FILENAME); } root = JsonUtils.json(is, true); } } LOGGER.debug("Config root:{}", root); JsonNode cfgClass = root.get("type"); if (cfgClass == null) { throw new IllegalStateException(MetadataConstants.ERR_CONFIG_NOT_FOUND + " - type"); } MetadataConfiguration cfg = (MetadataConfiguration) Thread.currentThread().getContextClassLoader().loadClass( cfgClass.asText()).newInstance(); injectDependencies(cfg); cfg.initializeFromJson(root); return mdConfiguration = cfg; }
private synchronized void initializeMetadata() throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (metadata == null) { LOGGER.debug("Initializing metadata"); JsonNode root; try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(MetadataConfiguration.FILENAME)) { root = JsonUtils.json(is); } LOGGER.debug("Config root:{}", root); JsonNode cfgClass = root.get("type"); if (cfgClass == null) { throw new IllegalStateException(MetadataConstants.ERR_CONFIG_NOT_FOUND + " - type"); } MetadataConfiguration cfg = (MetadataConfiguration) Class.forName(cfgClass.asText()).newInstance(); cfg.initializeFromJson(root); // Set validation flag for all metadata requests getJsonTranslator().setValidation(EntityMetadata.class,cfg.isValidateRequests()); getJsonTranslator().setValidation(EntitySchema.class,cfg.isValidateRequests()); getJsonTranslator().setValidation(EntityInfo.class,cfg.isValidateRequests()); metadata = cfg.createMetadata(datasources, getJSONParser(), this); } }