private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Optional<Bean> singleton = beanManager.getSingleton(ref.getSchemaName()); if (singleton.isPresent()) { singleton.get().set(singletonSchema); BeanId singletonId = singleton.get().getId(); singletonId.setBean(singleton.get()); // recursive call. setSingletonReferences(singleton.get(), schemas); bean.setReference(ref.getName(), singletonId); } } } }
private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Optional<Bean> singleton = beanManager.getSingleton(ref.getSchemaName()); if (!singleton.isPresent()) { initFile(null); Bean fileBean = FILE_CONFIG.get(BeanId.createSingleton(ref.getSchemaName())); if (fileBean != null) { singleton = Optional.of(fileBean); } } if (!singleton.isPresent()) { singleton = Optional.of(Bean.create(BeanId.createSingleton(ref.getSchemaName()))); } singleton.get().set(singletonSchema); BeanId singletonId = singleton.get().getId(); singletonId.setBean(singleton.get()); // recursive call. setSingletonReferences(singleton.get(), schemas); bean.setReference(ref.getName(), singletonId); } } }
private void convertPropertyRef(Bean source, Map<String, Object> values, Map<BeanId, Object> instanceCache) { for (SchemaPropertyRef prop : source.getSchema().get(SchemaPropertyRef.class)) { BeanId id = source.getFirstReference(prop.getName()); if (id == null) { continue; } Bean ref = id.getBean(); if (ref == null) { continue; } Schema refSchema = ref.getSchema(); SchemaPropertyRef schemaRef = source.getSchema().get(SchemaPropertyRef.class, prop.getName()); Object beanInstance = instanceCache.get(id); if (beanInstance == null) { try { beanInstance = newInstance(forName(refSchema.getType())); } catch (Exception e) { throw new UnsupportedOperationException(e); } beanInstance = convert(ref, beanInstance, new HashMap<String, Object>(), instanceCache); } values.put(schemaRef.getFieldName(), beanInstance); } }
private void convertPropertyRef(Bean source, Map<String, Object> values, Map<BeanId, Object> instanceCache) { for (SchemaPropertyRef prop : source.getSchema().get(SchemaPropertyRef.class)) { BeanId id = source.getFirstReference(prop.getName()); if (id == null) { continue; } Bean ref = id.getBean(); if (ref == null) { continue; } Schema refSchema = ref.getSchema(); SchemaPropertyRef schemaRef = source.getSchema().get(SchemaPropertyRef.class, prop.getName()); Object beanInstance = instanceCache.get(id); if (beanInstance == null) { try { beanInstance = newInstance(loadClass(refSchema.getType())); } catch (Exception e) { throw new UnsupportedOperationException(e); } beanInstance = convert(ref, beanInstance, new HashMap<String, Object>(), instanceCache); } values.put(schemaRef.getFieldName(), beanInstance); } }
private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Bean singleton = beanManager.getSingleton(ref.getSchemaName()); singleton.set(singletonSchema); BeanId singletonId = singleton.getId(); singletonId.setBean(singleton); // recursive call. setSingletonReferences(singleton, schemas); bean.setReference(ref.getName(), singletonId); } } }
private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Bean singleton = beanManager.getSingleton(ref.getSchemaName()); singleton.set(singletonSchema); BeanId singletonId = singleton.getId(); singletonId.setBean(singleton); // recursive call. setSingletonReferences(singleton, schemas); bean.setReference(ref.getName(), singletonId); } } }
public XmlSchemaRef(SchemaPropertyRef p) { this.name = p.getName(); this.fieldName = p.getFieldName(); this.schemaName = p.getSchemaName(); this.desc = p.getDesc(); this.isImmutable = p.isImmutable(); this.isSingleton = p.isSingleton(); } }