Correct DAO usage in VmwareDatacenterVO, relax assertion conditions to work with stack calling frame that is not wrapped with @DB injection

This commit is contained in:
Kelven Yang 2013-07-30 18:05:01 -07:00
parent 57dc52bb6f
commit 249e2e8f59
4 changed files with 20 additions and 6 deletions

View File

@ -73,6 +73,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
}
@Override
@DB
public String getCurrentVersion() {
Connection conn = null;
try {

View File

@ -299,13 +299,19 @@ public class Transaction {
if (se == null) {
return false;
}
StringBuffer sb = new StringBuffer();
for (; stack < stacks.length; stack++) {
String methodName = stacks[stack].getMethodName();
sb.append(" ").append(methodName);
if (methodName.equals(se.ref)){
return true;
}
}
return false;
// relax stack structure for several places that @DB required injection is not in place
s_logger.warn("Non-standard stack context that Transaction context is manaully placed into the calling chain. Stack chain: " + sb);
return true;
}
protected static String buildName() {

View File

@ -49,7 +49,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
private String vmwareDatacenterName;
@Column(name = "vcenter_host")
private String vCenterHost;
private String vcenterHost;
@Column(name = "uuid")
private String uuid;
@ -93,7 +93,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
@Override
public String getVcenterHost() {
return vCenterHost;
return vcenterHost;
}
public void setUuid(String uuid) {
@ -109,7 +109,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
}
public void setVcenterHost(String vCenterHost) {
this.vCenterHost = vCenterHost;
this.vcenterHost = vCenterHost;
}
public void setUser(String user) {
@ -143,7 +143,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
this.uuid = UUID.randomUUID().toString();
this.vmwareDatacenterName = name;
this.guid = guid;
this.vCenterHost = vCenterHost;
this.vcenterHost = vCenterHost;
this.user = user;
this.password = password;
}

View File

@ -29,6 +29,7 @@ import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import com.cloud.utils.LogUtils;
import com.cloud.utils.SerialVersionUID;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.db.Transaction;
public class CloudStartupServlet extends HttpServlet {
public static final Logger s_logger = Logger.getLogger(CloudStartupServlet.class.getName());
@ -47,7 +48,13 @@ public class CloudStartupServlet extends HttpServlet {
public void run() {
if(ComponentContext.getApplicationContext() != null) {
_timer.cancel();
ComponentContext.initComponentsLifeCycle();
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
try {
ComponentContext.initComponentsLifeCycle();
} finally {
txn.close();
}
}
}
}, 0, 1000);