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 a9efec6403
commit 065ae7a497
4 changed files with 24 additions and 10 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

@ -46,10 +46,10 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
private String guid;
@Column(name = "name")
private String name;
private String vmwareDatacenterName;
@Column(name = "vcenter_host")
private String vCenterHost;
private String vcenterHost;
@Column(name = "uuid")
private String uuid;
@ -73,7 +73,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
@Override
public String getVmwareDatacenterName() {
return name;
return vmwareDatacenterName;
}
@Override
@ -93,7 +93,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
@Override
public String getVcenterHost() {
return vCenterHost;
return vcenterHost;
}
public void setUuid(String uuid) {
@ -105,11 +105,11 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
}
public void setVmwareDatacenterName(String name) {
this.name = name;
this.vmwareDatacenterName = name;
}
public void setVcenterHost(String vCenterHost) {
this.vCenterHost = vCenterHost;
this.vcenterHost = vCenterHost;
}
public void setUser(String user) {
@ -141,9 +141,9 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
public VmwareDatacenterVO(String guid, String name, String vCenterHost, String user, String password) {
this.uuid = UUID.randomUUID().toString();
this.name = name;
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);

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() {