}
List<PersistenceContextRefType> specPersistenceContextRefsUntyped = convert(specDD.selectChildren(PERSISTENCE_CONTEXT_REF_QNAME_SET), JEE_CONVERTER, PersistenceContextRefType.class, PersistenceContextRefType.type);
Map<String, GerPersistenceContextRefType> gerPersistenceContextRefsUntyped = getGerPersistenceContextRefs(plan);
List<DeploymentException> problems = new ArrayList<DeploymentException>();
Configuration localConfiguration = module.getEarContext().getConfiguration();
for (PersistenceContextRefType persistenceContextRef : specPersistenceContextRefsUntyped) {
try {
String persistenceContextRefName = persistenceContextRef.getPersistenceContextRefName().getStringValue().trim();
addInjections(persistenceContextRefName, persistenceContextRef.getInjectionTargetArray(), componentContext);
PersistenceContextTypeType persistenceContextType = persistenceContextRef.getPersistenceContextType();
boolean transactionScoped = persistenceContextType == null || !persistenceContextType.getStringValue().equalsIgnoreCase("extended");
PropertyType[] propertyTypes = persistenceContextRef.getPersistencePropertyArray();
Map<String, String> properties = new HashMap<String, String>();
for (PropertyType propertyType : propertyTypes) {
String key = propertyType.getName().getStringValue();
String value = propertyType.getValue().getStringValue();
properties.put(key, value);
}
AbstractNameQuery persistenceUnitNameQuery;
GerPersistenceContextRefType gerPersistenceContextRef = gerPersistenceContextRefsUntyped.remove(persistenceContextRefName);
if (gerPersistenceContextRef != null) {
persistenceUnitNameQuery = findPersistenceUnit(gerPersistenceContextRef);
addProperties(gerPersistenceContextRef, properties);
checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
} else if (persistenceContextRef.isSetPersistenceUnitName() && persistenceContextRef.getPersistenceUnitName().getStringValue().trim().length() > 0) {
String persistenceUnitName = persistenceContextRef.getPersistenceUnitName().getStringValue().trim();
persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", persistenceUnitName), PERSISTENCE_UNIT_INTERFACE_TYPES);
if (!checkForGBean(localConfiguration, persistenceUnitNameQuery, strictMatching)) {
persistenceUnitName = "persistence/" + persistenceUnitName;
persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", persistenceUnitName), PERSISTENCE_UNIT_INTERFACE_TYPES);
checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
}
} else {
persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.EMPTY_MAP, PERSISTENCE_UNIT_INTERFACE_TYPES);
Set<AbstractNameQuery> patterns = Collections.singleton(persistenceUnitNameQuery);
LinkedHashSet<GBeanData> gbeans = localConfiguration.findGBeanDatas(localConfiguration, patterns);
persistenceUnitNameQuery = checkForDefaultPersistenceUnit(gbeans);
if (gbeans.isEmpty()) {
gbeans = localConfiguration.findGBeanDatas(patterns);
persistenceUnitNameQuery = checkForDefaultPersistenceUnit(gbeans);
if (gbeans.isEmpty()) {
if (defaultPersistenceUnitAbstractNameQuery == null) {
throw new DeploymentException("No default PersistenceUnit specified, and none located");