001: // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
002: /*
003: * ComponentMessageHolder.java
004: *
005: * SUN PROPRIETARY/CONFIDENTIAL.
006: * This software is the proprietary information of Sun Microsystems, Inc.
007: * Use is subject to license terms.
008: *
009: */
010: package com.sun.jbi.common.management;
011:
012: import java.util.HashMap;
013:
014: /**
015: * This provides necessary methods for the components to pass the task result data to
016: * ManagemntMessageBuilder. ManagementMessageBuilder constructs an XML document based on
017: * this.
018: *
019: * @author Sun Microsystems, Inc.
020: */
021: public class ComponentMessageHolder {
022: /**
023: * Type of message to build. Currently it can either be 'Status' or 'Exception'
024: */
025: private String mMsgTypeToBuild = null;
026:
027: /**
028: * Cache for Localized Tokens
029: */
030: private HashMap mLocTokenCache = new HashMap();
031:
032: /**
033: * Cache for Localized Tokens
034: */
035: private HashMap mLocMessageCache = new HashMap();
036:
037: /**
038: * Cache for Localized Tokens
039: */
040: private HashMap mLocParamCache = new HashMap();
041:
042: /**
043: * Exception Object
044: */
045: private Throwable mExceptionObject = null;
046:
047: /**
048: * task name
049: */
050: private String mTaskName = null;
051:
052: /**
053: * task result
054: */
055: private String mTaskResult = null;
056:
057: /**
058: * status message type
059: */
060: private String mStatusMsgType = null;
061:
062: /**
063: * exception message type
064: */
065: private String mExceptionMsgType = null;
066:
067: /**
068: * component name
069: */
070: private String mComponentName = null;
071:
072: /**
073: * Creates a new instance of MessageContentHolder with a message type.
074: *
075: * @param msgType String describing the message type to build.
076: */
077: public ComponentMessageHolder(String msgType) {
078: mMsgTypeToBuild = msgType;
079: }
080:
081: /**
082: * Set the name of the task executed by component.
083: *
084: * @param taskName - task executed by component.
085: */
086: public void setTaskName(String taskName) {
087: mTaskName = taskName;
088: }
089:
090: /**
091: * Set the name of the component that executed the task.
092: *
093: * @param name - Name of the component.
094: */
095: public void setComponentName(String name) {
096: mComponentName = name;
097: }
098:
099: /**
100: * Set the result of the task executed by component.
101: *
102: * @param taskResult - result of task executed by component.
103: */
104: public void setTaskResult(String taskResult) {
105: mTaskResult = taskResult;
106: }
107:
108: /**
109: * Set the exception object.
110: *
111: * @param exObj - exception object.
112: */
113: public void setExceptionObject(Throwable exObj) {
114: mExceptionObject = exObj;
115: }
116:
117: /**
118: * Set the message type being returned by the component.
119: *
120: * @param statMsgType - type of success message that is being returned by the
121: * component.
122: */
123: public void setStatusMessageType(String statMsgType) {
124: mStatusMsgType = statMsgType;
125: }
126:
127: /**
128: * Set the exception message type being returned by the component.
129: *
130: * @param exMsgType - type of exception message that is being returned by the
131: * component.
132: */
133: public void setExceptionMessageType(String exMsgType) {
134: mExceptionMsgType = exMsgType;
135: }
136:
137: /**
138: * Set the message token for the exception being thrown by the component.
139: *
140: * @param nestingLevel - nesting level of the exception
141: * @param locToken - message token.
142: */
143: public void setLocToken(int nestingLevel, String locToken) {
144: mLocTokenCache.put(String.valueOf(nestingLevel), locToken);
145: }
146:
147: /**
148: * Set the message for the exception being thrown by the component.
149: *
150: * @param nestingLevel - nesting level of the exception.
151: * @param locMessage - exception message.
152: */
153: public void setLocMessage(int nestingLevel, String locMessage) {
154: mLocMessageCache.put(String.valueOf(nestingLevel), locMessage);
155: }
156:
157: /**
158: * Set the message parameters for the exception being thrown by the component.
159: *
160: * @param nestingLevel - nesting level of the exception.
161: * @param locParam - exception message parameters.
162: */
163: public void setLocParam(int nestingLevel, String[] locParam) {
164: mLocParamCache.put(String.valueOf(nestingLevel), locParam);
165: }
166:
167: /**
168: * Returns the message token.
169: *
170: * @param nestingLevel nesting level of the exception.
171: *
172: * @return message token at the given nesting level.
173: */
174: public String getLocToken(int nestingLevel) {
175: return (String) mLocTokenCache
176: .get(String.valueOf(nestingLevel));
177: }
178:
179: /**
180: * Returns the exception message.
181: *
182: * @param nestingLevel nesting level of the exception
183: *
184: * @return exception message at the given nesting level
185: */
186: public String getLocMessage(int nestingLevel) {
187: return (String) mLocMessageCache.get(String
188: .valueOf(nestingLevel));
189: }
190:
191: /**
192: * Returns the exception message parameters.
193: *
194: * @param nestingLevel nesting level of the exception.
195: *
196: * @return exception message parameters at the given nesting level.
197: */
198: public String[] getLocParam(int nestingLevel) {
199: return (String[]) mLocParamCache.get(String
200: .valueOf(nestingLevel));
201: }
202:
203: /**
204: * Get the exception object being thrown by this component.
205: *
206: * @return Exception Object.
207: */
208: public Throwable getExceptionObject() {
209: return mExceptionObject;
210: }
211:
212: /**
213: * Get the name of the task executed by this component.
214: *
215: * @return Task name.
216: */
217: public String getTaskName() {
218: return mTaskName;
219: }
220:
221: /**
222: * Get the result of the task executed by this component.
223: *
224: * @return Task Result.
225: */
226: public String getTaskResult() {
227: return mTaskResult;
228: }
229:
230: /**
231: * Get the type(status, exception) of message to be built for this component.
232: *
233: * @return Task Result.
234: */
235: public String getComponentMessageType() {
236: return mMsgTypeToBuild;
237: }
238:
239: /**
240: * Get the status message type being returned by the component.
241: *
242: * @return Status message type.
243: */
244: public String getStatusMessageType() {
245: return mStatusMsgType;
246: }
247:
248: /**
249: * Get the exception message type being returned by the component.
250: *
251: * @return Status message type.
252: */
253: public String getExceptionMessageType() {
254: return mExceptionMsgType;
255: }
256:
257: /**
258: * Return the name of the component.
259: *
260: * @return component name.
261: */
262: public String getComponentName() {
263: return mComponentName;
264: }
265: }
|