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.mfwk.instrum.me.CMM_ApplicationSystemInstrum;
010: import com.sun.mfwk.instrum.me.MfManagedElementInstrumException;
011: import com.sun.mfwk.instrum.me.settings.CMM_ApplicationSystemSettingInstrum;
012: import com.sun.mfwk.instrum.me.statistics.CMM_ApplicationSystemStatsInstrum;
013: import com.sun.mfwk.instrum.relations.MfRelationInstrumException;
014: import com.sun.mfwk.instrum.server.MfManagedElementInfo;
015: import com.sun.mfwk.instrum.server.MfManagedElementServer;
016: import com.sun.mfwk.instrum.server.MfManagedElementServerException;
017: import com.sun.mfwk.instrum.server.MfManagedElementType;
018: import com.sun.mfwk.instrum.server.MfRelationType;
019: import com.sun.portal.log.common.PortalLogger;
020: import java.util.Arrays;
021: import java.util.HashSet;
022: import java.util.logging.Level;
023: import java.util.logging.LogRecord;
024: import java.util.logging.Logger;
025:
026: public class MfwkPSApplicationSystemAdaptor {
027: private static final Logger logger = PortalLogger
028: .getLogger(MfwkPSApplicationSystemAdaptor.class);
029:
030: private static Logger getLogger() {
031: return logger;
032: }
033:
034: private static LogRecord getLogRecord(Level level, String message,
035: Object[] parameters, Throwable t) {
036: LogRecord result = new LogRecord(level, message);
037: result.setLoggerName(getLogger().getName());
038: result.setParameters(parameters);
039: result.setThrown(t);
040: return result;
041: }
042:
043: private String name;
044: private String settingName;
045: private String statsName;
046:
047: public MfwkPSApplicationSystemAdaptor(String name,
048: String settingName, String statsName) {
049: setName(name);
050: setSettingName(settingName);
051: setStatsName(statsName);
052: }
053:
054: public String getName() {
055: return name;
056: }
057:
058: public void setName(String name) {
059: this .name = name;
060: }
061:
062: public String getSettingName() {
063: return settingName;
064: }
065:
066: public void setSettingName(String settingName) {
067: this .settingName = settingName;
068: }
069:
070: public String getStatsName() {
071: return statsName;
072: }
073:
074: public void setStatsName(String statsName) {
075: this .statsName = statsName;
076: }
077:
078: private boolean gearedUp = false;
079: private MfManagedElementInfo info;
080: private MfManagedElementInfo settingInfo;
081: private MfManagedElementInfo statsInfo;
082: private MfwkPSRelationAdaptor relation;
083: private MfwkPSRelationAdaptor settingRelation;
084: private MfwkPSRelationAdaptor statsRelation;
085: private CMM_ApplicationSystemInstrum instrum;
086:
087: public boolean isGearedUp() {
088: return gearedUp;
089: }
090:
091: public void setGearedUp(boolean gearedUp) {
092: this .gearedUp = gearedUp;
093: }
094:
095: public MfManagedElementInfo getInfo() {
096: return info;
097: }
098:
099: public void setInfo(MfManagedElementInfo info) {
100: this .info = info;
101: }
102:
103: public MfManagedElementInfo getSettingInfo() {
104: return settingInfo;
105: }
106:
107: public void setSettingInfo(MfManagedElementInfo settingInfo) {
108: this .settingInfo = settingInfo;
109: }
110:
111: public MfManagedElementInfo getStatsInfo() {
112: return statsInfo;
113: }
114:
115: public void setStatsInfo(MfManagedElementInfo statsInfo) {
116: this .statsInfo = statsInfo;
117: }
118:
119: public MfwkPSRelationAdaptor getRelation() {
120: return relation;
121: }
122:
123: public void setRelation(MfwkPSRelationAdaptor relation) {
124: this .relation = relation;
125: }
126:
127: public MfwkPSRelationAdaptor getSettingRelation() {
128: return settingRelation;
129: }
130:
131: public void setSettingRelation(MfwkPSRelationAdaptor settingRelation) {
132: this .settingRelation = settingRelation;
133: }
134:
135: public MfwkPSRelationAdaptor getStatsRelation() {
136: return statsRelation;
137: }
138:
139: public void setStatsRelation(MfwkPSRelationAdaptor statsRelation) {
140: this .statsRelation = statsRelation;
141: }
142:
143: public CMM_ApplicationSystemInstrum getInstrum() {
144: return instrum;
145: }
146:
147: public void setInstrum(CMM_ApplicationSystemInstrum instrum) {
148: this .instrum = instrum;
149: }
150:
151: public CMM_ApplicationSystemSettingInstrum getSettingInstrum()
152: throws MfRelationInstrumException {
153: return (CMM_ApplicationSystemSettingInstrum) getSettingRelation()
154: .getInstrum().getDestination();
155: }
156:
157: public CMM_ApplicationSystemStatsInstrum getStatsInstrum()
158: throws MfRelationInstrumException {
159: return (CMM_ApplicationSystemStatsInstrum) getStatsRelation()
160: .getInstrum().getDestination();
161: }
162:
163: public void gearUp(MfManagedElementServer mfmeServer,
164: String description, String instanceDir, String url)
165: throws MfManagedElementInstrumException,
166: MfManagedElementServerException, MfRelationInstrumException {
167: setInfo(mfmeServer.makeManagedElementInfo());
168: getInfo().setName(getName());
169: getInfo().setType(MfManagedElementType.CMM_APPLICATION_SYSTEM);
170: setInstrum((CMM_ApplicationSystemInstrum) mfmeServer
171: .createManagedElement(getInfo()));
172:
173: getInstrum().setDescription(description);
174: getInstrum().setDistribution(Distribution.LOCAL);
175: OperationalStatus[] operationalStatus = new OperationalStatus[] { OperationalStatus.OK };
176: getInstrum().setOperationalStatus(
177: new HashSet(Arrays.asList(operationalStatus)));
178:
179: setSettingInfo(mfmeServer.makeManagedElementInfo());
180: getSettingInfo().setName(getSettingName());
181: getSettingInfo().setType(
182: MfManagedElementType.CMM_APPLICATION_SYSTEM_SETTING);
183: setSettingRelation(new MfwkPSRelationAdaptor(
184: MfRelationType.CMM_SCOPED_SETTING, getInstrum()));
185: getSettingRelation().gearUp(mfmeServer, getSettingInfo());
186: getSettingInstrum().setConfigurationDirectory(instanceDir);
187: getSettingInstrum().setDirectoryName(instanceDir);
188: getSettingInstrum().setURL(url);
189:
190: setStatsInfo(mfmeServer.makeManagedElementInfo());
191: getStatsInfo().setName(getStatsName());
192: getStatsInfo().setType(
193: MfManagedElementType.CMM_APPLICATION_SYSTEM_STATS);
194: setStatsRelation(new MfwkPSRelationAdaptor(
195: MfRelationType.CMM_ELEMENT_STATISTICAL_DATA,
196: getInstrum()));
197: getStatsRelation().gearUp(mfmeServer, getStatsInfo());
198: getStatsInstrum().setFailedOutboundAssociations(0);
199: getStatsInstrum().setInboundAssociations(0);
200: getStatsInstrum().setOutboundAssociations(0);
201: getStatsInstrum().setRejectedInboundAssociations(0);
202:
203: setGearedUp(true);
204: }
205:
206: public void windDown() {
207: try {
208: OperationalStatus[] operationalStatus = new OperationalStatus[] { OperationalStatus.STOPPED, };
209: getInstrum().setOperationalStatus(
210: new HashSet(Arrays.asList(operationalStatus)));
211: } catch (MfManagedElementInstrumException e) {
212: if (getLogger().isLoggable(Level.SEVERE)) {
213: getLogger()
214: .log(
215: getLogRecord(
216: Level.SEVERE,
217: "PSDT_CSPDMF0001",
218: new Object[] { e
219: .getLocalizedMessage() },
220: e));
221: }
222: }
223: }
224: }
|