private PersistenceUnitDeployment lookupPersistenceUnitDeployment(String unitName) { if (unitName == null) { throw new IllegalArgumentException("unitName is null"); } String beanName = getPersistenceUnitSupplier(topLevelDeploymentUnit, persistenceUnitDependencyResolver, unitName); if (beanName == null) { throw new IllegalStateException("No persistence unit available for " + unitName); } return jbossEjb.lookupPersistenceUnitDeployment(beanName); }
private EntityManagerFactory resolvePersistenceUnit(String unitName) { if (unitName == null) { throw new IllegalArgumentException("unitName is null"); } String beanName = getPersistenceUnitSupplier(topLevelDeploymentUnit, persistenceUnitDependencyResolver, unitName); if (beanName == null) { throw new IllegalStateException("No persistence unit available for " + unitName); } PersistenceUnitDeployment deployment = jbossEjb.lookupPersistenceUnitDeployment(beanName); ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory(); return new InjectedEntityManagerFactory(managedFactory); }
private static String getPersistenceUnitSupplier(DeploymentUnit deploymentUnit, PersistenceUnitDependencyResolver persistenceUnitDependencyResolver, String persistenceUnitName) { if ((deploymentUnit.getAttachment(AttachmentNames.PROCESSED_METADATA, JBossMetaData.class) != null && deploymentUnit.getAttachment(JBossMetaData.class).isEJB3x()) || (deploymentUnit.getAttachment(JBossWebMetaData.class) != null)) { try { return persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName); } catch (IllegalArgumentException e) { // No-op, means we can't find the PU in this DU } } for (DeploymentUnit child : deploymentUnit.getChildren()) { String beanName = getPersistenceUnitSupplier(child, persistenceUnitDependencyResolver, persistenceUnitName); if (beanName != null) { return beanName; } } return null; }
private static String getPersistenceUnitSupplier(DeploymentUnit deploymentUnit, PersistenceUnitDependencyResolver persistenceUnitDependencyResolver, String persistenceUnitName) { if ((deploymentUnit.getAttachment(AttachmentNames.PROCESSED_METADATA, JBossMetaData.class) != null && deploymentUnit.getAttachment(JBossMetaData.class).isEJB3x()) || (deploymentUnit.getAttachment(JBossWebMetaData.class) != null)) { try { return persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName); } catch (IllegalArgumentException e) { // No-op, means we can't find the PU in this DU } } for (DeploymentUnit child : deploymentUnit.getChildren()) { String beanName = getPersistenceUnitSupplier(child, persistenceUnitDependencyResolver, persistenceUnitName); if (beanName != null) { return beanName; } } return null; } }