public static void translateMerge(BeanId id, Throwable e) { LOG.debug("", e); Throwable cause = e; while ((cause = cause.getCause()) != null) { if (CONSTRAINT_VIOLATION.contains(cause.getClass().getName())) { throw CFG301_MISSING_RUNTIME_REF(id); } } throw new RuntimeException(e); }
public static void translateMerge(Throwable e) { LOG.debug("", e); Throwable cause = e; while ((cause = cause.getCause()) != null) { if (CONSTRAINT_VIOLATION.contains(cause.getClass().getName())) { throw CFG301_MISSING_RUNTIME_REF(); } } throw new RuntimeException(e); } }
@Override public Optional<Bean> getLazy(BeanId id) throws AbortRuntimeException { Bean bean = storage.get(id); if (bean == null) { return Optional.absent(); } for (BeanId ref : bean.getReferences()) { Bean refBean = storage.get(ref); if (refBean == null) { throw CFG301_MISSING_RUNTIME_REF(ref); } ref.setBean(refBean); } return Optional.of(bean); }
@Override public Bean getLazy(BeanId id) throws AbortRuntimeException { Map<BeanId, Bean> all = readValuesAsMap(); Bean bean = all.get(id); if (bean == null) { throw CFG304_BEAN_DOESNT_EXIST(id); } for (BeanId ref : bean.getReferences()) { Bean refBean = all.get(ref); if (bean == null) { throw CFG301_MISSING_RUNTIME_REF(ref); } ref.setBean(refBean); } return bean; }
private static void checkReferencesExist(final Bean bean, final Map<BeanId, Bean> storage) { ArrayList<BeanId> allRefs = new ArrayList<BeanId>(); for (String name : bean.getReferenceNames()) { if (bean.getReference(name) == null) { // the reference is about to be removed. continue; } for (BeanId beanId : bean.getReference(name)) { allRefs.add(beanId); } } Collection<BeanId> missingReferences = new ArrayList<BeanId>(); for (BeanId beanId : allRefs) { if (beanId.getInstanceId() == null) { continue; } Bean b = storage.get(beanId); if (b == null) { missingReferences.add(beanId); } } if (missingReferences.size() > 0) { throw CFG301_MISSING_RUNTIME_REF(bean.getId(), missingReferences); } }
private void getEagerly(BeanId id, HashMap<BeanId, Bean> found, Set<BeanId> seen) { if (seen.contains(id)) { return; } seen.add(id); Bean bean = found.get(id) == null ? storage.get(id) : found.get(id); if (bean == null) { return; } found.put(id, bean); // bean found, fetch references. for (BeanId ref : bean.getReferences()) { if (ref.getBean() != null) { continue; } Bean refBean = found.get(ref) == null ? storage.get(ref) : found.get(ref); if (refBean == null) { throw CFG301_MISSING_RUNTIME_REF(bean.getId(), ref); } ref.setBean(refBean); found.put(ref, refBean); getEagerly(ref, found, seen); } }
private static void checkReferencesExist(final Bean bean, Collection<Bean> additional) { HashMap<BeanId, Bean> additionalMap = new HashMap<>(); for (Bean b : additional) { additionalMap.put(b.getId(), b); } ArrayList<BeanId> allRefs = new ArrayList<>(); for (String name : bean.getReferenceNames()) { if (bean.getReference(name) == null) { // the reference is about to be removed. continue; } for (BeanId beanId : bean.getReference(name)) { allRefs.add(beanId); } } Collection<BeanId> missingReferences = new ArrayList<>(); for (BeanId beanId : allRefs) { if (beanId.getInstanceId() == null) { continue; } if (storage.get(beanId) == null && additionalMap.get(beanId) == null) { missingReferences.add(beanId); } } if (missingReferences.size() > 0) { throw CFG301_MISSING_RUNTIME_REF(bean.getId(), missingReferences); } }
Bean b = storage.get(ref); if (b == null) { throw CFG301_MISSING_RUNTIME_REF(predecessor.getId());
Bean b = all.get(ref); if (b == null) { throw CFG301_MISSING_RUNTIME_REF(predecessor.getId());
private Bean getEagerly(BeanId id, Map<BeanId, Bean> all) { Bean result = all.get(id); if (result == null) { throw CFG304_BEAN_DOESNT_EXIST(id); } // bean found, initalize references. for (BeanId ref : result.getReferences()) { if (ref.getBean() != null) { continue; } Bean refBean = all.get(ref); if (refBean == null) { throw CFG301_MISSING_RUNTIME_REF(result.getId(), ref); } ref.setBean(refBean); getEagerly(ref, all); } return result; }
Optional<Bean> optional = beanManager.getLazy(beanId); if (!optional.isPresent()) { throw CFG301_MISSING_RUNTIME_REF(beanId);
private void createJpaRefs(Collection<Bean> beans) { int i = 0; for (Bean bean : beans) { for (String name : bean.getReferenceNames()) { List<BeanId> refs = bean.getReference(name); if (refs == null) { continue; } for (BeanId id : refs) { if (!exists(id)) { throw CFG301_MISSING_RUNTIME_REF(bean.getId(), id); } getEmOrFail().persist(new JpaRef(bean.getId(), id, name)); if (i++ % BATCH_SIZE == 0) { getEmOrFail().flush(); getEmOrFail().clear(); } } } } }
Optional<Bean> optional = get(id); if (!optional.isPresent()) { throw CFG301_MISSING_RUNTIME_REF(id); Optional<Bean> ref = get(beanId); if (!ref.isPresent()) { throw CFG301_MISSING_RUNTIME_REF(beanId); Optional<Bean> idBean = get(id); if (!idBean.isPresent()) { throw Events.CFG301_MISSING_RUNTIME_REF(id);