01: /**
02: * $Id: ServiceBootstrap.java,v 1.7 2007/01/26 03:50:14 portalbld Exp $
03: * Copyright 2005 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.service.common;
14:
15: import javax.servlet.ServletContextListener;
16: import javax.servlet.ServletContextEvent;
17: import javax.servlet.ServletContext;
18:
19: import com.sun.portal.service.serviceregistry.ServiceRegistryFactory;
20: import com.sun.portal.service.portlet.PortletServiceFactory;
21: import com.sun.portal.service.provider.ProviderServiceFactory;
22: import java.util.logging.Logger;
23: import java.util.logging.Level;
24: import com.sun.portal.log.common.PortalLogger;
25:
26: /**
27: * This class is used to bootstrap various consumer compoments
28: * during initialization phase. This class has responsibility
29: * to initialize all singletons. Methods in it are called to bootstrap
30: * right components for CLI and for Servlet environment.
31: */
32: public class ServiceBootstrap implements ServletContextListener {
33: private static Logger logger = PortalLogger
34: .getLogger(ServiceBootstrap.class);
35:
36: /**
37: * This method is implementation of a method in
38: * ServletContextListener and is called when servlet
39: * for portal is initialized.
40: *
41: * @param sce servlet context.
42: */
43: public void contextInitialized(ServletContextEvent sce) {
44:
45: try {
46:
47: //
48: // Initialize ServiceConfig singleton
49: //
50:
51: ServiceConfig.init(sce.getServletContext());
52:
53: //
54: // Initialize singletons
55: //
56:
57: ServiceRegistryFactory.init();
58:
59: PortletServiceFactory.init();
60:
61: ProviderServiceFactory.init();
62:
63: //
64: // a debug message stating we started fine
65: logger.log(Level.INFO,
66: "Initialized service framework successfully");
67:
68: } catch (Exception ex) {
69: ex.printStackTrace();
70: throw new RuntimeException(
71: "Service Framework Initialization Failed", ex);
72: }
73: }
74:
75: public void contextDestroyed(ServletContextEvent sce) {
76: }
77:
78: }
|