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: * @(#)JavaEEVerifierReport.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.esb.management.common.data;
030:
031: import javax.management.openmbean.TabularData;
032: import javax.management.openmbean.CompositeData;
033: import javax.management.openmbean.TabularType;
034: import javax.management.openmbean.CompositeType;
035: import javax.management.openmbean.SimpleType;
036: import javax.management.openmbean.OpenType;
037: import javax.management.openmbean.CompositeDataSupport;
038: import javax.management.openmbean.TabularDataSupport;
039: import javax.management.openmbean.OpenDataException;
040: import java.io.Serializable;
041: import java.util.ArrayList;
042: import java.util.Iterator;
043: import java.util.Set;
044:
045: /**
046: * This class holds information about JavaEEVerificationReport
047: * for a single service unit
048: */
049: public class JavaEEVerifierReport implements Serializable {
050: static final long serialVersionUID = -1L;
051:
052: String serviceUnitName;
053:
054: ArrayList<JavaEEReportItem> reportTable = new ArrayList<JavaEEReportItem>();
055:
056: /**
057: * Constructor
058: */
059: public JavaEEVerifierReport() {
060: }
061:
062: /**
063: * get the service unit name
064: * @return the serviceunit name
065: */
066: public String getServiceUnitName() {
067: return this .serviceUnitName;
068: }
069:
070: /**
071: * set the service unit name
072: * @param serviceUnitName
073: * the serviceUnitName to set
074: */
075: public void setServiceUnitName(String serviceUnitName) {
076: this .serviceUnitName = serviceUnitName;
077: }
078:
079: /**
080: * get the verifier report for this service unit
081: * @return the serviceUnitName
082: */
083: public ArrayList getJavaEEVerifierReport() {
084: return this .reportTable;
085: }
086:
087: /**
088: * set the verifier report for this service unit
089: * @return the serviceUnitName
090: */
091: public void setJavaEEVerifierReport(TabularData javaEEReportTable) {
092:
093: if (javaEEReportTable != null) {
094:
095: for (Iterator dataIterator = javaEEReportTable.values()
096: .iterator(); dataIterator.hasNext();) {
097: CompositeData cdata = (CompositeData) dataIterator
098: .next();
099: JavaEEReportItem reportItem = new JavaEEReportItem();
100: reportItem.setEarFileName((String) cdata
101: .get("Ear Filename"));
102: reportItem.setReferenceBy((String) cdata
103: .get("Referrence By"));
104: reportItem.setReferenceClass((String) cdata
105: .get("Referrence Class"));
106: reportItem.setJndiName((String) cdata.get("JNDI Name"));
107: reportItem.setJndiClass((String) cdata
108: .get("JNDI Class Type"));
109: reportItem.setMessage((String) cdata.get("Message"));
110: reportItem.setStatus(((Integer) cdata.get("Status"))
111: .intValue());
112: reportTable.add(reportItem);
113: }
114: }
115: }
116:
117: /**
118: * this method is used to set a given row of java ee verifier report
119: * read by the xml reader into this instance of javaee verifier report
120: */
121: public void addJavaEEVerifierReportItem(JavaEEReportItem tableItem) {
122: JavaEEReportItem item = new JavaEEReportItem();
123: item.setEarFileName(tableItem.getEarFileName());
124: item.setReferenceBy(tableItem.getReferenceBy());
125: item.setReferenceClass(tableItem.getReferenceClass());
126: item.setJndiName(tableItem.getJndiName());
127: item.setJndiClass(tableItem.getJndiClass());
128: item.setMessage(tableItem.getMessage());
129: item.setStatus(tableItem.getStatus());
130: reportTable.add(item);
131: }
132:
133: /**
134: * This method returns the CompositeType for the items in
135: * the JavaEEVerifier report table
136: * @return CompositeType the type for each item in the report table
137: */
138: public static CompositeType getReportItemCompositeType()
139: throws OpenDataException {
140: return new CompositeType("JavaEEVerifierReportItem",
141: "JavaEE Verifier Report Item",
142: JAVAEE_VERIFIER_ITEM_NAMES,
143: JAVAEE_VERIFIER_ITEM_DESCRIPTIONS,
144: JAVAEE_VERIFIER_ITEM_TYPES);
145: }
146:
147: /**
148: * This method is used to create a composite data to represent this
149: * JavaEEVerifierReport
150: * @return CompositeData representing the data in this instance
151: */
152: public CompositeData getCompositeData() throws OpenDataException {
153: TabularType reportTableType = new TabularType(
154: "JavaEEVerifierTableType",
155: "Java EE Verification Report Table Type",
156: getReportItemCompositeType(),
157: new String[] { "Reference Class", "Reference By",
158: "JNDI Name" });
159:
160: String[] javaEEVerifierReportItemNames = new String[] {
161: "ServiceUnitName", "JavaEEVerifierReport" };
162:
163: String[] javaEEVerifierReportItemDesc = new String[] {
164: "Service Unit Name", "Java EE Verifier Report" };
165:
166: OpenType[] javaEEVerifierReportItemTypes = new OpenType[] {
167: SimpleType.STRING, reportTableType };
168:
169: CompositeType javaEEVerifierReport = new CompositeType(
170: "JavaEEVerifierReport", "Java EE Verifier Report",
171: javaEEVerifierReportItemNames,
172: javaEEVerifierReportItemDesc,
173: javaEEVerifierReportItemTypes);
174:
175: TabularData table = new TabularDataSupport(reportTableType);
176: for (JavaEEReportItem item : reportTable) {
177: table.put(item.getCompositeData());
178: }
179:
180: return new CompositeDataSupport(javaEEVerifierReport,
181: javaEEVerifierReportItemNames, new Object[] {
182: getServiceUnitName(), table });
183:
184: }
185:
186: /**
187: * Return a displayable string of values
188: * @return
189: */
190: public String getDisplayString() {
191: StringBuffer buffer = new StringBuffer();
192: buffer.append("\n Service Unit Name" + "="
193: + this .getServiceUnitName());
194: buffer.append("\n VerifierReport\n");
195: for (JavaEEReportItem item : reportTable) {
196: buffer.append("\n " + item.getDisplayString());
197: }
198: return buffer.toString();
199: }
200:
201: /**
202: * This class holds details about the JavaEEVerifierReport
203: */
204: public class JavaEEReportItem {
205:
206: /**
207: * Ear filename
208: */
209: private String earFileName;
210:
211: /**
212: * reference by
213: */
214: private String referenceBy;
215:
216: /**
217: * reference class
218: */
219: private String referenceClass;
220:
221: /**
222: * jndi name
223: */
224: private String jndiName;
225:
226: /**
227: * jndi class
228: */
229: private String jndiClass;
230:
231: /**
232: * message
233: */
234: private String message;
235:
236: /**
237: * status
238: */
239: private int status;
240:
241: /**
242: * get ear file name
243: * @return String
244: */
245: public String getEarFileName() {
246: return this .earFileName;
247: }
248:
249: /**
250: * set ear file name
251: * @param String
252: */
253: public void setEarFileName(String earFileName) {
254: this .earFileName = earFileName;
255: }
256:
257: /**
258: * get reference by
259: * @return String
260: */
261: public String getReferenceBy() {
262: return this .referenceBy;
263: }
264:
265: /**
266: * set reference by
267: * @param String
268: */
269: public void setReferenceBy(String referenceBy) {
270: this .referenceBy = referenceBy;
271: }
272:
273: /**
274: * get reference class
275: * @return String
276: */
277: public String getReferenceClass() {
278: return this .referenceClass;
279: }
280:
281: /**
282: * set reference class
283: * @param String
284: */
285: public void setReferenceClass(String referenceClass) {
286: this .referenceClass = referenceClass;
287: }
288:
289: /**
290: * get jndi class
291: * @return String
292: */
293: public String getJndiClass() {
294: return this .jndiClass;
295: }
296:
297: /**
298: * set reference class
299: * @param String
300: */
301: public void setJndiClass(String jndiClass) {
302: this .jndiClass = jndiClass;
303: }
304:
305: /**
306: * get jndi name
307: * @return String
308: */
309: public String getJndiName() {
310: return this .jndiName;
311: }
312:
313: /**
314: * set reference class
315: * @param String
316: */
317: public void setJndiName(String jndiName) {
318: this .jndiName = jndiName;
319: }
320:
321: /**
322: * get message
323: * @return String
324: */
325: public String getMessage() {
326: return this .message;
327: }
328:
329: /**
330: * set message
331: * @param String
332: */
333: public void setMessage(String message) {
334: this .message = message;
335: }
336:
337: /**
338: * get status
339: * @return String
340: */
341: public int getStatus() {
342: return this .status;
343: }
344:
345: /**
346: * set status
347: * @param int
348: */
349: public void setStatus(int status) {
350: this .status = status;
351: }
352:
353: /**
354: * get display string
355: */
356: private String getDisplayString() {
357: StringBuffer buffer = new StringBuffer();
358: buffer.append("\n Ear File Name" + "="
359: + this .getEarFileName());
360: buffer.append("\n Reference By" + "="
361: + this .getReferenceBy());
362: buffer.append("\n Reference Class" + "="
363: + this .getReferenceClass());
364: buffer.append("\n Jndi Name" + "=" + this .getJndiName());
365: buffer.append("\n Jndi Class" + "="
366: + this .getJndiClass());
367: buffer.append("\n Message" + "=" + this .getMessage());
368: buffer.append("\n Status" + "=" + this .getStatus());
369: buffer.append("\n");
370: return buffer.toString();
371: }
372:
373: /** This method is used to create a CompositeData with the
374: * given values of a JavaEEReportItem
375: * @retutn CompositeData representing the data in this instance
376: */
377: public CompositeData getCompositeData()
378: throws OpenDataException {
379: return new CompositeDataSupport(
380: getReportItemCompositeType(),
381: JAVAEE_VERIFIER_ITEM_NAMES, new Object[] {
382: getEarFileName(), getReferenceBy(),
383: getReferenceClass(), getJndiName(),
384: getJndiClass(), getMessage(), getStatus() });
385: }
386:
387: } //end of the inner class
388:
389: /**
390: * JavaEE Verifier Item Names
391: */
392:
393: static String[] JAVAEE_VERIFIER_ITEM_NAMES = new String[] {
394: "Ear Filename", "Reference By", "Reference Class",
395: "JNDI Name", "JNDI Class Type", "Message", "Status" };
396:
397: /**
398: * JavaEE Verifier Item Descriptions
399: */
400: static String[] JAVAEE_VERIFIER_ITEM_DESCRIPTIONS = new String[] {
401: "Ear File Name", "Reference By", "Reference Class",
402: "Jndi Name", "Jndi Class", "Message", "Status"
403:
404: };
405:
406: /**
407: * JavaEE Verifier Item Types
408: */
409: static OpenType[] JAVAEE_VERIFIER_ITEM_TYPES = new OpenType[] {
410: SimpleType.STRING, SimpleType.STRING, SimpleType.STRING,
411: SimpleType.STRING, SimpleType.STRING, SimpleType.STRING,
412: SimpleType.INTEGER };
413:
414: }
|