optimistic = false;
}
sb.append("mode=").append((optimistic ? LocaleHelper.getSpeedoRB().getString("optim")
: LocaleHelper.getSpeedoRB().getString("pessim")));
//fetch the composite TPM
Component composite_tpm = getSubComponent(speedo, COMPOSITE_TPM_PATH);
Component cm = getSubComponent(composite_tpm, "concurrency-manager");
if (dbLocking) {
tempName = DBDELEGATE_CONCURRENCY_TEMPLATE;
sb.append(LocaleHelper.getSpeedoRB().getString("concdeleg"));
} else {
sb.append(LocaleHelper.getSpeedoRB().getString("concspeed"));
if (!optimistic) {
//Configure the pessimistic concurrency manager
//policy= mutex | rw-fifo | rw-reader
strval = getProperty(props,
TRANSACTION_LOCKING_PESSIMISTIC_POLICY,
TRANSACTION_LOCKING_PESSIMISTIC_POLICY_RW_FIFO, true);
PessimisticConcurrencyManagerAC pcmAC = null;
if (!strval.equals(TRANSACTION_LOCKING_PESSIMISTIC_POLICY_RW_FIFO)) {
pcmAC = (PessimisticConcurrencyManagerAC)
Fractal.getAttributeController(cm);
strval = strval.toUpperCase();
if (!strval.startsWith("POLICY_")) {
strval = "POLICY_" + strval;
}
pcmAC.setPolicy(strval);
sb.append(LocaleHelper.getSpeedoRB().getString("lockpol")).append(strval);
}
//locking level = instance | field
strval = getProperty(props,
TRANSACTION_LOCKING_LEVEL_ENABLETHIN,
"false", true);
boolean b = BooleanHelper.parse(strval, false);
if (b) {
logger.log(BasicLevel.INFO, LocaleHelper.getSpeedoRB().getString("thinlock"));
pcmAC = (PessimisticConcurrencyManagerAC)
Fractal.getAttributeController(cm);
pcmAC.setThinkLockAllowed(true);
sb.append(LocaleHelper.getSpeedoRB().getString("thlklvl"));
}
logger.log(BasicLevel.INFO, sb.toString());
return;
}
tempName = OPTIMISTIC_CONCURRENCY_TEMPLATE;
}
//optimistic or dblocking
logger.log(BasicLevel.INFO, sb.toString());
ContentController tpmCC = Fractal.getContentController(composite_tpm);
//fetch the primitive concurrency manager
BindingController tpmBC = Fractal.getBindingController(
getSubComponent(composite_tpm, "transactional-persistence-manager"));
tpmBC.unbindFc("concurrency-manager");
//Remove the old pessimistic concurrency manager
BindingController cmBC = Fractal.getBindingController(cm);
String[] bds = cmBC.listFc();
for (int i = 0; i < bds.length; i++) {
cmBC.unbindFc(bds[i]);
}
tpmCC.removeFcSubComponent(cm);
//instanciate the new ConcurrencyManager
cm = (Component)getADLFactory().newComponent(tempName, null);
//Add the new concurrency manager into the composite
tpmCC.addFcSubComponent(cm);
//bind the server interface of the new concurrency manager
cmBC = Fractal.getBindingController(cm);
if (dbLocking) {
cmBC.bindFc(PConcurrencyManager.STATE_MANAGER_BINDING,
tpmCC.getFcInternalInterface("state-manager"));
cmBC.bindFc(PConcurrencyManager.STORAGE_MANAGER_BINDING,
tpmCC.getFcInternalInterface("storage-manager"));
} else {//optimistic
cmBC.bindFc(PConcurrencyManager.DEPENDENCY_GRAPH_BINDING,
getSubComponent(composite_tpm, "dependency-graph")
.getFcInterface("dependency-graph"));
}
//bind the client interface of the new ConcurrencyManager
tpmBC.bindFc("concurrency-manager", cm.getFcInterface("concurrency-manager"));
}