001: /**
002: * Copyright 2004 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: */package com.sun.portal.subscriptions.admin.mbeans;
013:
014: import java.util.logging.Level;
015: import java.util.logging.Logger;
016: import java.util.logging.LogRecord;
017: import java.util.*;
018: import javax.management.ObjectName;
019: import com.sun.portal.admin.common.context.PortalDomainContext;
020: import com.sun.portal.admin.common.context.PSConfigContext;
021: import com.sun.portal.admin.common.util.AdminUtil;
022: import com.sun.portal.admin.server.mbeans.PSResource;
023: import com.sun.portal.admin.common.PSConfigConstants;
024:
025: import com.sun.portal.log.common.PortalLogger;
026:
027: import com.sun.portal.subscriptions.admin.mbeans.tasks.ProfilerController;
028: import com.sun.portal.subscriptions.admin.mbeans.tasks.ProfilerException;
029:
030: public class Profiler extends PSResource implements ProfilerMBean {
031: public static final String CONFIG = "config";
032:
033: private ObjectName objectName = null;
034: private String psPortalID;
035: private String organizationDN;
036: private String usersUID;
037: private String host = null;
038: private PSConfigContext cc = null;
039: private String pconfFileName = null;
040: private static Logger logger = PortalLogger
041: .getLogger(Profiler.class);
042:
043: public Profiler() {
044: }
045:
046: public void init(PSConfigContext cc, PortalDomainContext pdc,
047: List path) {
048: super .init(cc, pdc, path);
049: this .cc = cc;
050: this .psPortalID = (String) path.get(1);
051: pconfFileName = getProfilerConfigFileName();
052: }
053:
054: /*
055: * Gets the profilerRuntime.properties file name based on the portal ID
056: */
057: private String getProfilerConfigFileName() {
058:
059: String psDataDir = cc.getPSDataDir() + fs
060: + PSConfigConstants.PORTALS + fs + psPortalID + fs
061: + PSConfigConstants.CONFIG;
062: String profilerConfDir = psDataDir + fs
063: + PSConfigConstants.PS_PROFILER_CONFIG_FILE;
064: return profilerConfDir;
065: }
066:
067: public void startProfiler(String portalId, String orgDN,
068: String usersUID, String adminUID, String adminPWD)
069: throws ProfilerMBeanException {
070: ProfilerController startTask = new ProfilerController();
071: try {
072: startTask.start(portalId, orgDN, usersUID, pconfFileName,
073: adminUID, adminPWD, getLogger());
074: } catch (ProfilerException e) {
075: if (getLogger().isLoggable(Level.ALL)) {
076: LogRecord rec = new LogRecord(Level.ALL,
077: "PSSS_CSPP0001");
078: String[] param = { e.getMessage() };
079: rec.setThrown(e);
080: rec.setParameters(param);
081: rec.setLoggerName(getLogger().getName());
082: getLogger().log(rec);
083: }
084: }
085: }
086:
087: public void stopProfiler(String portalId, String orgDN,
088: String adminUID, String adminPWD)
089: throws ProfilerMBeanException {
090: ProfilerController stopTask = new ProfilerController();
091: try {
092: stopTask.stop(portalId, orgDN, pconfFileName, adminUID,
093: adminPWD, getLogger());
094: } catch (ProfilerException e) {
095: if (getLogger().isLoggable(Level.ALL)) {
096: LogRecord rec = new LogRecord(Level.ALL,
097: "PSSS_CSPP0001");
098: String[] param = { e.getMessage() };
099: rec.setThrown(e);
100: rec.setParameters(param);
101: rec.setLoggerName(getLogger().getName());
102: getLogger().log(rec);
103: }
104: }
105: }
106:
107: public Logger getLogger() {
108: return logger;
109: }
110:
111: public void setLogger(Logger logger) {
112: this.logger = logger;
113: }
114:
115: }
|