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