@Inject public JaxrsConfigEndpoint(AdminContext admin) { this.admin = admin; for (Schema s : admin.getSchemas().values()) { schemas.put(s.getName(), s); } }
public String toString() { return Objects.toStringHelper(Schema.class).add("id", id).add("name", getName()) .add("type", getType()).add("desc", getDesc()).add("properties", properties) .toString(); }
public String toString() { return Objects.toStringHelper(Schema.class).add("id", id).add("name", getName()) .add("type", getType()).add("desc", getDesc()).add("properties", properties) .toString(); }
private BeanId getSingletonId(Schema s, Class<?> configurable) { return BeanId.createSingleton(s.getName()); }
@Override public BeanQuery newQuery(Schema schema) { Map<BeanId, Bean> beans = list(schema.getName()); ArrayList<Bean> sorted = new ArrayList<>(beans.values()); Collections.sort(sorted, new Comparator<Bean>() { @Override public int compare(Bean b1, Bean b2) { return b1.getId().getInstanceId().compareTo(b2.getId().getInstanceId()); } }); return new DefaultBeanQuery(schema, sorted); }
@Override public int hashCode() { return Objects.hashCode(properties, getType(), getDesc(), getName()); }
@Override public int hashCode() { return Objects.hashCode(properties, getType(), getDesc(), getName()); }
@Override public <T> Optional<T> get(Class<T> configurable, String instanceId) throws AbortRuntimeException { doLookup(); Schema schema = schemaManager.getSchema(configurable); Optional<Bean> bean = get(BeanId.create(instanceId, schema.getName())); if (!bean.isPresent()) { return Optional.absent(); } Object object = schemaManager.convertBean(bean.get()); return Optional.of((T) object); }
@Override public <T> Optional<T> get(Class<T> configurable) throws AbortRuntimeException { doLookup(); Schema schema = schemaManager.getSchema(configurable); Optional<Bean> bean = get(BeanId.createSingleton(schema.getName())); if (!bean.isPresent()) { return Optional.absent(); } return (Optional<T>) Optional.of(schemaManager.convertBean(bean.get())); }
@Override public void deleteObjects(Class<?> configurable, Collection<String> instanceIds) throws AbortRuntimeException { Schema schema = schemaManager.getSchema(configurable); for (String instanceId : instanceIds) { delete(BeanId.create(instanceId, schema.getName())); } }
@Override public <T> Optional<T> get(String id, Class<T> configurable) { doLookup(); Schema s = schemaManager.getSchema(configurable); BeanId beanId = BeanId.create(id, s.getName()); Optional<Bean> bean = beanManager.getEager(beanId); if (!bean.isPresent()) { initFile(configurable); Bean fileBean = FILE_CONFIG.get(beanId); if (fileBean != null) { bean = Optional.of(fileBean); } else { return Optional.absent(); } } schemaManager.setSchema(Arrays.asList(bean.get())); setSingletonReferences(bean.get()); T object = (T) schemaManager.convertBean(bean.get()); if (cacheManager.isPresent()) { cacheManager.get().put(bean.get()); } return Optional.of(object); }
bean = Optional.of(Bean.create(BeanId.createSingleton(schema.getName())));
public List<Bean> list(Schema schema, Map<String, Schema> schemas) { List<Bean> beans = new ArrayList<>(); Config schemaConfig; try { String schemaName = schema.getName().replaceAll("\\$", "\\."); schemaConfig = config.getConfig(schemaName); if (schemaConfig == null) { return beans; } } catch (Exception e) { return beans; } if (schema.getId().isSingleton()) { final Bean bean = Bean.create(BeanId.createSingleton(schema.getName())); beans.add(bean); constructBean(schemaConfig, schema, bean, schemas); } else { for (Object instanceId : schemaConfig.root().keySet()) { Config instance = schemaConfig.getConfig(instanceId.toString()); final Bean bean = Bean.create(BeanId.create(instanceId.toString(), schema.getName())); beans.add(bean); constructBean(instance, schema, bean, schemas); } } return beans; }
@Override public <T> Collection<T> list(Class<T> configurable) throws AbortRuntimeException { doLookup(); final Schema schema = schemaManager.getSchema(configurable); Collection<Bean> beans = list(schema.getName()); return (Collection<T>) schemaManager.convertBeans(beans); }
String schemaName = schema.getName().replaceAll("\\$", "\\."); Config schemaConfig = config.getConfig(schemaName); Bean bean; if (schema.getId().isSingleton()) { bean = Bean.create(BeanId.createSingleton(schema.getName())); constructBean(schemaConfig, schema, bean, schemas); return Optional.of(bean); if (instanceId.equals(beanId.getInstanceId())) { Config instance = schemaConfig.getConfig(instanceId.toString()); bean = Bean.create(BeanId.create(instanceId.toString(), schema.getName())); constructBean(instance, schema, bean, schemas); return Optional.of(bean);
public JaxrsSchema(Schema schema) { this.schemaName = schema.getName(); this.className = schema.getType(); this.desc = schema.getDesc(); this.idName = schema.getId().getName(); this.idDesc = schema.getId().getDesc(); this.singleton = schema.getId().isSingleton(); for (Schema.SchemaProperty prop : schema.get(Schema.SchemaProperty.class)) { property.add(new SchemaProperty(prop)); propertyNames.add(prop.getName()); } for (Schema.SchemaPropertyList prop : schema.get(Schema.SchemaPropertyList.class)) { propertyList.add(new SchemaPropertyList(prop)); propertyNames.add(prop.getName()); } for (Schema.SchemaPropertyRef prop : schema.get(Schema.SchemaPropertyRef.class)) { propertyRef.add(new SchemaPropertyRef(prop)); propertyNames.add(prop.getName()); } for (Schema.SchemaPropertyRefList prop : schema.get(Schema.SchemaPropertyRefList.class)) { propertyRefList.add(new SchemaPropertyRefList(prop)); propertyNames.add(prop.getName()); } for (Schema.SchemaPropertyRefMap prop : schema.get(Schema.SchemaPropertyRefMap.class)) { propertyRefMap.add(new SchemaPropertyRefMap(prop)); propertyNames.add(prop.getName()); } }
public Bean toBean(Schema schema) { final BeanId id; if (schema.getId().isSingleton()) { id = BeanId.createSingleton(schema.getName()); } else { id = BeanId.create(getId(), getSchemaName());