private synchronized void initializeMediator() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException, InstantiationException { if (mediator == null) { mediator = new Mediator(getMetadata(), getFactory()); } }
public Factory getFactory() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException, InstantiationException { if (factory == null) { initializeFactory(); } return factory; }
public JsonTranslator getJsonTranslator() { if (jsonTranslator == null) { initializeJsonTranslator(); } return jsonTranslator; }
public JSONMetadataParser getJSONParser() throws ClassNotFoundException, NoSuchMethodException, IOException, IllegalAccessException, InvocationTargetException, InstantiationException { if (parser == null) { initializeParser(); // Metadata is loaded next because the hooks need to be registered on the Factory. getMetadata(); } return parser; }
public Metadata getMetadata() throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (metadata == null) { initializeMetadata(getFactory()); } return metadata; }
@Override public Object fromJson(JsonNode node) { try { return getJSONParser().parseEntityMetadata(node); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } } }, "json-schema/metadata/metadata.json");
private synchronized void initializeMetadata(Factory factory) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (metadata == null) { LOGGER.debug("Initializing metadata"); MetadataConfiguration cfg = getMetadataConfiguration(); // 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); factory.setHookResolver(new SimpleHookResolver(cfg.getHookConfigurationParsers(), this)); } }
getJSONParser(). getExtensions(). mergeWith(parserExtensions); MongoMetadata mongoMetadata = null; if (collection == null) { mongoMetadata = new MongoMetadata(dbresolver.get(mdstore), parserExtensions, typeResolver, factory.getFactory(), metadataCache); } else { mongoMetadata = new MongoMetadata(dbresolver.get(mdstore), collection, parserExtensions, typeResolver, factory.getFactory(), metadataCache);
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); } }
lightblueFactory = new LightblueFactory( new DataSourcesConfiguration(getDatasourcesJson()), getLightblueCrudJson(), getLightblueMetadataJson()); JsonTranslator tx = lightblueFactory.getJsonTranslator(); Metadata metadata = lightblueFactory.getMetadata();
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 initializeLockingMap() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException, InstantiationException { if (lockingMap == null) { LOGGER.debug("Initializing locking"); Map<String, LockingSupport> map = new HashMap<>(); CRUDController[] controllers = getFactory().getCRUDControllers(); LOGGER.debug("Got {} controllers", controllers.length); for (CRUDController controller : controllers) { LOGGER.debug("Inspecting {}", controller.getClass()); if (controller instanceof ExtensionSupport) { LOGGER.debug("{} supports extensions", controller.getClass()); LockingSupport lockingSupport = (LockingSupport) ((ExtensionSupport) controller).getExtensionInstance(LockingSupport.class); if (lockingSupport != null) { LOGGER.debug("{} supports locking", controller.getClass()); for (String domain : lockingSupport.getLockingDomains()) { map.put(domain, lockingSupport); } } } } LOGGER.debug("Locking map:{}", map); lockingMap = map; } }
protected Mediator tryGetMediator() { if (mediator == null) { synchronized (this) { if (mediator == null) { if (lightblueFactory == null) { throw new IllegalStateException("No Mediator or LightblueFactory provided!"); } try { mediator = lightblueFactory.getMediator(); } catch (Exception e) { throw new IllegalStateException("Unable to get Mediator from LightblueFactory!", e); } } } } return mediator; }
/** * Creates and returns a {@link Request} based on the passed in * {@link JsonNode} * * @param type - Request class to instantiate. * @param node - {@link JsonNode} of actions metadata * @return a {@link Request} based on the passed in {@link JsonNode} */ protected static <T extends Request> T createRequest(Class<T> type, JsonNode node) { JsonTranslator tx = getLightblueFactory().getJsonTranslator(); return tx.parse(type, node); }
public Mediator getMediator() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, IOException, NoSuchMethodException, InstantiationException { if (mediator == null) { initializeMediator(); } return mediator; }
public Metadata getMetadata() throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (metadata == null) { initializeMetadata(); } return metadata; }
@Override public Object fromJson(JsonNode node) { try { return getJSONParser().parseEntityMetadata(node); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } } },"json-schema/metadata/metadata.json");
private synchronized void initializeMetadata(Factory factory) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (metadata == null) { LOGGER.debug("Initializing metadata"); MetadataConfiguration cfg = getMetadataConfiguration(); // 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); factory.setHookResolver(new SimpleHookResolver(cfg.getHookConfigurationParsers(), this)); } }
getJSONParser(). getExtensions(). mergeWith(parserExtensions); MongoMetadata mongoMetadata = null; if (collection == null) { mongoMetadata = new MongoMetadata(dbresolver.get(mdstore), parserExtensions, typeResolver, factory.getFactory(),metadataCache); } else { mongoMetadata = new MongoMetadata(dbresolver.get(mdstore), collection, parserExtensions, typeResolver, factory.getFactory(),metadataCache);
public JSONMetadataParser getJSONParser() throws ClassNotFoundException, NoSuchMethodException, IOException, IllegalAccessException, InvocationTargetException, InstantiationException { if (parser == null) { initializeParser(); getMetadata(); } return parser; }