If not already created, a new <code>referenced-bean</code> element will be created and returned.
Otherwise, the first existing <code>referenced-bean</code> element will be returned.
@return the instance defined for the element <code>referenced-bean</code>
764318
public FacesConfigReferencedBeanType<FacesConfigType<T>> getOrCreateReferencedBean()
   {
      List<Node> nodeList = childNode.get("referenced-bean");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigReferencedBeanTypeImpl<FacesConfigType<T>>(this, "referenced-bean", childNode, nodeList.get(0));
      }
      return createReferencedBean();
   }
280574
@Override
    public void create(Collection<Bean> beans) throws AbortRuntimeException {
        init();
        Set<HBeanRow> beanRows = new HashSet<>();
        Map<HBeanRow, HBeanRow> refRows = new HashMap<>();
        Map<BeanId, Bean> beansMap = BeanUtils.uniqueIndex(beans);
        try {
            for (Bean bean : beans) {
                beanRows.add(new HBeanRow(bean, uids));
                for (BeanId ref : bean.getReferences()) {
                    Bean refBean = beansMap.get(ref);
                    HBeanRow row;
                    if (refBean == null) {
                        row = new HBeanRow(ref, uids);
                    } else {
                        row = new HBeanRow(refBean, uids);
                    }
                    refRows.put(row, row);
                }
            }
            table.getLazy(beanRows);
            throw Events.CFG303_BEAN_ALREADY_EXIST(beans.iterator().next().getId());
        } catch (HBeanNotFoundException e) {
            // ensure beans to be create does not exist
        }

        // ensure references exist either in memory or storage
        try {
            refRows = table.getLazyAsMap(refRows);
        } catch (HBeanNotFoundException e) {
            // only throw exception if the bean was not provided
            // as an argument to the create method.
            if (!idsFoundIn(beans, e)) {
                throw Events.CFG301_MISSING_RUNTIME_REF(e.getNotFound().iterator().next());
            }
            // make sure that references found in storage override the refRows
            for (HBeanRow row : e.getFound().keySet()) {
                refRows.put(row, row);
            }

        }
        // select the rows to update predecessors
        for (HBeanRow beanRow : beanRows) {
            for (HBeanRow refRow : beanRow.getReferenceRows()) {
                refRow = refRows.get(refRow);
                refRow.addPredecessor(beanRow);
            }
        }

        table.put(beanRows);
        table.put(Sets.newHashSet(refRows.values()));
    }
208359
@Override
    public Object newInstance(Object[] args) throws BeanConstructorNotFoundException {
        Constructor<?> constructor = getSuitableConstructor(args);
        return LdiConstructorUtil.newInstance(constructor, args);
    }
1251957
public List<Bean> getBeans() {
        Map<BeanId, Bean> referenceMap = new HashMap<>();
        List<Bean> result = new ArrayList<>();

        for (HBeanRow row : inital.keySet()) {
            Bean bean = row.getBean();
            result.add(bean);
            referenceMap.put(bean.getId(), bean);
        }
        for (HBeanRow row : references.keySet()) {
            Bean bean = row.getBean();
            referenceMap.put(bean.getId(), bean);
        }
        for (Bean bean : referenceMap.values()) {
            for (BeanId id : bean.getReferences()) {
                Bean ref = referenceMap.get(id);
                id.setBean(ref);
            }
        }
        return result;
    }
948285
public static JusFragment newInstance() {
		JusFragment fragment = new JusFragment();
		Bundle args = new Bundle();
		fragment.setArguments(args);
		return fragment;
	}
1155187
public Alternatives<Beans<T>> getOrCreateAlternatives()
   {
      List<Node> nodeList = childNode.get("alternatives");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new AlternativesImpl<Beans<T>>(this, "alternatives", childNode, nodeList.get(0));
      }
      return createAlternatives();
   }
395807
@Override
    public T create(CreationalContext<T> creationalContext) {
        T instance = getProducer().produce(creationalContext);
        getProducer().inject(instance, creationalContext);

        if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) {
            getProducer().postConstruct(instance);
        } else {
            /*
             * CDI-219
             * The request scope is active during @PostConstruct callback of any bean.
             */
            RequestContext context = getUnboundRequestContext();
            try {
                context.activate();
                beanManager.fireRequestContextInitialized(getId());
                getProducer().postConstruct(instance);
            } finally {
                beanManager.fireRequestContextBeforeDestroyed(getId());
                context.invalidate();
                context.deactivate();
                beanManager.fireRequestContextDestroyed(getId());
            }
        }
        return instance;
    }
827546
@Override
    protected Object createNewInstance(Erector erector) throws BlueprintTemplateException {
        SpringBlueprint springBlueprint = erector.getBlueprint().getClass().getAnnotation(SpringBlueprint.class);
        if ( springBlueprint != null && springBlueprint.bean() ) {
            Class beanClass = springBlueprint.beanClass();

            if ( beanClass.equals( NotSet.class) ) {
                beanClass = erector.getTarget();
            }

            try {
                if ( StringUtils.isNotBlank( springBlueprint.beanName() ) ) {
                    logger.debug( "Retrieving model from Spring [{},{}]", springBlueprint.beanName(), beanClass );
                    return applicationContext.getBean( springBlueprint.beanName(), beanClass );
                } else {
                    logger.debug( "Retrieving model from Spring [{}]", beanClass );
                    return applicationContext.getBean( beanClass );
                }
            } catch( NoSuchBeanDefinitionException e ) {
                // Model not directly registered with Spring, autowire it manually.
                Object instance = super.createNewInstance(erector);
                beanFactory.autowireBean( instance );
                return instance;
            }
        } else {
            return super.createNewInstance(erector);
        }

    }
98188
public BeanType<ValidationMappingDescriptor> getOrCreateBean()
   {
      List<Node> nodeList = model.get("bean");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new BeanTypeImpl<ValidationMappingDescriptor>(this, "bean", model, nodeList.get(0));
      }
      return createBean();
   }
817242
public ResourceFactory createChild() {
        ResourceFactory child = new ResourceFactory(this);
        this.chidren.add(new WeakReference<>(child));
        return child;
    }
1172139
def referenced_by(self):
        
        href = fetch_entry_point('references_by_element')
        return [Element.from_meta(**ref)
                for ref in self.make_request(
                    method='create',
                    href=href,
                    json={'value': self.href})]
246570
public Object createInstanceQuietly() {
      try {
         return clazz.newInstance();
      } catch (InstantiationException e) {
         log.finest(e);
         return null;
      } catch (IllegalAccessException e) {
         log.finest(e);
         return null;
      }
   }
1162717
public FacesConfigManagedBeanType<FacesConfigType<T>> getOrCreateManagedBean()
   {
      List<Node> nodeList = childNode.get("managed-bean");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigManagedBeanTypeImpl<FacesConfigType<T>>(this, "managed-bean", childNode, nodeList.get(0));
      }
      return createManagedBean();
   }
987137
@SuppressWarnings("unchecked")
    private Object createManagedBean(final ManagedBean managedBean, final FacesContext facesContext) throws ELException
    {

        final ExternalContext extContext = facesContext.getExternalContext();
        final Map<Object, Object> facesContextMap = facesContext.getAttributes();
        final String managedBeanName = managedBean.getManagedBeanName();

        // check for cyclic references
        List<String> beansUnderConstruction = (List<String>) facesContextMap.get(BEANS_UNDER_CONSTRUCTION);
        if (beansUnderConstruction == null)
        {
            beansUnderConstruction = new ArrayList<String>();
            facesContextMap.put(BEANS_UNDER_CONSTRUCTION, beansUnderConstruction);
        }
        else if (beansUnderConstruction.contains(managedBeanName))
        {
            throw new ELException("Detected cyclic reference to managedBean " + managedBeanName);
        }

        beansUnderConstruction.add(managedBeanName);

        Object obj = null;
        try
        {
            obj = beanBuilder.buildManagedBean(facesContext, managedBean);
        }
        finally
        {
            beansUnderConstruction.remove(managedBeanName);
        }

        putInScope(managedBean, facesContext, extContext, obj);

        return obj;
    }
225954
public BeanId getBeanId() {
        final byte[] rowkey = getRowKey();
        final byte[] sid = new byte[] { rowkey[0], rowkey[1] };
        final byte[] iid = new byte[] { rowkey[2], rowkey[3], rowkey[4], rowkey[5] };
        final String schemaName = uids.getUsid().getName(sid);
        final String instanceId = uids.getUiid().getName(iid);

        if (Strings.isNullOrEmpty(schemaName)) {
            throw new IllegalStateException("Could not lookup schema name from sid "
                    + Arrays.toString(sid));
        }
        if (Strings.isNullOrEmpty(instanceId)) {
            throw new IllegalStateException("Could not lookup instance id from iid "
                    + Arrays.toString(iid));
        }
        return BeanId.create(instanceId, schemaName);
    }
1155000
@SuppressWarnings("unchecked")
	public T getInstance() {
		if(beanClassName == null) {
			return null;
		} else try {
			T beanInstance;
			Class<T> beanClass = null;
			try {
				try {
					ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
					beanClass = (Class<T>)Class.forName(beanClassName, true, classLoader);
				} catch(ClassNotFoundException cnfe) {
					throw new RuntimeException("Unknown class " + beanClassName, cnfe);
				}
				// Instancjonowanie i inicjalizcja w oparciu o konstruktor inicjujący:
				Constructor<T> constructor = (Constructor<T>)beanClass.getConstructor(Collection.class);
				beanInstance = constructor.newInstance(properties);
			} catch(NoSuchMethodException nsme) {
				// Instancjonowanie i inicjalizacja w oparciu o konstruktor bezargumentowy
				// i publiczne setter'y Java Beans:
				beanInstance = beanClass.newInstance();

				if(properties != null && !properties.isEmpty()) {
					BeanInfo validatorInfo = Introspector.getBeanInfo(beanClass);
					PropertyDescriptor[] propertyDescriptors = validatorInfo.getPropertyDescriptors();
					for(BeanProperty beanProperty : properties) {
						String propertyName = beanProperty.getPropertyName();
						Method writeMethod = null;
						for(PropertyDescriptor propertyDescriptor : propertyDescriptors) {
							if(propertyDescriptor.getName().equals(propertyName)) {
								writeMethod = propertyDescriptor.getWriteMethod();
								break;
							}
						}
						if(writeMethod == null) {
							throw new RuntimeException("No public setter found for property '" + propertyName + "' "
									+ "in validator class " + beanClass.getCanonicalName());
						}
						Class<?> parameterType = writeMethod.getParameterTypes()[0];
						if(BeanProperty.class.equals(parameterType)) {
							writeMethod.invoke(beanInstance, beanProperty);
						} else if(String.class.equals(parameterType)) {
							if(beanProperty.hasAttributes()) {
								throw new RuntimeException("BeanProperty '" + propertyName + "' setter should has "
										+ Parameter.class.getSimpleName() + " type parameter");
							}
							writeMethod.invoke(beanInstance, beanProperty.getPropertyValue());
						}
					}
				}
			}
			return beanInstance;
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
	}
1174197
public Object getEJBNextBeanInstance() {
        if (_colIter == null)
            return null;

        if (!_colIter.hasNext()) {
            releaseBeanInstance(false);
            return null;
        }

        _beanInstance = beanNarrow(_colIter.next());
        return _beanInstance;
    }