This method exists to give us access to the protected method
createEntityManagerFactoryImpl(...)
420125
public EntityManagerFactory createContainerEMF(PersistenceUnitInfo info, Map<?, ?> properties,
          boolean requiresConnection) {
          return super.createContainerEntityManagerFactoryImpl(info, properties, requiresConnection);
     }
939437
public EntityManager createEntityManager(String projectId, InputStream jsonCredentialsStream) {
    return createEntityManager(projectId, jsonCredentialsStream, null);
  }
374993
private static String initCreateEntityQuery(EntityKeyMetadata entityKeyMetadata) {
		StringBuilder queryBuilder = new StringBuilder( "CREATE " );
		appendEntityNode( ENTITY_ALIAS, entityKeyMetadata, queryBuilder );
		queryBuilder.append( " RETURN " );
		queryBuilder.append( ENTITY_ALIAS );
		return queryBuilder.toString();
	}
378194
@SuppressWarnings("unchecked")
	private <IN1, IN2, OUT> TypeInformation<OUT> createTypeInfoFromFactory(
			Type t, ArrayList<Type> typeHierarchy, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {

		final ArrayList<Type> factoryHierarchy = new ArrayList<>(typeHierarchy);
		final TypeInfoFactory<? super OUT> factory = getClosestFactory(factoryHierarchy, t);
		if (factory == null) {
			return null;
		}
		final Type factoryDefiningType = factoryHierarchy.get(factoryHierarchy.size() - 1);

		// infer possible type parameters from input
		final Map<String, TypeInformation<?>> genericParams;
		if (factoryDefiningType instanceof ParameterizedType) {
			genericParams = new HashMap<>();
			final ParameterizedType paramDefiningType = (ParameterizedType) factoryDefiningType;
			final Type[] args = typeToClass(paramDefiningType).getTypeParameters();

			final TypeInformation<?>[] subtypeInfo = createSubTypesInfo(t, paramDefiningType, factoryHierarchy, in1Type, in2Type, true);
			assert subtypeInfo != null;
			for (int i = 0; i < subtypeInfo.length; i++) {
				genericParams.put(args[i].toString(), subtypeInfo[i]);
			}
		} else {
			genericParams = Collections.emptyMap();
		}

		final TypeInformation<OUT> createdTypeInfo = (TypeInformation<OUT>) factory.createTypeInfo(t, genericParams);
		if (createdTypeInfo == null) {
			throw new InvalidTypesException("TypeInfoFactory returned invalid TypeInformation 'null'");
		}
		return createdTypeInfo;
	}
354197
@Override
    public EntityManager getEntityManager
                    (JPAPuId puId,
                     J2EEName j2eeName, // d510184
                     String refName, // d510184
                     boolean isExtendedContextType,
                     boolean isUnsynchronized,
                     Map<?, ?> properties)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "getEntityManager : " + puId + ", " + j2eeName);

        EntityManager em = null;
        JPAPUnitInfo puInfo = findPersistenceUnitInfo(puId);
        if (puInfo != null)
        {
            em = isExtendedContextType ?
                            getJPARuntime().createJPAExEntityManager(puId, puInfo, j2eeName, refName, properties, isUnsynchronized, this) :
                            getJPARuntime().createJPATxEntityManager(puId, puInfo, j2eeName, refName, properties, isUnsynchronized, this);
        }
        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "getEntityManager : " + em);
        return em;

    }
576873
@Override
  public final HandlerEntityRequest<RS>
    lazyGetHandlerEntityRequest() throws Exception {
    String beanName = this.factoryAppBeans.getHandlerEntityRequestName();
    @SuppressWarnings("unchecked")
    HandlerEntityRequest<RS> hndlEntityReq = (HandlerEntityRequest<RS>)
      this.factoryAppBeans.getBeansMap().get(beanName);
    if (hndlEntityReq == null) {
      hndlEntityReq = new HandlerEntityRequest<RS>();
      hndlEntityReq.setWriteTi(this.factoryAppBeans.getWriteTi());
      hndlEntityReq.setReadTi(this.factoryAppBeans.getReadTi());
      hndlEntityReq.setWriteReTi(this.factoryAppBeans.getWriteReTi());
      hndlEntityReq.setWrReSpTr(this.factoryAppBeans.getWrReSpTr());
      hndlEntityReq
        .setSrvDatabase(this.factoryAppBeans.lazyGetSrvDatabase());
      hndlEntityReq.setFillEntityFromReq(
        this.factoryAppBeans.lazyGetFillEntityFromReq());
      hndlEntityReq.setLogger(
        this.factoryAppBeans.lazyGetLogger());
      hndlEntityReq.setSecureLogger(
        this.factoryAppBeans.lazyGetSecureLogger());
      hndlEntityReq
        .setEntitiesFactoriesFatory(lazyGetFctBcFctSimpleEntities());
      hndlEntityReq
        .setProcessorsFactory(lazyGetFctBnProcessors());
      hndlEntityReq
        .setProcessorsNamesHolder(new HldProcessorNames());
      hndlEntityReq
        .setEntitiesProcessorsFactory(lazyGetFctBnEntitiesProcessors());
      hndlEntityReq
        .setEntitiesProcessorsNamesHolder(new HldEntitiesProcessorNames());
      @SuppressWarnings("unchecked")
      HashMap<String, Class<?>> mcl = (HashMap<String, Class<?>>)
        this.factoryAppBeans.getEntitiesMap().clone();
      hndlEntityReq.setEntitiesMap(mcl);
      lazyGetFctBnProcessors().getSrvEntitiesPage()
        .setEntitiesMap(mcl);
      this.factoryAppBeans.getBeansMap().put(beanName, hndlEntityReq);
      this.factoryAppBeans.lazyGetLogger().info(null, AFactoryAppBeans.class,
        beanName + " has been created.");
    }
    return hndlEntityReq;
  }
1272770
@Override
    public ConnectionFactory createConnectionFactory(JmsJcaConnectionFactory jcaConnectionFactory) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createConnectionFactory", jcaConnectionFactory);
        ConnectionFactory cf = new JmsManagedConnectionFactoryImpl(jcaConnectionFactory);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createConnectionFactory", cf);
        return cf;
    }
1327678
public function factory()
    {

        // register additional annotation libraries
        foreach ($this->persistenceUnitNode->getAnnotationRegistries() as $annotationRegistry) {
            AnnotationRegistry::registerAutoloadNamespace(
                $annotationRegistry->getNamespace(),
                $annotationRegistry->getDirectoriesAsArray($this->application->getWebappPath())
            );
        }

        // globally ignore configured annotations to ignore
        foreach ($this->persistenceUnitNode->getIgnoredAnnotations() as $ignoredAnnotation) {
            AnnotationReader::addGlobalIgnoredName($ignoredAnnotation->getNodeValue()->__toString());
        }

        // load the metadata configuration
        $metadataConfiguration = $this->persistenceUnitNode->getMetadataConfiguration();

        // prepare the setup properties
        $absolutePaths = $metadataConfiguration->getDirectoriesAsArray($this->application->getWebappPath());
        $proxyDir = $metadataConfiguration->getParam(MetadataConfigurationInterface::PARAM_PROXY_DIR);
        $isDevMode = $metadataConfiguration->getParam(MetadataConfigurationInterface::PARAM_IS_DEV_MODE);
        $useSimpleAnnotationReader = $metadataConfiguration->getParam(MetadataConfigurationInterface::PARAM_USE_SIMPLE_ANNOTATION_READER);

        // load the factory method from the available mappings
        $factoryMethod = EntityManagerFactory::$metadataMapping[$metadataConfiguration->getType()];

        // create the database configuration and initialize the entity manager
        $configuration = Setup::$factoryMethod($absolutePaths, $isDevMode, $proxyDir, null, $useSimpleAnnotationReader);

        // load the datasource node
        $datasourceNode = null;
        foreach ($this->application->getInitialContext()->getSystemConfiguration()->getDatasources() as $datasourceNode) {
            if ($datasourceNode->getName() === $this->persistenceUnitNode->getDatasource()->getName()) {
                break;
            }
        }

        // throw a exception if the configured datasource is NOT available
        if ($datasourceNode == null) {
            throw new \Exception(
                sprintf(
                    'Can\'t find a datasource node for persistence unit %s',
                    $this->persistenceUnitNode->getName()
                )
            );
        }

        // load the database node
        $databaseNode = $datasourceNode->getDatabase();

        // throw an exception if the configured database is NOT available
        if ($databaseNode == null) {
            throw new \Exception(
                sprintf(
                    'Can\'t find database node for persistence unit %s',
                    $this->persistenceUnitNode->getName()
                )
            );
        }

        // load the driver node
        $driverNode = $databaseNode->getDriver();

        // throw an exception if the configured driver is NOT available
        if ($driverNode == null) {
            throw new \Exception(
                sprintf(
                    'Can\'t find driver node for persistence unit %s',
                    $this->persistenceUnitNode->getName()
                )
            );
        }

        // initialize and return a entity manager decorator instance
        return new DoctrineEntityManagerDecorator(
            EntityManager::create(ConnectionUtil::get($this->application)->fromDatabaseNode($databaseNode), $configuration)
        );
    }
504869
private static TrustManagerFactory getTrustManagerFactory(InputStream trustStoreStream, StoreProperties storeProperties)
      throws IOException, GeneralSecurityException {

    // use provider if given, otherwise use the first matching security provider
    final KeyStore ks;
    if (StringUtils.isNotBlank(storeProperties.getProvider())) {
      ks = KeyStore.getInstance(storeProperties.getType(), storeProperties.getProvider());
    }
    else {
      ks = KeyStore.getInstance(storeProperties.getType());
    }

    ks.load(trustStoreStream, storeProperties.getPassword().toCharArray());
    TrustManagerFactory tmf = TrustManagerFactory.getInstance(storeProperties.getManagerType());
    tmf.init(ks);
    return tmf;
  }
492240
public void enableMvc(ConfigurableListableBeanFactory factory, BundleContext context) {
        if (factory == null) {
            throw new IllegalArgumentException("Method argument factory must not be null.");
        }
        if (context == null) {
            throw new IllegalArgumentException("Method argument context must not be null.");
        }

        BundleAwareServletConfig servletConfig = new BundleAwareServletConfig(context);

        factory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext, servletConfig));
        factory.ignoreDependencyInterface(ServletContextAware.class);
        factory.ignoreDependencyInterface(ServletConfigAware.class);

        final BundleSpecificDispatcherServlet dispatcherServlet = createBundleSpecificDispatcherServlet(factory, servletConfig);
        factory.registerSingleton(generateNameFor(BundleSpecificDispatcherServlet.class), dispatcherServlet);
        this.mvcCapableBundles.put(context.getBundle(), dispatcherServlet);
    }
460426
public void exposeAllEntities(EntityManagerFactory emf) {
        Set<ManagedType<?>> managedTypes = emf.getMetamodel().getManagedTypes();
        for (ManagedType<?> managedType : managedTypes) {
            Class<?> managedJavaType = managedType.getJavaType();
            if (managedJavaType.getAnnotation(Entity.class) != null) {
                addRepository(JpaRepositoryConfig.builder(managedJavaType).build());
            }
        }
    }
239405
private static void createFactoryInstance() {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createFactoryInstance");
    try {
      Class cls = Class.forName(JS_MESSAGE_HANDLE_FACTORY_CLASS);
      instance = (JsMessageHandleFactory) cls.newInstance();
    }
    catch (Exception e) {
      FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.JsMessageHandleFactory.createFactoryInstance", "133");
      SibTr.error(tc,"UNABLE_TO_CREATE_HANDLEFACTORY_CWSIF0031",e);
      NoClassDefFoundError ncdfe = new NoClassDefFoundError(e.getMessage());
      ncdfe.initCause(e);
      throw ncdfe;
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createFactoryInstance");
  }
598702
public static void construct(BaseMessageEndpointFactory factory,
                                 MessageEndpointBase messageEndpointBase,
                                 int recoveryId,
                                 EJSContainer container,
                                 BeanMetaData beanMetaData,
                                 EJBPMICollaborator pmiBean,
                                 WrapperManager wrapperManager,
                                 boolean rrsTransactional) //d219252x
    {
        // Initialize superclass with the wrapper information.
        messageEndpointBase.container = container;
        messageEndpointBase.wrapperManager = wrapperManager;
        messageEndpointBase.beanId = new BeanId(factory, null, false);
        messageEndpointBase.bmd = beanMetaData;
        messageEndpointBase.ivPmiBean = pmiBean;
        messageEndpointBase.isolationAttrs = null;
        messageEndpointBase.ivCommon = null; // Not a cached wrapper.     d174057.2
        messageEndpointBase.isManagedWrapper = false; // Not a managed wrapper.    d174057.2
        messageEndpointBase.methodInfos = messageEndpointBase.bmd.localMethodInfos;
        messageEndpointBase.methodNames = messageEndpointBase.bmd.localMethodNames;
        messageEndpointBase.ivInterface = WrapperInterface.MESSAGE_LISTENER; // d366807

        // Initialize this objects instance variables.
        messageEndpointBase.ivRecoveryId = recoveryId;
        messageEndpointBase.ivMessageEndpointFactory = factory;
        messageEndpointBase.ivTransactionManager = EmbeddableTransactionManagerFactory.getTransactionManager();
        messageEndpointBase.ivRRSTransactional = rrsTransactional;

        //d456256 start
        // If there is only 1 method in the EJBMethodInfo for the
        // message listener interface, then set ivSingleMethodInterface
        // to true.
        if (messageEndpointBase.methodInfos.length == 1)
        {
            messageEndpointBase.ivSingleMethodInterface = true;
        }
        // d456256 end
    }
982055
public static LocalContainerEntityManagerFactoryBean newHibernateEntityManagerFactoryBean(final JpaConfigDataHolder config,
                                                                                              final AbstractJpaProperties jpaProperties) {
        val bean = new LocalContainerEntityManagerFactoryBean();
        bean.setJpaVendorAdapter(config.getJpaVendorAdapter());

        if (StringUtils.isNotBlank(config.getPersistenceUnitName())) {
            bean.setPersistenceUnitName(config.getPersistenceUnitName());
        }
        bean.setPackagesToScan(config.getPackagesToScan().toArray(ArrayUtils.EMPTY_STRING_ARRAY));

        if (config.getDataSource() != null) {
            bean.setDataSource(config.getDataSource());
        }

        val properties = new Properties();
        properties.put(Environment.DIALECT, jpaProperties.getDialect());
        properties.put(Environment.HBM2DDL_AUTO, jpaProperties.getDdlAuto());
        properties.put(Environment.STATEMENT_BATCH_SIZE, jpaProperties.getBatchSize());
        if (StringUtils.isNotBlank(jpaProperties.getDefaultCatalog())) {
            properties.put(Environment.DEFAULT_CATALOG, jpaProperties.getDefaultCatalog());
        }
        if (StringUtils.isNotBlank(jpaProperties.getDefaultSchema())) {
            properties.put(Environment.DEFAULT_SCHEMA, jpaProperties.getDefaultSchema());
        }
        properties.put(Environment.ENABLE_LAZY_LOAD_NO_TRANS, Boolean.TRUE);
        properties.put(Environment.FORMAT_SQL, Boolean.TRUE);
        properties.put("hibernate.connection.useUnicode", Boolean.TRUE);
        properties.put("hibernate.connection.characterEncoding", StandardCharsets.UTF_8.name());
        properties.put("hibernate.connection.charSet", StandardCharsets.UTF_8.name());
        if (StringUtils.isNotBlank(jpaProperties.getPhysicalNamingStrategyClassName())) {
            properties.put(Environment.PHYSICAL_NAMING_STRATEGY, jpaProperties.getPhysicalNamingStrategyClassName());
        }
        properties.putAll(jpaProperties.getProperties());
        bean.setJpaProperties(properties);
        return bean;
    }
992010
protected EntityManagerFactory lookupEntityManagerFactory(OpenEntityManager openEntityManager) {
        String emfBeanName = openEntityManager.name();
        String puName = openEntityManager.unitName();
        if (StringUtils.hasLength(emfBeanName)) {
            return this.applicationContext.getBean(emfBeanName, EntityManagerFactory.class);
        } else if (!StringUtils.hasLength(puName)
                && this.applicationContext.containsBean(
                        OpenEntityManagerInViewFilter.DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME)) {
            return this.applicationContext.getBean(
                    OpenEntityManagerInViewFilter.DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME,
                    EntityManagerFactory.class);
        } else {
            // Includes fallback search for single EntityManagerFactory bean by type.
            return EntityManagerFactoryUtils.findEntityManagerFactory(
                    this.applicationContext, puName);
        }
    }
1072386
protected <A extends AggregateRoot<?>> A createFromFactory(Class<A> aggregateClass, Object... parameters) {
        checkNotNull(aggregateClass);
        checkNotNull(parameters);

        Factory<A> factory = domainRegistry.getFactory(aggregateClass);

        // Find the method in the factory which match the signature determined with the previously
        // extracted parameters
        Method factoryMethod;
        boolean useDefaultFactory = false;
        try {
            factoryMethod = MethodMatcher.findMatchingMethod(factory.getClass(), aggregateClass, parameters);
            if (factoryMethod == null) {
                useDefaultFactory = true;
            }
        } catch (Exception e) {
            throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_FIND_FACTORY_METHOD)
                    .put("aggregateClass", aggregateClass.getName())
                    .put("parameters", Arrays.toString(parameters));
        }

        // Invoke the factory to create the aggregate root
        try {
            if (useDefaultFactory) {
                return factory.create(parameters);
            } else {
                if (parameters.length == 0) {
                    return ReflectUtils.invoke(factoryMethod, factory);
                } else {
                    return ReflectUtils.invoke(factoryMethod, factory, parameters);
                }
            }
        } catch (Exception e) {
            throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_INVOKE_FACTORY_METHOD)
                    .put("aggregateClass", aggregateClass.getName())
                    .put("factoryClass", factory.getClass()
                            .getName())
                    .put("factoryMethod", Optional.ofNullable(factoryMethod)
                            .map(Method::getName)
                            .orElse("create"))
                    .put("parameters", Arrays.toString(parameters));
        }
    }
1288109
@Nullable
    private SessionFactory unwrap(EntityManagerFactory entityManagerFactory) {
        try {
            return entityManagerFactory.unwrap(SessionFactory.class);
        } catch (PersistenceException ex) {
            return null;
        }
    }