mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
57dc52bb6f
commit
249e2e8f59
@ -73,6 +73,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public String getCurrentVersion() {
|
||||
Connection conn = null;
|
||||
try {
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user