001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.desktop.monitoring;
006:
007: import com.sun.portal.monitoring.Subsystem;
008: import com.sun.portal.monitoring.MonitoringException;
009: import com.sun.portal.monitoring.Client;
010: import com.sun.portal.monitoring.SubsystemImpl;
011: import com.sun.common.pool.Pool;
012: import com.sun.portal.desktop.mfwk.MfwkFacade;
013: import com.sun.portal.log.common.PortalLogger;
014:
015: import java.util.Properties;
016: import java.util.List;
017: import java.util.Map;
018: import java.util.logging.Level;
019: import java.util.logging.LogRecord;
020: import java.util.logging.Logger;
021:
022: public class MonitoringSubsystemImpl extends SubsystemImpl implements
023: MonitoringSubsystem {
024: private static final Logger logger = PortalLogger
025: .getLogger(MonitoringSubsystemImpl.class);
026:
027: private static LogRecord getLogRecord(Level level, String message,
028: Object[] parameters, Throwable t) {
029: LogRecord result = new LogRecord(level, message);
030: result.setLoggerName(logger.getName());
031: result.setParameters(parameters);
032: result.setThrown(t);
033: return result;
034: }
035:
036: private Properties configurationProperties;
037: private boolean hardDisable = false;
038: private MfwkFacade mfwkFacade;
039: private DesktopRequestStatistic desktopRequestStatistic;
040: private ChannelActionStatistic contentChannelActionStatistic;
041: private ChannelActionStatistic editChannelActionStatistic;
042: private ChannelActionStatistic processChannelActionStatistic;
043: private ChannelCacheHitsStatistic channelCacheHitsStatistic;
044:
045: public Properties getConfigurationProperties() {
046: return configurationProperties;
047: }
048:
049: public void setConfigurationProperties(
050: Properties configurationProperties) {
051: this .configurationProperties = configurationProperties;
052: }
053:
054: private synchronized void gearUp() {
055: if (!isDisabled().booleanValue()) {
056: // Initialization has not failed...
057: setResourceBundleBaseName(DESKTOP_MONITORING_RESOURCE_BUNDLE_BASE_NAME);
058: try {
059: super .start();
060: } catch (MonitoringException e) {
061: hardDisable = true;
062: if (logger.isLoggable(Level.SEVERE)) {
063: logger.log(getLogRecord(Level.SEVERE,
064: "PSDT_CSPDM0002", new Object[] { e
065: .getLocalizedMessage() }, e));
066: }
067: }
068: }
069:
070: desktopRequestStatistic = new DesktopRequestStatisticImpl(this );
071: contentChannelActionStatistic = new ChannelActionStatisticImpl(
072: this , CHANNEL_ACTION_CONTENT);
073: editChannelActionStatistic = new ChannelActionStatisticImpl(
074: this , CHANNEL_ACTION_EDIT);
075: processChannelActionStatistic = new ChannelActionStatisticImpl(
076: this , CHANNEL_ACTION_PROCESS);
077: channelCacheHitsStatistic = new ChannelCacheHitsStatisticImpl(
078: this );
079:
080: String mfwkDisableProperty = getConfigurationProperties()
081: .getProperty("com.sun.portal.mfwk.disable");
082: boolean mfwkDisable = (mfwkDisableProperty != null) ? new Boolean(
083: mfwkDisableProperty).booleanValue()
084: : true;
085: if (!mfwkDisable) {
086: setMfwkFacade(new MfwkFacade());
087: if (!isDisabled().booleanValue()) {
088: try {
089: // Initialization has not failed, and subsystem has started...
090: getMfwkFacade().gearUp(
091: getConfigurationProperties(),
092: getMBeanServer());
093: } catch (MonitoringException e) {
094: hardDisable = true;
095: if (logger.isLoggable(Level.SEVERE)) {
096: logger.log(getLogRecord(Level.SEVERE,
097: "PSDT_CSPDM0002", new Object[] { e
098: .getLocalizedMessage() }, e));
099: }
100: }
101: }
102: }
103: }
104:
105: private synchronized void windDown() throws MonitoringException {
106: if (getMfwkFacade() != null) {
107: // PS:JESMF Integration is active
108: getMfwkFacade().windDown();
109: }
110:
111: super .destroy();
112: }
113:
114: public MonitoringSubsystemImpl(Properties properties) {
115: super (properties);
116: setConfigurationProperties(properties);
117: gearUp();
118: }
119:
120: public DesktopRequestStatistic getDesktopRequestStatistic() {
121: return desktopRequestStatistic;
122: }
123:
124: public ChannelActionStatistic getContentChannelActionStatistic() {
125: return contentChannelActionStatistic;
126: }
127:
128: public ChannelActionStatistic getEditChannelActionStatistic() {
129: return editChannelActionStatistic;
130: }
131:
132: public ChannelActionStatistic getProcessChannelActionStatistic() {
133: return processChannelActionStatistic;
134: }
135:
136: public ChannelCacheHitsStatistic getChannelCacheHitsStatistic() {
137: return channelCacheHitsStatistic;
138: }
139:
140: public void createPoolStatistic(String poolId, int minSize,
141: Pool pool) {
142: new PoolStatisticImpl(this , poolId, minSize, pool);
143: }
144:
145: public Boolean isDisabled() {
146: if (hardDisable) {
147: return Boolean.TRUE;
148: }
149:
150: return super .isDisabled();
151: }
152:
153: public void start() throws MonitoringException {
154: gearUp();
155: }
156:
157: public void destroy() throws MonitoringException {
158: windDown();
159: }
160:
161: public MfwkFacade getMfwkFacade() {
162: return mfwkFacade;
163: }
164:
165: public void setMfwkFacade(MfwkFacade mfwkFacade) {
166: this .mfwkFacade = mfwkFacade;
167: }
168:
169: public void startDesktopServiceTransaction(String serviceName) {
170: if (getMfwkFacade() != null) {
171: getMfwkFacade().startDesktopServiceTransaction(serviceName);
172: }
173: }
174:
175: public void stopDesktopServiceTransaction(String serviceName) {
176: if (getMfwkFacade() != null) {
177: getMfwkFacade().stopDesktopServiceTransaction(serviceName);
178: }
179: }
180:
181: public void startProviderServiceTransaction(String encodedFQCN,
182: String serviceName) {
183: if (getMfwkFacade() != null) {
184: getMfwkFacade().startProviderServiceTransaction(
185: encodedFQCN, serviceName);
186: }
187: }
188:
189: public void stopProviderServiceTransaction(String encodedFQCN,
190: String serviceName) {
191: if (getMfwkFacade() != null) {
192: getMfwkFacade().stopProviderServiceTransaction(encodedFQCN,
193: serviceName);
194: }
195: }
196:
197: public void updateCallerThreadPool(Pool pool) {
198: if (getMfwkFacade() != null) {
199: getMfwkFacade().updateCallerThreadPool(pool);
200: }
201: }
202:
203: public void updateGetterThreadPool(Pool pool) {
204: if (getMfwkFacade() != null) {
205: getMfwkFacade().updateGetterThreadPool(pool);
206: }
207: }
208:
209: public void startDesktopServiceAccessURITransaction() {
210: if (getMfwkFacade() != null) {
211: getMfwkFacade().startDesktopServiceAccessURITransaction();
212: }
213: }
214:
215: public void stopDesktopServiceAccessURITransaction() {
216: if (getMfwkFacade() != null) {
217: getMfwkFacade().stopDesktopServiceAccessURITransaction();
218: }
219: }
220:
221: public Object getDesktopContentServiceTransaction() {
222: if (getMfwkFacade() != null) {
223: return getMfwkFacade()
224: .getDesktopContentServiceTransaction();
225: }
226:
227: return null;
228: }
229:
230: public void startProviderContentServiceTransaction(
231: String encodedFQCN) {
232: if (getMfwkFacade() != null) {
233: getMfwkFacade().startProviderContentServiceTransaction(
234: encodedFQCN);
235: }
236: }
237:
238: public void stopProviderContentServiceTransaction(String encodedFQCN) {
239: if (getMfwkFacade() != null) {
240: getMfwkFacade().stopProviderContentServiceTransaction(
241: encodedFQCN);
242: }
243: }
244: }
|