public SimpleHookResolver(List<HookConfigurationParser> hookConfigurationParsers, LightblueFactory lightblueFactory) { if (hookConfigurationParsers != null && !hookConfigurationParsers.isEmpty()) { for (HookConfigurationParser parser : hookConfigurationParsers) { lightblueFactory.injectDependencies(parser); CRUDHook hook = parser.getCRUDHook(); lightblueFactory.injectDependencies(hook); map.put(parser.getName(), hook); } } }
public SimpleHookResolver(List<HookConfigurationParser> hookConfigurationParsers, LightblueFactory lightblueFactory) { if (hookConfigurationParsers != null && !hookConfigurationParsers.isEmpty()) { for (HookConfigurationParser parser : hookConfigurationParsers) { lightblueFactory.injectDependencies(parser); CRUDHook hook = parser.getCRUDHook(); lightblueFactory.injectDependencies(hook); map.put(parser.getName(), hook); } } }
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 initializeParser() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException, InstantiationException { if (parser == null) { Extensions<JsonNode> extensions = new Extensions<>(); extensions.addDefaultExtensions(); Map<String, DataSourceConfiguration> ds = datasources.getDataSources(); for (Map.Entry<String, DataSourceConfiguration> entry : ds.entrySet()) { Class<? extends DataStoreParser> tempParser = entry.getValue().getMetadataDataStoreParser(); DataStoreParser backendParser = tempParser.newInstance(); injectDependencies(backendParser); extensions.registerDataStoreParser(backendParser.getDefaultName(), backendParser); } parser = new JSONMetadataParser(extensions, new DefaultTypes(), NODE_FACTORY); } }
private synchronized void initializeParser() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException, InstantiationException { if (parser == null) { Extensions<JsonNode> extensions = new Extensions<>(); extensions.addDefaultExtensions(); Map<String, DataSourceConfiguration> ds = datasources.getDataSources(); for (Map.Entry<String, DataSourceConfiguration> entry : ds.entrySet()) { Class<? extends DataStoreParser> tempParser = entry.getValue().getMetadataDataStoreParser(); DataStoreParser backendParser = tempParser.newInstance(); injectDependencies(backendParser); extensions.registerDataStoreParser(backendParser.getDefaultName(), backendParser); } parser = new JSONMetadataParser(extensions, new DefaultTypes(), NODE_FACTORY); } }
private synchronized void initializeFactory() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException, InstantiationException { if (factory == null) { LOGGER.debug("Initializing factory"); if(crudConfiguration==null) initializeCrudConfiguration(); // Set validation flag for all crud requests getJsonTranslator().setValidation(Request.class, crudConfiguration.isValidateRequests()); Factory f = new Factory(); f.setBulkParallelExecutions(crudConfiguration.getBulkParallelExecutions()); f.setMemoryIndexThreshold(crudConfiguration.getMemoryIndexThreshold()); f.addFieldConstraintValidators(new DefaultFieldConstraintValidators()); f.setMaxResultSetSizeForReadsB(crudConfiguration.getMaxResultSetSizeForReadsB()); f.setWarnResultSetSizeB(crudConfiguration.getWarnResultSetSizeB()); f.setMaxResultSetSizeForWritesB(crudConfiguration.getMaxResultSetSizeForWritesB()); f.setMaxExecutionContextSizeForCompositeFindB(crudConfiguration.getMaxExecutionContextSizeForCompositeFindB()); // Add default interceptors new UIDInterceptor().register(f.getInterceptors()); new GeneratedFieldInterceptor().register(f.getInterceptors()); for (ControllerConfiguration x : crudConfiguration.getControllers()) { ControllerFactory cfactory = x.getControllerFactory().newInstance(); CRUDController controller = cfactory.createController(x, datasources); injectDependencies(controller); f.addCRUDController(x.getBackend(), controller); } // Make sure we assign factory after it is initialized. (factory is volatile, there's a memory barrier here) factory = f; LOGGER.info("Initialized factory: {}", factory); } }
private synchronized void initializeFactory() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException, InstantiationException { if (factory == null) { LOGGER.debug("Initializing factory"); if(crudConfiguration==null) initializeCrudConfiguration(); // Set validation flag for all crud requests getJsonTranslator().setValidation(Request.class, crudConfiguration.isValidateRequests()); Factory f = new Factory(); f.setBulkParallelExecutions(crudConfiguration.getBulkParallelExecutions()); f.setMemoryIndexThreshold(crudConfiguration.getMemoryIndexThreshold()); f.addFieldConstraintValidators(new DefaultFieldConstraintValidators()); f.setMaxResultSetSizeForReadsB(crudConfiguration.getMaxResultSetSizeForReadsB()); f.setWarnResultSetSizeB(crudConfiguration.getWarnResultSetSizeB()); f.setMaxResultSetSizeForWritesB(crudConfiguration.getMaxResultSetSizeForWritesB()); f.setMaxExecutionContextSizeForCompositeFindB(crudConfiguration.getMaxExecutionContextSizeForCompositeFindB()); // Add default interceptors new UIDInterceptor().register(f.getInterceptors()); new GeneratedFieldInterceptor().register(f.getInterceptors()); for (ControllerConfiguration x : crudConfiguration.getControllers()) { ControllerFactory cfactory = x.getControllerFactory().newInstance(); CRUDController controller = cfactory.createController(x, datasources); injectDependencies(controller); f.addCRUDController(x.getBackend(), controller); } // Make sure we assign factory after it is initialized. (factory is volatile, there's a memory barrier here) factory = f; LOGGER.info("Initialized factory: {}", factory); } }