private TransactionFactory(){}
public static TransactionContainer create(ConfigPropertyLoader config) throws QueryTestFailedException {
TransactionContainer transacton = null;
String type = config.getProperty(TRANSACTION_TYPE);
if (type == null) {
throw new TransactionRuntimeException(TRANSACTION_TYPE + " property was not specified" );
}
TestLogger.logDebug("==== Create Transaction-Option: " + type);
if (type.equalsIgnoreCase(TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
transacton = new LocalTransaction();
}
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.XATRANSACTION)) {
transacton = new XATransaction();
}
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.JNDI_TRANSACTION)) {
transacton = new JNDITransaction();
}
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.OFFWRAP_TRANSACTION)) {
transacton = new TxnAutoTransaction(TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
}
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.ONWRAP_TRANSACTION)) {
transacton = new TxnAutoTransaction(TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_ON);
}
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.AUTOWRAP_TRANSACTION)) {
transacton = new TxnAutoTransaction(TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_AUTO);
} else {
throw new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
}
TestLogger.log("==== TransactionContainer: " + transacton.getClass().getName() + " option:" + type);
return transacton;
}