001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */
013:
014: package com.sun.portal.wsrp.consumer.common;
015:
016: import java.util.logging.Level;
017: import java.util.logging.Logger;
018:
019: import javax.servlet.ServletContextListener;
020: import javax.servlet.ServletContextEvent;
021: import javax.servlet.ServletContext;
022:
023: import com.sun.portal.wsrp.consumer.common.RemoteServiceStubManagerFactory;
024: import com.sun.portal.wsrp.consumer.producermanager.ProducerEntityManagerFactory;
025: import com.sun.portal.wsrp.consumer.markup.MarkupManagerFactory;
026: import com.sun.portal.log.common.PortalLogger;
027:
028: /**
029: * This class is used to bootstrap various consumer compoments
030: * during initialization phase. This class has responsibility
031: * to initialize WSRPConsumerConfig, MarkupManager,
032: * RemoteServiceStubManager, ProducerEntityManagerFactory,
033: * WSRPConsumerDebug. Methods in it are called to bootstrap
034: * right components for CLI and for Servlet environment.
035: */
036: public class WSRPConsumerBootstrap implements ServletContextListener {
037:
038: /**
039: * This method is implementation of a method in
040: * ServletContextListener and is called when servlet
041: * for portal is initialized.
042: *
043: * @param sce servlet context.
044: */
045:
046: private static Logger logger = PortalLogger
047: .getLogger(WSRPConsumerBootstrap.class);
048:
049: public void contextInitialized(ServletContextEvent sce) {
050:
051: try {
052:
053: //
054: // Initialize WSRPConsumerConfig singleton
055: //
056:
057: WSRPConsumerConfig.init(sce.getServletContext());
058:
059: //
060: // Initialize WSRPConsumerDebug singleton
061: // Replaced by logger
062:
063: // WSRPConsumerDebug.init();
064:
065: //
066: // Initialize RemoteServiceStubManager singleton
067: //
068:
069: RemoteServiceStubManagerFactory.init();
070:
071: //
072: // Initialize ProducerEntityManagerFactory singleton
073: //
074:
075: ProducerEntityManagerFactory.init();
076:
077: //
078: // Initialize MarkupManagerFactory singleton
079: //
080:
081: MarkupManagerFactory.init();
082:
083: //
084: // a debug message stating we started fine
085:
086: if (logger.isLoggable(Level.FINEST))
087: logger.log(Level.FINEST, "PSWS_CSPWCC0001");
088: } catch (Exception ex) {
089: ex.printStackTrace();
090: throw new RuntimeException("WSRP Initialization Failed: "
091: + ex.getMessage());
092: }
093: }
094:
095: public void contextDestroyed(ServletContextEvent sce) {
096: }
097:
098: /**
099: * This method must be called for any cli
100: * working with WSRPConsumer.
101: *
102: * @param propertiesFile file with wsrp configuration properties.
103: */
104: public static void cliInitialized(String propertiesFile) {
105:
106: try {
107:
108: //
109: // Initialize WSRPConsumerConfig singleton
110: //
111:
112: WSRPConsumerConfig.init(propertiesFile, null);
113:
114: //
115: // Initialize WSRPConsumerDebug singleton
116: // Replaced by logger
117:
118: // WSRPConsumerDebug.init();
119:
120: //
121: // Initialize RemoteServiceStubManager singleton
122: //
123:
124: RemoteServiceStubManagerFactory.init();
125:
126: //
127: // Initialize ProducerEntityManagerFactory singleton
128: //
129:
130: ProducerEntityManagerFactory.init();
131:
132: } catch (Exception ex) {
133: ex.printStackTrace();
134: throw new RuntimeException("WSRP Initialization Failed: "
135: + ex.getMessage());
136: }
137:
138: }
139:
140: /**
141: * This method must be called for any cli
142: * working with WSRPConsumer.
143: *
144: * @param propertiesFile file with wsrp configuration properties.
145: * @param portalId the portal identifier as String
146: */
147: public static void cliInitialized(String propertiesFile,
148: String portalId) {
149:
150: try {
151:
152: //
153: // Initialize WSRPConsumerConfig singleton
154: //
155:
156: WSRPConsumerConfig.init(propertiesFile, portalId);
157:
158: //
159: // Initialize WSRPConsumerDebug singleton
160: // Replaced by logger
161:
162: // WSRPConsumerDebug.init();
163:
164: //
165: // Initialize RemoteServiceStubManager singleton
166: //
167:
168: RemoteServiceStubManagerFactory.init();
169:
170: //
171: // Initialize ProducerEntityManagerFactory singleton
172: //
173:
174: ProducerEntityManagerFactory.init();
175:
176: } catch (Exception ex) {
177: ex.printStackTrace();
178: throw new RuntimeException("WSRP Initialization Failed: "
179: + ex.getMessage());
180: }
181:
182: }
183: }
|