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.mfwk;
006:
007: import com.sun.cmm.cim.Distribution;
008: import com.sun.cmm.cim.OperationalStatus;
009: import com.sun.common.pool.Pool;
010: import com.sun.mfwk.instrum.me.CMM_ApplicationSystemInstrum;
011: import com.sun.mfwk.instrum.me.MfManagedElementInstrumException;
012: import com.sun.mfwk.instrum.relations.MfRelationInstrumException;
013: import com.sun.mfwk.instrum.server.MfManagedElementInfo;
014: import com.sun.mfwk.instrum.server.MfManagedElementServer;
015: import com.sun.mfwk.instrum.server.MfManagedElementServerException;
016: import com.sun.mfwk.instrum.server.MfManagedElementServerFactory;
017: import com.sun.mfwk.instrum.server.MfManagedElementType;
018: import com.sun.mfwk.instrum.server.MfRelationInfo;
019: import com.sun.mfwk.instrum.server.MfRelationType;
020: import com.sun.portal.log.common.PortalLogger;
021: import java.util.Arrays;
022: import java.util.HashSet;
023: import java.util.Map;
024: import java.util.Properties;
025: import java.util.TreeMap;
026: import java.util.logging.Level;
027: import java.util.logging.LogRecord;
028: import java.util.logging.Logger;
029: import javax.management.MBeanServer;
030:
031: public class MfwkFacade {
032: private static final Logger logger = PortalLogger
033: .getLogger(MfwkFacade.class);
034:
035: private static LogRecord getLogRecord(Level level, String message,
036: Object[] parameters, Throwable t) {
037: LogRecord result = new LogRecord(level, message);
038: result.setLoggerName(logger.getName());
039: result.setParameters(parameters);
040: result.setThrown(t);
041: return result;
042: }
043:
044: private MfwkContext mfwkContext;
045: private MfManagedElementServer mfmeServer;
046: private boolean gearedUp = false;
047: private MfwkPSApplicationSystemAdaptor applicationSystem;
048: private MfwkPSServiceLogicalComponentAdaptor desktop;
049: private MfwkPSServiceAccessURIAdaptor desktopServiceAccessURI;
050:
051: private static final String DOT = ".";
052: private static final String HASH = "#";
053: private Map desktopServices = new TreeMap();
054:
055: public static final String CACHED_CONTENT = "CachedContent";
056: public static final String CHANNEL_ACTION_CONTENT = "Content";
057: public static final String CHANNEL_ACTION_EDIT = "Edit";
058: public static final String CHANNEL_ACTION_PROCESS = "Process";
059: private Map providerLogicalComponents = new TreeMap();
060: private Map providerServices = new TreeMap();
061:
062: private MfwkPSThreadPoolAdaptor threadPoolCaller;
063: private MfwkPSThreadPoolAdaptor threadPoolGetter;
064:
065: public MfwkContext getMfwkContext() {
066: return mfwkContext;
067: }
068:
069: public void setMfwkContext(MfwkContext mfwkContext) {
070: this .mfwkContext = mfwkContext;
071: }
072:
073: public MfManagedElementServer getMfmeServer() {
074: return mfmeServer;
075: }
076:
077: public void setMfmeServer(MfManagedElementServer mfmeServer) {
078: this .mfmeServer = mfmeServer;
079: }
080:
081: public boolean isGearedUp() {
082: return gearedUp;
083: }
084:
085: public void setGearedUp(boolean gearedUp) {
086: this .gearedUp = gearedUp;
087: }
088:
089: public MfwkPSApplicationSystemAdaptor getApplicationSystem() {
090: return applicationSystem;
091: }
092:
093: public void setApplicationSystem(
094: MfwkPSApplicationSystemAdaptor applicationSystem) {
095: this .applicationSystem = applicationSystem;
096: }
097:
098: public MfwkPSServiceLogicalComponentAdaptor getDesktop() {
099: return desktop;
100: }
101:
102: public void setDesktop(MfwkPSServiceLogicalComponentAdaptor desktop) {
103: this .desktop = desktop;
104: }
105:
106: public MfwkPSServiceAccessURIAdaptor getDesktopServiceAccessURI() {
107: return desktopServiceAccessURI;
108: }
109:
110: public void setDesktopServiceAccessURI(
111: MfwkPSServiceAccessURIAdaptor desktopServiceAccessURI) {
112: this .desktopServiceAccessURI = desktopServiceAccessURI;
113: }
114:
115: private void gearUpApplicationSystem()
116: throws MfManagedElementInstrumException,
117: MfManagedElementServerException, MfRelationInstrumException {
118: String name = getMfwkContext().getConfigProperty(
119: MfwkContext.SUFFIX_APPLICATION_SYSTEM_NAME)
120: + DOT
121: + getMfwkContext().getPortalID()
122: + DOT
123: + getMfwkContext().getInstanceID();
124: String settingName = getMfwkContext().getConfigProperty(
125: MfwkContext.SUFFIX_APPLICATION_SYSTEM_SETTING_NAME)
126: + DOT
127: + getMfwkContext().getPortalID()
128: + DOT
129: + getMfwkContext().getInstanceID();
130: String statsName = getMfwkContext().getConfigProperty(
131: MfwkContext.SUFFIX_APPLICATION_SYSTEM_STATS_NAME)
132: + DOT
133: + getMfwkContext().getPortalID()
134: + DOT
135: + getMfwkContext().getInstanceID();
136: setApplicationSystem(new MfwkPSApplicationSystemAdaptor(name,
137: settingName, statsName));
138:
139: // Use property names at our convenience. Property names are available as far as MfwkFacade is concerned.
140: String instanceDir = getMfwkContext().getContextProperty(
141: "monitoring.MonitoringContext.configuration.directory");
142: String url = getMfwkContext().getContextProperty("url");
143: String description = getMfwkContext().getContextProperty(
144: MfManagedElementServer.PRODUCT_NAME_CTX_KEY);
145: getApplicationSystem().gearUp(getMfmeServer(), description,
146: instanceDir, url);
147: }
148:
149: public Map getDesktopServices() {
150: return desktopServices;
151: }
152:
153: public void setDesktopServices(Map desktopServices) {
154: this .desktopServices = desktopServices;
155: }
156:
157: public Map getProviderLogicalComponents() {
158: return providerLogicalComponents;
159: }
160:
161: public void setProviderLogicalComponents(
162: Map providerLogicalComponents) {
163: this .providerLogicalComponents = providerLogicalComponents;
164: }
165:
166: public Map getProviderServices() {
167: return providerServices;
168: }
169:
170: public void setProviderServices(Map providerServices) {
171: this .providerServices = providerServices;
172: }
173:
174: public MfwkPSThreadPoolAdaptor getThreadPoolCaller() {
175: return threadPoolCaller;
176: }
177:
178: public void setThreadPoolCaller(
179: MfwkPSThreadPoolAdaptor threadPoolCaller) {
180: this .threadPoolCaller = threadPoolCaller;
181: }
182:
183: public MfwkPSThreadPoolAdaptor getThreadPoolGetter() {
184: return threadPoolGetter;
185: }
186:
187: public void setThreadPoolGetter(
188: MfwkPSThreadPoolAdaptor threadPoolGetter) {
189: this .threadPoolGetter = threadPoolGetter;
190: }
191:
192: private void gearUpDesktop()
193: throws MfManagedElementInstrumException,
194: MfManagedElementServerException, MfRelationInstrumException {
195: setDesktop(new MfwkPSServiceLogicalComponentAdaptor(
196: getMfwkContext()
197: .getConfigProperty(
198: MfwkContext.SUFFIX_DESKTOP_LOGICAL_COMPONENT_NAME),
199: getMfwkContext().getConfigProperty(
200: MfwkContext.SUFFIX_DESKTOP_SERVICE_NAME),
201: getMfwkContext()
202: .getConfigProperty(
203: MfwkContext.SUFFIX_DESKTOP_SERVICE_SETTING_NAME),
204: getMfwkContext().getConfigProperty(
205: MfwkContext.SUFFIX_DESKTOP_SERVICE_STATS_NAME),
206: 100, 1000));
207: getDesktop()
208: .gearUp(
209: getMfmeServer(),
210: MfRelationType.CMM_HOSTED_SERVICE,
211: getApplicationSystem().getInstrum(),
212: MfRelationType.CMM_APPLICATION_SYSTEM_LOGICAL_COMPONENT,
213: getApplicationSystem().getInstrum(),
214: MfRelationType.CMM_SERVICE_LOGICAL_COMPONENT);
215: }
216:
217: private void gearUpDesktopServiceAccessURI()
218: throws MfManagedElementInstrumException,
219: MfManagedElementServerException, MfRelationInstrumException {
220: setDesktopServiceAccessURI(new MfwkPSServiceAccessURIAdaptor(
221: getMfwkContext()
222: .getConfigProperty(
223: MfwkContext.SUFFIX_DESKTOP_SERVICE_ACCESS_URI_NAME),
224: getMfwkContext()
225: .getConfigProperty(
226: MfwkContext.SUFFIX_DESKTOP_SERVICE_ACCESS_URI_SETTING_NAME),
227: getMfwkContext()
228: .getConfigProperty(
229: MfwkContext.SUFFIX_DESKTOP_SERVICE_ACCESS_URI_STATS_NAME),
230: getMfwkContext().getContextProperty("url"), false));
231: getDesktopServiceAccessURI().gearUp(getMfmeServer(),
232: MfRelationType.CMM_HOSTED_ACCESS_POINT,
233: getApplicationSystem().getInstrum());
234: }
235:
236: private void gearUpThreadPools()
237: throws MfManagedElementInstrumException,
238: MfManagedElementServerException, MfRelationInstrumException {
239: setThreadPoolCaller(new MfwkPSThreadPoolAdaptor(
240: getMfwkContext().getConfigProperty(
241: MfwkContext.SUFFIX_THREAD_POOL_CALLER_NAME),
242: getMfwkContext()
243: .getConfigProperty(
244: MfwkContext.SUFFIX_THREAD_POOL_CALLER_SETTING_NAME),
245: getMfwkContext()
246: .getConfigProperty(
247: MfwkContext.SUFFIX_THREAD_POOL_CALLER_STATS_NAME),
248: "CallerThreadPool", 0, 0, 0));
249: getThreadPoolCaller().gearUp(getMfmeServer(),
250: MfRelationType.CMM_RESOURCE_OF_SYSTEM,
251: getApplicationSystem().getInstrum());
252:
253: setThreadPoolGetter(new MfwkPSThreadPoolAdaptor(
254: getMfwkContext().getConfigProperty(
255: MfwkContext.SUFFIX_THREAD_POOL_GETTER_NAME),
256: getMfwkContext()
257: .getConfigProperty(
258: MfwkContext.SUFFIX_THREAD_POOL_GETTER_SETTING_NAME),
259: getMfwkContext()
260: .getConfigProperty(
261: MfwkContext.SUFFIX_THREAD_POOL_GETTER_STATS_NAME),
262: "GetterThreadPool", 0, 0, 0));
263: getThreadPoolGetter().gearUp(getMfmeServer(),
264: MfRelationType.CMM_RESOURCE_OF_SYSTEM,
265: getApplicationSystem().getInstrum());
266: }
267:
268: public void gearUp(Properties properties, MBeanServer mBeanServer) {
269: ClassLoader cl = Thread.currentThread().getContextClassLoader();
270: try {
271: Thread.currentThread().setContextClassLoader(
272: getClass().getClassLoader());
273:
274: setMfwkContext(new MfwkContext(properties));
275: setMfmeServer(MfManagedElementServerFactory
276: .makeManagedElementServer());
277: getMfmeServer().initialize(
278: getMfwkContext().getMeServerConfigProperties(),
279: getMfwkContext().getMeServerContext());
280: if (mBeanServer != null) {
281: getMfmeServer().start(mBeanServer);
282: } else {
283: getMfmeServer().start();
284: }
285: getMfmeServer().publish();
286:
287: gearUpApplicationSystem();
288: gearUpDesktop();
289: gearUpDesktopServiceAccessURI();
290: gearUpThreadPools();
291:
292: setGearedUp(true);
293: } catch (MfManagedElementServerException e) {
294: if (logger.isLoggable(Level.SEVERE)) {
295: logger.log(getLogRecord(Level.SEVERE,
296: "PSDT_CSPDMF0001", new Object[] { e
297: .getLocalizedMessage() }, e));
298: }
299: } catch (MfManagedElementInstrumException e) {
300: if (logger.isLoggable(Level.SEVERE)) {
301: logger.log(getLogRecord(Level.SEVERE,
302: "PSDT_CSPDMF0001", new Object[] { e
303: .getLocalizedMessage() }, e));
304: }
305: } catch (MfRelationInstrumException e) {
306: if (logger.isLoggable(Level.SEVERE)) {
307: logger.log(getLogRecord(Level.SEVERE,
308: "PSDT_CSPDMF0001", new Object[] { e
309: .getLocalizedMessage() }, e));
310: }
311: } finally {
312: if (cl != null) {
313: Thread.currentThread().setContextClassLoader(cl);
314: }
315: }
316: }
317:
318: public void windDown() {
319: if (!isGearedUp()) {
320: return;
321: }
322:
323: getApplicationSystem().windDown();
324: try {
325: getMfmeServer().stop();
326: } catch (MfManagedElementServerException e) {
327: if (logger.isLoggable(Level.SEVERE)) {
328: logger.log(getLogRecord(Level.SEVERE,
329: "PSDT_CSPDMF0001", new Object[] { e
330: .getLocalizedMessage() }, e));
331: }
332: }
333: }
334:
335: public void startDesktopServiceTransaction(String serviceName) {
336: if (!isGearedUp()) {
337: return;
338: }
339:
340: MfwkPSServiceAdaptor serviceAdaptor = (MfwkPSServiceAdaptor) getDesktopServices()
341: .get(serviceName);
342: if (serviceAdaptor == null) {
343: serviceAdaptor = new MfwkPSServiceAdaptor(
344: getMfwkContext().getConfigProperty(
345: MfwkContext.SUFFIX_DESKTOP_SERVICE_NAME
346: + DOT + serviceName),
347: getMfwkContext()
348: .getConfigProperty(
349: MfwkContext.SUFFIX_DESKTOP_SERVICE_SETTING_NAME
350: + DOT + serviceName),
351: getMfwkContext()
352: .getConfigProperty(
353: MfwkContext.SUFFIX_DESKTOP_SERVICE_STATS_NAME
354: + DOT + serviceName), 100,
355: 1000);
356: try {
357: serviceAdaptor.gearUp(getMfmeServer(),
358: MfRelationType.CMM_SERVICE_COMPONENT,
359: getDesktop().getServiceAdaptor().getInstrum());
360: } catch (MfRelationInstrumException e) {
361: if (logger.isLoggable(Level.SEVERE)) {
362: logger.log(getLogRecord(Level.SEVERE,
363: "PSDT_CSPDMF0001", new Object[] { e
364: .getLocalizedMessage() }, e));
365: }
366: } catch (MfManagedElementInstrumException e) {
367: if (logger.isLoggable(Level.SEVERE)) {
368: logger.log(getLogRecord(Level.SEVERE,
369: "PSDT_CSPDMF0001", new Object[] { e
370: .getLocalizedMessage() }, e));
371: }
372: } catch (MfManagedElementServerException e) {
373: if (logger.isLoggable(Level.SEVERE)) {
374: logger.log(getLogRecord(Level.SEVERE,
375: "PSDT_CSPDMF0001", new Object[] { e
376: .getLocalizedMessage() }, e));
377: }
378: }
379:
380: getDesktopServices().put(serviceName, serviceAdaptor);
381: }
382:
383: serviceAdaptor.startTransaction();
384:
385: if (logger.isLoggable(Level.FINEST)) {
386: logger.log(getLogRecord(Level.FINEST, "PSDT_CSPDMF0004",
387: new Object[] { "DesktopService " + serviceName
388: + " Xaction start" }, null));
389: }
390: }
391:
392: public void stopDesktopServiceTransaction(String serviceName) {
393: if (!isGearedUp()) {
394: return;
395: }
396:
397: MfwkPSServiceAdaptor serviceAdaptor = (MfwkPSServiceAdaptor) getDesktopServices()
398: .get(serviceName);
399: // No check for serviceAdaptor = null as startDesktopServiceTransaction must have been called for serviceName
400: serviceAdaptor.stopTransaction();
401:
402: if (logger.isLoggable(Level.FINEST)) {
403: logger.log(getLogRecord(Level.FINEST, "PSDT_CSPDMF0004",
404: new Object[] { "DesktopService " + serviceName
405: + " Xaction end" }, null));
406: }
407: }
408:
409: private String getProviderKey(String channelID) {
410: return HASH + channelID;
411: }
412:
413: private String getProviderServiceKey(String channelID,
414: String serviceName) {
415: return HASH + serviceName + HASH + channelID;
416: }
417:
418: private MfwkPSLogicalComponentAdaptor getProviderLogicalComponentAdaptor(
419: String providerKey)
420: throws MfManagedElementInstrumException,
421: MfManagedElementServerException, MfRelationInstrumException {
422: MfwkPSLogicalComponentAdaptor providerLogicalComponentAdaptor = (MfwkPSLogicalComponentAdaptor) getProviderLogicalComponents()
423: .get(providerKey);
424: if (providerLogicalComponentAdaptor == null) {
425: providerLogicalComponentAdaptor = new MfwkPSLogicalComponentAdaptor(
426: providerKey);
427: providerLogicalComponentAdaptor.gearUp(getMfmeServer(),
428: MfRelationType.CMM_LOGICAL_COMPONENT_HIERARCHY,
429: getDesktop().getLogicalComponentAdaptor()
430: .getInstrum());
431: getProviderLogicalComponents().put(providerKey,
432: providerLogicalComponentAdaptor);
433: }
434:
435: return providerLogicalComponentAdaptor;
436: }
437:
438: private MfwkPSServiceAdaptor getProviderServiceAdaptor(
439: String channelID, String serviceName) {
440: MfwkPSServiceAdaptor serviceAdaptor = null;
441:
442: String providerKey = getProviderKey(channelID);
443: try {
444: MfwkPSLogicalComponentAdaptor providerLogicalComponentAdaptor = getProviderLogicalComponentAdaptor(providerKey);
445: String providerServiceKey = getProviderServiceKey(
446: channelID, serviceName);
447: serviceAdaptor = (MfwkPSServiceAdaptor) getProviderServices()
448: .get(providerServiceKey);
449: if (serviceAdaptor == null) {
450: serviceAdaptor = new MfwkPSServiceAdaptor(
451: getMfwkContext()
452: .getConfigProperty(
453: MfwkContext.SUFFIX_PROVIDER_SERVICE_NAME
454: + DOT + serviceName)
455: + providerKey,
456: getMfwkContext()
457: .getConfigProperty(
458: MfwkContext.SUFFIX_PROVIDER_SERVICE_SETTING_NAME
459: + DOT + serviceName)
460: + providerKey,
461: getMfwkContext()
462: .getConfigProperty(
463: MfwkContext.SUFFIX_PROVIDER_SERVICE_STATS_NAME
464: + DOT + serviceName)
465: + providerKey, 100, 1000);
466: try {
467: serviceAdaptor.gearUp(getMfmeServer(),
468: MfRelationType.CMM_HOSTED_SERVICE,
469: getApplicationSystem().getInstrum());
470:
471: MfRelationInfo mfrInfo = getMfmeServer()
472: .makeRelationInfo();
473: mfrInfo
474: .setType(MfRelationType.CMM_SERVICE_LOGICAL_COMPONENT);
475: getMfmeServer().createRelation(
476: serviceAdaptor.getInstrum(),
477: mfrInfo,
478: providerLogicalComponentAdaptor
479: .getInstrum());
480:
481: mfrInfo = getMfmeServer().makeRelationInfo();
482: mfrInfo
483: .setType(MfRelationType.CMM_SERVICE_SERVICE_DEPENDENCY);
484: if (serviceName.equals(CACHED_CONTENT)) {
485: // CachedContent service is associated with Desktop Content service
486: getMfmeServer().createRelation(
487: serviceAdaptor.getInstrum(),
488: mfrInfo,
489: ((MfwkPSServiceAdaptor) desktopServices
490: .get(CHANNEL_ACTION_CONTENT))
491: .getInstrum());
492: } else {
493: getMfmeServer()
494: .createRelation(
495: serviceAdaptor.getInstrum(),
496: mfrInfo,
497: ((MfwkPSServiceAdaptor) desktopServices
498: .get(serviceName))
499: .getInstrum());
500: }
501: } catch (MfManagedElementInstrumException e) {
502: if (logger.isLoggable(Level.SEVERE)) {
503: logger.log(getLogRecord(Level.SEVERE,
504: "PSDT_CSPDMF0001", new Object[] { e
505: .getLocalizedMessage() }, e));
506: }
507: } catch (MfManagedElementServerException e) {
508: if (logger.isLoggable(Level.SEVERE)) {
509: logger.log(getLogRecord(Level.SEVERE,
510: "PSDT_CSPDMF0001", new Object[] { e
511: .getLocalizedMessage() }, e));
512: }
513: } catch (MfRelationInstrumException e) {
514: if (logger.isLoggable(Level.SEVERE)) {
515: logger.log(getLogRecord(Level.SEVERE,
516: "PSDT_CSPDMF0001", new Object[] { e
517: .getLocalizedMessage() }, e));
518: }
519: }
520:
521: getProviderServices().put(providerServiceKey,
522: serviceAdaptor);
523: }
524: } catch (MfManagedElementInstrumException e) {
525: if (logger.isLoggable(Level.SEVERE)) {
526: logger.log(getLogRecord(Level.SEVERE,
527: "PSDT_CSPDMF0001", new Object[] { e
528: .getLocalizedMessage() }, e));
529: }
530: } catch (MfRelationInstrumException e) {
531: if (logger.isLoggable(Level.SEVERE)) {
532: logger.log(getLogRecord(Level.SEVERE,
533: "PSDT_CSPDMF0001", new Object[] { e
534: .getLocalizedMessage() }, e));
535: }
536: } catch (MfManagedElementServerException e) {
537: if (logger.isLoggable(Level.SEVERE)) {
538: logger.log(getLogRecord(Level.SEVERE,
539: "PSDT_CSPDMF0001", new Object[] { e
540: .getLocalizedMessage() }, e));
541: }
542: }
543:
544: return serviceAdaptor;
545: }
546:
547: public void startProviderServiceTransaction(String channelID,
548: String serviceName) {
549: if (!isGearedUp()) {
550: return;
551: }
552:
553: MfwkPSServiceAdaptor serviceAdaptor = getProviderServiceAdaptor(
554: channelID, serviceName);
555: if (serviceName.equals(CACHED_CONTENT)) {
556: // CachedContent service transaction is like Content service transactions, i.e. subtransaction of Desktop Content service transaction
557: serviceAdaptor
558: .startTransaction(((MfwkPSServiceAdaptor) getDesktopServices()
559: .get(CHANNEL_ACTION_CONTENT))
560: .getTransactionInstrum());
561: } else {
562: // Provider service transactions are sub-transactions of corresponding Desktop service transactions
563: serviceAdaptor
564: .startTransaction(((MfwkPSServiceAdaptor) getDesktopServices()
565: .get(serviceName)).getTransactionInstrum());
566: }
567:
568: if (logger.isLoggable(Level.FINEST)) {
569: logger
570: .log(getLogRecord(
571: Level.FINEST,
572: "PSDT_CSPDMF0004",
573: new Object[] { "ProviderService "
574: + serviceName
575: + " Xaction start for " + channelID },
576: null));
577: }
578: }
579:
580: public void stopProviderServiceTransaction(String channelID,
581: String serviceName) {
582: if (!isGearedUp()) {
583: return;
584: }
585:
586: MfwkPSServiceAdaptor serviceAdaptor = getProviderServiceAdaptor(
587: channelID, serviceName);
588: serviceAdaptor.stopTransaction();
589:
590: if (logger.isLoggable(Level.FINEST)) {
591: logger.log(getLogRecord(Level.FINEST, "PSDT_CSPDMF0004",
592: new Object[] { "ProviderService " + serviceName
593: + " Xaction end for " + channelID }, null));
594: }
595: }
596:
597: public void updateCallerThreadPool(Pool pool) {
598: if (!isGearedUp()) {
599: return;
600: }
601:
602: try {
603: getThreadPoolCaller().getStatsInstrum()
604: .setCurrentNumberOfThreads(pool.size());
605: getThreadPoolCaller().getStatsInstrum()
606: .setCurrentNumberOfThreadsLowerBound(
607: pool.getMinSize());
608: getThreadPoolCaller().getStatsInstrum()
609: .setCurrentNumberOfThreadsUpperBound(
610: pool.getMaxSize());
611: getThreadPoolCaller().getStatsInstrum()
612: .setNumberOfAvailableThreads(
613: Math.abs(pool.size() - pool.getLeased()));
614: getThreadPoolCaller().getStatsInstrum()
615: .setNumberOfBusyThreads(pool.getLeased());
616: } catch (MfRelationInstrumException e) {
617: if (logger.isLoggable(Level.SEVERE)) {
618: logger.log(getLogRecord(Level.SEVERE,
619: "PSDT_CSPDMF0001", new Object[] { e
620: .getLocalizedMessage() }, e));
621: }
622: } catch (MfManagedElementInstrumException e) {
623: if (logger.isLoggable(Level.SEVERE)) {
624: logger.log(getLogRecord(Level.SEVERE,
625: "PSDT_CSPDMF0001", new Object[] { e
626: .getLocalizedMessage() }, e));
627: }
628: }
629: }
630:
631: public void updateGetterThreadPool(Pool pool) {
632: if (!isGearedUp()) {
633: return;
634: }
635:
636: try {
637: getThreadPoolGetter().getStatsInstrum()
638: .setCurrentNumberOfThreads(pool.size());
639: getThreadPoolGetter().getStatsInstrum()
640: .setCurrentNumberOfThreadsLowerBound(
641: pool.getMinSize());
642: getThreadPoolGetter().getStatsInstrum()
643: .setCurrentNumberOfThreadsUpperBound(
644: pool.getMaxSize());
645: getThreadPoolGetter().getStatsInstrum()
646: .setNumberOfAvailableThreads(
647: Math.abs(pool.size() - pool.getLeased()));
648: getThreadPoolGetter().getStatsInstrum()
649: .setNumberOfBusyThreads(pool.getLeased());
650: } catch (MfRelationInstrumException e) {
651: if (logger.isLoggable(Level.SEVERE)) {
652: logger.log(getLogRecord(Level.SEVERE,
653: "PSDT_CSPDMF0001", new Object[] { e
654: .getLocalizedMessage() }, e));
655: }
656: } catch (MfManagedElementInstrumException e) {
657: if (logger.isLoggable(Level.SEVERE)) {
658: logger.log(getLogRecord(Level.SEVERE,
659: "PSDT_CSPDMF0001", new Object[] { e
660: .getLocalizedMessage() }, e));
661: }
662: }
663: }
664:
665: public void startDesktopServiceAccessURITransaction() {
666: if (!isGearedUp()) {
667: return;
668: }
669:
670: getDesktopServiceAccessURI().startTransaction();
671: }
672:
673: public void stopDesktopServiceAccessURITransaction() {
674: if (!isGearedUp()) {
675: return;
676: }
677:
678: getDesktopServiceAccessURI().stopTransaction();
679: }
680:
681: public Object getDesktopContentServiceTransaction() {
682: return ((MfwkPSServiceAdaptor) getDesktopServices().get(
683: CHANNEL_ACTION_CONTENT)).getTransactionInstrum();
684: }
685:
686: public void startProviderContentServiceTransaction(String channelID) {
687: if (!isGearedUp()) {
688: return;
689: }
690:
691: MfwkPSServiceAdaptor serviceAdaptor = getProviderServiceAdaptor(
692: channelID, CHANNEL_ACTION_CONTENT);
693: serviceAdaptor.startTransaction();
694:
695: if (logger.isLoggable(Level.FINEST)) {
696: logger
697: .log(getLogRecord(
698: Level.FINEST,
699: "PSDT_CSPDMF0004",
700: new Object[] { "ProviderService "
701: + CHANNEL_ACTION_CONTENT
702: + " Xaction start for " + channelID },
703: null));
704: }
705: }
706:
707: public void stopProviderContentServiceTransaction(String channelID) {
708: if (!isGearedUp()) {
709: return;
710: }
711:
712: MfwkPSServiceAdaptor serviceAdaptor = getProviderServiceAdaptor(
713: channelID, CHANNEL_ACTION_CONTENT);
714: serviceAdaptor.stopTransaction();
715:
716: if (logger.isLoggable(Level.FINEST)) {
717: logger.log(getLogRecord(Level.FINEST, "PSDT_CSPDMF0004",
718: new Object[] { "ProviderService "
719: + CHANNEL_ACTION_CONTENT
720: + " Xaction end for " + channelID }, null));
721: }
722: }
723: }
|