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");
}
persistenceUnitNameQuery = defaultPersistenceUnitAbstractNameQuery;
}
}
checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
}
PersistenceContextReference reference = new PersistenceContextReference(module.getConfigId(), persistenceUnitNameQuery, transactionScoped, properties);
put(persistenceContextRefName, reference, NamingBuilder.JNDI_KEY.get(componentContext));
} catch (DeploymentException e) {
problems.add(e);
}
}
// Support persistence context refs that are mentioned only in the geronimo plan
for (GerPersistenceContextRefType gerPersistenceContextRef : gerPersistenceContextRefsUntyped.values()) {
try {
String persistenceContextRefName = gerPersistenceContextRef.getPersistenceContextRefName();
GerPersistenceContextTypeType.Enum persistenceContextType = gerPersistenceContextRef.getPersistenceContextType();
boolean transactionScoped = persistenceContextType == null || !persistenceContextType.equals(GerPersistenceContextTypeType.EXTENDED);
Map<String, String> properties = new HashMap<String, String>();
addProperties(gerPersistenceContextRef, properties);
AbstractNameQuery persistenceUnitNameQuery = findPersistenceUnit(gerPersistenceContextRef);