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