@Override public Schema getSchema(String schemaName) { Map<String, Schema> values = readValues(); Schema schema = values.get(schemaName); if (schema == null) { throw CFG101_SCHEMA_NOT_EXIST(schemaName); } return schema; }
@Override public <T> ConfigQuery newQuery(Class<T> configurable) { doLookup(); Schema schema = getSchema(configurable); ConfigIndexedCollection collection = core.get(schema); if(collection == null) { throw Events.CFG101_SCHEMA_NOT_EXIST(configurable.getName()); } if(!cacheManager.isPresent()) { throw new IllegalStateException("Queries are not possible without a cache manager."); } return new ConfigQuery<T>(collection, cacheManager.get()); }
private Optional<Bean> get(BeanId beanId) { Schema schema = schemas.get(beanId.getSchemaName()); if (schema == null) { throw Events.CFG101_SCHEMA_NOT_EXIST(beanId.getSchemaName()); } Map<String, Map<String, Object>> instances = (Map) config.getAnyRef(schema.getName()); try { final Bean bean; if (schema.getId().isSingleton()) { bean = Bean.create(BeanId.createSingleton(schema.getName())); constructBean((Map) instances, schema, bean); } else { if (instances == null) { return Optional.absent(); } bean = Bean.create(beanId); Map<String, Object> properties = instances.get(beanId.getInstanceId()); constructBean(properties, schema, bean); } return Optional.of(bean); } catch (ConfigException e) { return Optional.absent(); } }
public void setSchema(Bean b, Map<String, Schema> schemas) { Schema s = schemas.get(b.getId().getSchemaName()); if (s == null) { throw CFG101_SCHEMA_NOT_EXIST(b.getId().getSchemaName()); } b.set(s); for (BeanId id : b.getReferences()) { Bean ref = id.getBean(); if (ref != null && ref.getSchema() == null) { setSchema(ref, schemas); } } }
public static void setSchema(Bean b, Map<String, Schema> schemas) { Schema s = schemas.get(b.getId().getSchemaName()); if (s == null) { throw CFG101_SCHEMA_NOT_EXIST(b.getId().getSchemaName()); } b.set(s); for (BeanId id : b.getReferences()) { Bean ref = id.getBean(); if (ref != null && ref.getSchema() == null) { setSchema(ref, schemas); } } }