Creates the bean instance using either the ManagedObjectFactory or constructor.
486901
private void createInstance() throws InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createInstance");

        ManagedObjectFactory<?> ejbManagedObjectFactory = home.beanMetaData.ivEnterpriseBeanFactory;
        if (ejbManagedObjectFactory != null) {
            createInstanceUsingMOF(ejbManagedObjectFactory);
        } else {
            createInstanceUsingConstructor();
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createInstance");
    }
308151
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ JsonElement.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return JsonElement.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
          (ContentHandle<C>) new GSONHandle() : null;
        return handle;
      }
    };
  }
525724
public static BeanMap create(Class srcClass) {
        BeanMappingObject describeConfig = BeanMappingConfigHelper.getInstance().getBeanMapObject(srcClass, Map.class,
                                                                                                  true);

        BeanMappingObject populateConfig = BeanMappingConfigHelper.getInstance().getBeanMapObject(Map.class, srcClass,
                                                                                                  true);
        return new BeanMap(describeConfig, populateConfig);
    }
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;
    }
940782
@Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
    jpaVendorAdapter.setDatabase(Database.H2);
    jpaVendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactory.setPackagesToScan(this.getClass().getPackage().getName());
    entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter);
    entityManagerFactory.setDataSource(dataSource());
    return entityManagerFactory;
  }
450322
@SuppressWarnings("rawtypes")
  @Override
  public EntityManagerFactory createContainerEntityManagerFactory(
      PersistenceUnitInfo info, Map properties) {
    EntityManagerFactory factory = wrappedPersistenceProvider.createContainerEntityManagerFactory(info, properties);
    return factory;
  }
66180
public JettyServiceBuilder bean(Object bean, boolean managed) {
        beans.add(new Bean(bean, managed));
        return this;
    }
1279538
private void _createEagerBeans(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
        List<ManagedBean> eagerBeans = new ArrayList<ManagedBean>();
        
        // check all registered managed-beans
        for (ManagedBean bean : runtimeConfig.getManagedBeans().values())
        {
            String eager = bean.getEager();
            if (eager != null && "true".equals(eager))
            {
                // eager beans are only allowed for application scope
                if (ManagedBeanBuilder.APPLICATION.equals(bean.getManagedBeanScope()))
                {
                    // add to eager beans
                    eagerBeans.add(bean);
                }
                else
                {
                    // log warning and continue (the bean will be lazy loaded)
                    log.log(Level.WARNING, "The managed-bean with name "
                            + bean.getManagedBeanName()
                            + " must be application scoped to support eager=true.");
                }
            }
        }
        
        // check if there are any eager beans
        if (!eagerBeans.isEmpty())
        {
            ManagedBeanBuilder managedBeanBuilder = new ManagedBeanBuilder();
            Map<String, Object> applicationMap = externalContext.getApplicationMap();
            
            for (ManagedBean bean : eagerBeans)
            {
                // check application scope for bean instance
                if (applicationMap.containsKey(bean.getManagedBeanName()))
                {
                    // do not build bean, because it already exists
                    // (e.g. @ManagedProperty from previous managed bean already created it)
                    continue;
                }

                // create instance
                Object beanInstance = managedBeanBuilder.buildManagedBean(facesContext, bean);
                
                // put in application scope
                applicationMap.put(bean.getManagedBeanName(), beanInstance);
            }
        }
    }
21172
public ObjectName createObjectName() {
        try {
            if (StringUtils.hasText(objectName)) {
                return new ObjectName(objectDomain + ":" + objectName);
            }

            if (type != null) {
                if (StringUtils.hasText(objectDomain)) {
                    return new ObjectName(objectDomain, "type", type.getSimpleName());
                }

                return new ObjectName(type.getPackage().getName(), "type", type.getSimpleName());
            }

            return new ObjectName(objectDomain, "name", name);
        } catch (NullPointerException | MalformedObjectNameException e) {
            throw new CitrusRuntimeException("Failed to create proper object name for managed bean", e);
        }
    }
537806
@SuppressWarnings("unchecked")
    private void createInstanceUsingMOF(ManagedObjectFactory<?> ejbManagedObjectFactory) throws InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createInstanceUsingMOF");

        try {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "calling ManagedObjectFactory.createManagedObject(InvocationContext)");

            @SuppressWarnings("rawtypes")
            InvocationContextImpl invCtx = getInvocationContext();
            ivManagedObject = ejbManagedObjectFactory.createManagedObject(invCtx);

            ivEjbManagedObjectContext = ivManagedObject.getContext();
            setEnterpriseBean(ivManagedObject.getObject());
        } catch (ManagedObjectException e) {
            //the callstack is epecting a InvocationTargetException so unwrap the ManagedObjectException and rewrap as InvocationTargetException
            Throwable cause = e.getCause();
            if (cause != null && cause instanceof Exception) {
                if (cause instanceof InvocationTargetException) {
                    throw (InvocationTargetException) cause;
                } else {
                    throw new InvocationTargetException(cause);
                }
            } else {
                throw new EJBException(home.beanMetaData.enterpriseBeanClassName, e);
            }
        } catch (Exception e) {
            // Reflection exceptions are unexpected.
            FFDCFilter.processException(e, CLASS_NAME + ".createInstanceUsingMOF", "321", this);
            throw new EJBException(home.beanMetaData.enterpriseBeanClassName, e);
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createInstanceUsingMOF");
    }
739287
@Constructed
	public void constructed() {
		Context context = factory.enterContext();
		
		try {
			scope = new ImporterTopLevel(context);
		} finally {
			Context.exit();
		}
		
		Container container = Jaguar.component(Container.class);
		Object store = container.component(container.contexts().get(Application.class)).store();
		
		if (store instanceof ServletContext) {
			org.eiichiro.bootleg.Configuration configuration = new DefaultConfiguration();
			configuration.init((ServletContext) store);
			this.configuration = configuration;
		}
	}
808926
private E createUsingConstructor() throws CheckedAnalysisException {
        Constructor<E> constructor;
        try {
            constructor = databaseClass.getConstructor(new Class[0]);
        } catch (NoSuchMethodException e) {
            return null;
        }

        try {
            return constructor.newInstance(new Object[0]);
        } catch (InstantiationException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        } catch (IllegalAccessException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        } catch (InvocationTargetException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        }
    }
446748
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ JsonNode.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return JsonNode.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
                                  (ContentHandle<C>) new JacksonHandle() : null;
        return handle;
      }
    };
  }
1336248
private MBeanPluginContext createMBeanPluginContext() {
        return new MBeanPluginContext() {
            public ObjectName registerMBean(Object pMBean, String... pOptionalName) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException {
                return MBeanServerHandler.this.registerMBean(pMBean, pOptionalName);
            }

            public void each(ObjectName pObjectName, MBeanEachCallback pCallback) throws IOException, ReflectionException, MBeanException {
                mBeanServerManager.each(pObjectName,pCallback);
            }

            public <R> R call(ObjectName pObjectName, MBeanAction<R> pMBeanAction, Object... pExtraArgs) throws IOException, ReflectionException, MBeanException, AttributeNotFoundException, InstanceNotFoundException {
                return mBeanServerManager.call(pObjectName,pMBeanAction,pExtraArgs);
            }

            public Set<ObjectName> queryNames(ObjectName pObjectName) throws IOException {
                return mBeanServerManager.queryNames(pObjectName);
            }

            public boolean hasMBeansListChangedSince(long pTimestamp) {
                return mBeanServerManager.hasMBeansListChangedSince(pTimestamp);
            }
        };
    }
782806
public ControlBeanContext instantiate(ControlBean controlBean) {
        if(!(controlBean instanceof org.apache.beehive.controls.runtime.bean.ControlBean))
            throw new IllegalArgumentException("The ControlBean of type \"" +
                controlBean.getClass().getName() +
                "\" is unsupported.  The ControlBean must extend " +
                org.apache.beehive.controls.runtime.bean.ControlBean.class.getName());

        /*
        The provided ControlBean is a "api.bean.ControlBean"; this factory implementation only creates
        ControlBeanContext implementations for "runtime.bean.ControlBean" types.  Ensuare that this is
        of that type.
         */
        org.apache.beehive.controls.runtime.bean.ControlBean runtimeControlBean =
            (org.apache.beehive.controls.runtime.bean.ControlBean)controlBean;

        /*
        Create a simple new ControlBeanContext.
        */
        return new org.apache.beehive.controls.runtime.bean.ControlBeanContext(runtimeControlBean);
    }
1123461
public <T> Producer<T> createProducer(final Bean<X> declaringBean, final Bean<T> bean, DisposalMethod<X, T> disposalMethod) {
        EnhancedAnnotatedMethod<T, X> enhancedMethod = getManager().getServices().get(MemberTransformer.class).loadEnhancedMember(method, getManager().getId());
        return new ProducerMethodProducer<X, T>(enhancedMethod, disposalMethod) {

            @Override
            public AnnotatedMethod<X> getAnnotated() {
                return method;
            }

            @Override
            public BeanManagerImpl getBeanManager() {
                return getManager();
            }

            @Override
            public Bean<X> getDeclaringBean() {
                return declaringBean;
            }

            @Override
            public Bean<T> getBean() {
                return bean;
            }
        };
    }
801608
public FacesConfigManagedBeanType<WebFacesConfigDescriptor> getOrCreateManagedBean()
   {
      List<Node> nodeList = model.get("managed-bean");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigManagedBeanTypeImpl<WebFacesConfigDescriptor>(this, "managed-bean", model, nodeList.get(0));
      }
      return createManagedBean();
   }