mirror of https://github.com/apache/cloudstack.git
A workaround to injection problems in servlets (ConsoleProxyServlet and RegisterCompletionServlet) classes
This commit is contained in:
parent
b63b7ddf60
commit
f8e5740c31
|
|
@ -71,13 +71,29 @@ public class ConsoleProxyServlet extends HttpServlet {
|
|||
@Inject ManagementServer _ms;
|
||||
@Inject IdentityService _identityService;
|
||||
|
||||
static AccountManager s_accountMgr;
|
||||
static VirtualMachineManager s_vmMgr;
|
||||
static ManagementServer s_ms;
|
||||
static IdentityService s_identityService;
|
||||
|
||||
public ConsoleProxyServlet() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
void initComponent() {
|
||||
s_ms = _ms;
|
||||
void initComponent() {
|
||||
// Servlet injection does not always work for servlet container
|
||||
// We use a hacking here to initialize static variables at Spring wiring time
|
||||
if(_accountMgr != null) {
|
||||
s_accountMgr = _accountMgr;
|
||||
s_vmMgr = _vmMgr;
|
||||
s_ms = _ms;
|
||||
s_identityService = _identityService;
|
||||
} else {
|
||||
_accountMgr = s_accountMgr;
|
||||
_vmMgr = s_vmMgr;
|
||||
_ms = s_ms;
|
||||
_identityService = s_identityService;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.cloud.servlet;
|
|||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
|
@ -48,6 +49,27 @@ public class RegisterCompleteServlet extends HttpServlet implements ServletConte
|
|||
@Inject ConfigurationDao _configDao;
|
||||
@Inject UserDao _userDao;
|
||||
|
||||
static AccountService s_accountSvc;
|
||||
static ConfigurationDao s_configDao;
|
||||
static UserDao s_userDao;
|
||||
|
||||
public RegisterCompleteServlet() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
void initComponent() {
|
||||
// Hakcing way to make servlet injection work for now
|
||||
if(_accountSvc != null) {
|
||||
s_accountSvc = _accountSvc;
|
||||
s_configDao = _configDao;
|
||||
s_userDao = _userDao;
|
||||
} else {
|
||||
_accountSvc = s_accountSvc;
|
||||
_configDao = s_configDao;
|
||||
_userDao = s_userDao;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue