}
public void mergeRef(NamingResources naming, ResourceEnvReferenceInfo ref) {
if (isLookupRef(naming, ref)) return;
ContextResourceEnvRef resourceEnv = naming.findResourceEnvRef(ref.referenceName.replaceAll("^comp/env/", ""));
boolean addEntry = false;
if (resourceEnv == null) {
resourceEnv = new ContextResourceEnvRef();
resourceEnv.setName(ref.referenceName.replaceAll("^comp/env/", ""));
addEntry = true;
}
resourceEnv.setType(ref.resourceEnvRefType);
if (UserTransaction.class.getName().equals(ref.resourceEnvRefType)) {
resourceEnv.setProperty(Constants.FACTORY, UserTransactionFactory.class.getName());
} else if (TransactionManager.class.getName().equals(ref.resourceEnvRefType)) {
resourceEnv.setProperty(Constants.FACTORY, SystemComponentFactory.class.getName());
resourceEnv.setProperty(COMPONENT_TYPE, TransactionManager.class.getName());
} else if (TransactionSynchronizationRegistry.class.getName().equals(ref.resourceEnvRefType)) {
resourceEnv.setProperty(Constants.FACTORY, SystemComponentFactory.class.getName());
resourceEnv.setProperty(COMPONENT_TYPE, TransactionSynchronizationRegistry.class.getName());
} else if (ORB.class.getName().equals(ref.resourceEnvRefType)) {
resourceEnv.setProperty(Constants.FACTORY, SystemComponentFactory.class.getName());
resourceEnv.setProperty(COMPONENT_TYPE, ORB.class.getName());
} else if (HandleDelegate.class.getName().equals(ref.resourceEnvRefType)) {
resourceEnv.setProperty(Constants.FACTORY, SystemComponentFactory.class.getName());
resourceEnv.setProperty(COMPONENT_TYPE, HandleDelegate.class.getName());
} else {
resourceEnv.setProperty(Constants.FACTORY, ResourceFactory.class.getName());
resourceEnv.setProperty(NAME, ref.referenceName.replaceAll("^comp/env/", ""));
if (ref.resourceID != null) {
resourceEnv.setProperty(RESOURCE_ID, ref.resourceID);
}
if (ref.location != null) {
resourceEnv.setProperty(JNDI_NAME, ref.location.jndiName);
resourceEnv.setProperty(JNDI_PROVIDER_ID, ref.location.jndiProviderId);
}
}
if (addEntry) {
naming.addResourceEnvRef(resourceEnv);
}
if (replaceEntry) {
ContextAccessController.setWritable(namingContextListener.getName(), standardContext);
if (!addEntry) namingContextListener.removeResourceEnvRef(resourceEnv.getName());
namingContextListener.addResourceEnvRef(resourceEnv);
ContextAccessController.setReadOnly(namingContextListener.getName());
}
}