1919import java .net .URLEncoder ;
2020import java .util .List ;
2121
22- import javax .annotation .PostConstruct ;
2322import javax .inject .Inject ;
24- import javax .servlet .ServletContextEvent ;
25- import javax .servlet .ServletContextListener ;
23+ import javax .servlet .ServletConfig ;
24+ import javax .servlet .ServletException ;
2625import javax .servlet .http .HttpServlet ;
2726import javax .servlet .http .HttpServletRequest ;
2827import javax .servlet .http .HttpServletResponse ;
2928
3029import org .apache .log4j .Logger ;
3130import org .springframework .stereotype .Component ;
31+ import org .springframework .web .context .support .SpringBeanAutowiringSupport ;
3232
3333import com .cloud .configuration .Configuration ;
3434import com .cloud .configuration .dao .ConfigurationDao ;
4040import com .cloud .utils .SerialVersionUID ;
4141
4242@ Component ("registerCompleteServlet" )
43- public class RegisterCompleteServlet extends HttpServlet implements ServletContextListener {
43+ public class RegisterCompleteServlet extends HttpServlet {
4444 public static final Logger s_logger = Logger .getLogger (RegisterCompleteServlet .class .getName ());
4545
4646 static final long serialVersionUID = SerialVersionUID .CloudStartupServlet ;
@@ -49,35 +49,14 @@ public class RegisterCompleteServlet extends HttpServlet implements ServletConte
4949 @ Inject ConfigurationDao _configDao ;
5050 @ Inject UserDao _userDao ;
5151
52- static AccountService s_accountSvc ;
53- static ConfigurationDao s_configDao ;
54- static UserDao s_userDao ;
55-
5652 public RegisterCompleteServlet () {
5753 }
5854
59- @ PostConstruct
60- void initComponent () {
61- // Hakcing way to make servlet injection work for now
62- if (_accountSvc != null ) {
63- s_accountSvc = _accountSvc ;
64- s_configDao = _configDao ;
65- s_userDao = _userDao ;
66- } else {
67- _accountSvc = s_accountSvc ;
68- _configDao = s_configDao ;
69- _userDao = s_userDao ;
70- }
71- }
72-
73- @ Override
74- public void contextInitialized (ServletContextEvent sce ) {
75- }
76-
7755 @ Override
78- public void contextDestroyed (ServletContextEvent sce ) {
56+ public void init (ServletConfig config ) throws ServletException {
57+ SpringBeanAutowiringSupport .processInjectionBasedOnServletContext (this , config .getServletContext ());
7958 }
80-
59+
8160 @ Override
8261 protected void doPost (HttpServletRequest req , HttpServletResponse resp ) {
8362 doGet (req , resp );
0 commit comments