Source Code Cross Referenced for ServiceAssemblyStatisticsData.java in  » ESB » open-esb » com » sun » esb » management » common » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.esb.management.common.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * @(#)ServiceAssemblyStatisticsData.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 java.io.Serializable;
032:        import java.util.ArrayList;
033:        import java.util.Collection;
034:        import java.util.Date;
035:        import java.util.HashMap;
036:        import java.util.Iterator;
037:        import java.util.List;
038:        import java.util.Map;
039:
040:        import javax.management.openmbean.CompositeData;
041:        import javax.management.openmbean.CompositeType;
042:        import javax.management.openmbean.TabularData;
043:        import javax.xml.parsers.ParserConfigurationException;
044:        import javax.xml.transform.TransformerException;
045:
046:        import com.sun.esb.management.common.ManagementRemoteException;
047:        import com.sun.esb.management.common.data.helper.ServiceAssemblyStatisticsDataCreator;
048:        import com.sun.esb.management.common.data.helper.ServiceAssemblyStatisticsDataWriter;
049:
050:        /**
051:         * Provides Service Assembly Statistics
052:         * 
053:         * @author graj
054:         * 
055:         */
056:        public class ServiceAssemblyStatisticsData implements  Serializable {
057:            static final long serialVersionUID = -1L;
058:
059:            public static final String INSTANCE_NAME_KEY = "InstanceName";
060:
061:            public static final String NAME_KEY = "ServiceAssemblyName";
062:
063:            public static final String LAST_STARTUP_TIME_KEY = "LastStartupTime";
064:
065:            public static final String STARTUP_TIME_AVG_KEY = "StartupTime Avg (ms)";
066:
067:            public static final String STOP_TIME_AVG_KEY = "StopTime Avg (ms)";
068:
069:            public static final String SHUTDOWN_TIME_AVG_KEY = "ShutdownTime Avg (ms)";
070:
071:            public static final String UP_TIME_KEY = "UpTime (ms)";
072:
073:            public static final String SERVICE_UNIT_STATISTICS_KEY = "ServiceUnitStatistics";
074:
075:            String instanceName;
076:
077:            String name;
078:
079:            Date lastStartupTime;
080:
081:            long startupTimeAverage;
082:
083:            long stopTimeAverage;
084:
085:            long shutdownTimeAverage;
086:
087:            long upTime;
088:
089:            List<ServiceUnitStatisticsData> serviceUnitStatisticsList = new ArrayList<ServiceUnitStatisticsData>();
090:
091:            /** Constructor - creates a ServiceAssemblyStatisticsData object */
092:            public ServiceAssemblyStatisticsData() {
093:            }
094:
095:            /**
096:             * Generate Tabular Data for this object
097:             * 
098:             * @param map
099:             * @return tabular data of this object
100:             */
101:            static public TabularData generateTabularData(
102:                    Map<String /* instanceName */, ServiceAssemblyStatisticsData> map) {
103:                TabularData tabularData = null;
104:                try {
105:                    tabularData = ServiceAssemblyStatisticsDataCreator
106:                            .createTabularData(map);
107:                } catch (ManagementRemoteException e) {
108:                }
109:                return tabularData;
110:            }
111:
112:            /**
113:             * Retrieves the Service Assembly Statistics Data
114:             * 
115:             * @param tabularData
116:             * @return Service Assembly Statistics Data
117:             */
118:            @SuppressWarnings("unchecked")
119:            static public Map<String /* instanceName */, ServiceAssemblyStatisticsData> retrieveDataMap(
120:                    TabularData tabularData) {
121:                ServiceAssemblyStatisticsData data = null;
122:                Map<String /* instanceName */, ServiceAssemblyStatisticsData> map = null;
123:                map = new HashMap<String /* instanceName */, ServiceAssemblyStatisticsData>();
124:                for (Iterator dataIterator = tabularData.values().iterator(); dataIterator
125:                        .hasNext();) {
126:                    CompositeData compositeData = (CompositeData) dataIterator
127:                            .next();
128:                    CompositeType compositeType = compositeData
129:                            .getCompositeType();
130:                    data = new ServiceAssemblyStatisticsData();
131:                    for (Iterator<String> itemIterator = compositeType.keySet()
132:                            .iterator(); itemIterator.hasNext();) {
133:                        String item = (String) itemIterator.next();
134:                        if (true == item
135:                                .equals(ServiceAssemblyStatisticsData.INSTANCE_NAME_KEY)) {
136:                            String value = (String) compositeData.get(item);
137:                            data.setInstanceName(value);
138:                        }
139:                        if (true == item
140:                                .equals(ServiceAssemblyStatisticsData.LAST_STARTUP_TIME_KEY)) {
141:                            Date value = (Date) compositeData.get(item);
142:                            data.setLastStartupTime(value);
143:                        }
144:                        if (true == item
145:                                .equals(ServiceAssemblyStatisticsData.NAME_KEY)) {
146:                            String value = (String) compositeData.get(item);
147:                            data.setName(value);
148:                        }
149:                        if (true == item
150:                                .equals(ServiceAssemblyStatisticsData.SHUTDOWN_TIME_AVG_KEY)) {
151:                            Long value = (Long) compositeData.get(item);
152:                            data.setShutdownTimeAverage(value.longValue());
153:                        }
154:                        if (true == item
155:                                .equals(ServiceAssemblyStatisticsData.STARTUP_TIME_AVG_KEY)) {
156:                            Long value = (Long) compositeData.get(item);
157:                            if (data != null) {
158:                                data.setStartupTimeAverage(value.longValue());
159:                            }
160:                        }
161:                        if (true == item
162:                                .equals(ServiceAssemblyStatisticsData.STOP_TIME_AVG_KEY)) {
163:                            Long value = (Long) compositeData.get(item);
164:                            if (data != null) {
165:                                data.setStopTimeAverage(value.longValue());
166:                            }
167:                        }
168:                        if (true == item
169:                                .equals(ServiceAssemblyStatisticsData.UP_TIME_KEY)) {
170:                            Long value = (Long) compositeData.get(item);
171:                            if (data != null) {
172:                                data.setUpTime(value.longValue());
173:                            }
174:                        }
175:                        if (true == item
176:                                .equals(ServiceAssemblyStatisticsData.SERVICE_UNIT_STATISTICS_KEY)) {
177:                            CompositeData[] values = (CompositeData[]) compositeData
178:                                    .get(item);
179:                            if (values != null) {
180:                                ServiceUnitStatisticsData unit = null;
181:                                // Retrieve Service Unit data
182:                                for (CompositeData value : values) {
183:                                    CompositeType valueType = value
184:                                            .getCompositeType();
185:                                    unit = new ServiceUnitStatisticsData();
186:                                    for (Iterator<String> valueIterator = valueType
187:                                            .keySet().iterator(); valueIterator
188:                                            .hasNext();) {
189:                                        String key = (String) valueIterator
190:                                                .next();
191:                                        if (true == key
192:                                                .equals(ServiceUnitStatisticsData.ENDPOINTS_KEY)) {
193:                                            String[] datum = (String[]) value
194:                                                    .get(key);
195:                                            unit.setEndpointNameList(datum);
196:                                        }
197:                                        if (true == key
198:                                                .equals(ServiceUnitStatisticsData.NAME_KEY)) {
199:                                            String datum = (String) value
200:                                                    .get(key);
201:                                            unit.setName(datum);
202:                                        }
203:                                        if (true == key
204:                                                .equals(ServiceUnitStatisticsData.SHUTDOWN_TIME_AVG_KEY)) {
205:                                            Long datum = (Long) value.get(key);
206:                                            unit.setShutdownTimeAverage(datum
207:                                                    .longValue());
208:                                        }
209:                                        if (true == key
210:                                                .equals(ServiceUnitStatisticsData.STARTUP_TIME_AVG_KEY)) {
211:                                            Long datum = (Long) value.get(key);
212:                                            unit.setStartupTimeAverage(datum
213:                                                    .longValue());
214:                                        }
215:                                        if (true == key
216:                                                .equals(ServiceUnitStatisticsData.STOP_TIME_AVG_KEY)) {
217:                                            Long datum = (Long) value.get(key);
218:                                            unit.setStopTimeAverage(datum
219:                                                    .longValue());
220:                                        }
221:                                    }
222:                                    data.getServiceUnitStatisticsList().add(
223:                                            unit);
224:                                }
225:                            }
226:                        }
227:                    }
228:                    map.put(data.getInstanceName(), data);
229:                }
230:                return map;
231:            }
232:
233:            /**
234:             * Converts a Service Assembly Statistics Data to an XML String
235:             * 
236:             * @param map
237:             * @return XML string representing a Service Assembly Statistics Datum
238:             * @throws ManagementRemoteException
239:             */
240:            static public String convertDataMapToXML(
241:                    Map<String /* instanceName */, ServiceAssemblyStatisticsData> map)
242:                    throws ManagementRemoteException {
243:                String xmlText = null;
244:                try {
245:                    xmlText = ServiceAssemblyStatisticsDataWriter
246:                            .serialize(map);
247:                } catch (ParserConfigurationException e) {
248:                    throw new ManagementRemoteException(e);
249:                } catch (TransformerException e) {
250:                    throw new ManagementRemoteException(e);
251:                }
252:                return xmlText;
253:            }
254:
255:            /**
256:             * @return the instanceName
257:             */
258:            public String getInstanceName() {
259:                return this .instanceName;
260:            }
261:
262:            /**
263:             * @param instanceName
264:             *            the instanceName to set
265:             */
266:            public void setInstanceName(String instanceName) {
267:                this .instanceName = instanceName;
268:            }
269:
270:            /**
271:             * @return the lastStartupTime
272:             */
273:            public Date getLastStartupTime() {
274:                return this .lastStartupTime;
275:            }
276:
277:            /**
278:             * @param lastStartupTime
279:             *            the lastStartupTime to set
280:             */
281:            public void setLastStartupTime(Date lastStartupTime) {
282:                this .lastStartupTime = lastStartupTime;
283:            }
284:
285:            /**
286:             * @return the upTime
287:             */
288:            public long getUpTime() {
289:                return this .upTime;
290:            }
291:
292:            /**
293:             * @param upTime the upTime to set
294:             */
295:            public void setUpTime(long upTime) {
296:                this .upTime = upTime;
297:            }
298:
299:            /**
300:             * @return the serviceAssemblyName
301:             */
302:            public String getName() {
303:                return this .name;
304:            }
305:
306:            /**
307:             * @param serviceAssemblyName
308:             *            the serviceAssemblyName to set
309:             */
310:            public void setName(String serviceAssemblyName) {
311:                this .name = serviceAssemblyName;
312:            }
313:
314:            /**
315:             * @return the startupTimeAverage
316:             */
317:            public double getStartupTimeAverage() {
318:                return this .startupTimeAverage;
319:            }
320:
321:            /**
322:             * @param startupTimeAverage
323:             *            the startupTimeAverage to set
324:             */
325:            public void setStartupTimeAverage(long serviceAssemblyStartTime) {
326:                this .startupTimeAverage = serviceAssemblyStartTime;
327:            }
328:
329:            /**
330:             * @return the stopTimeAverage
331:             */
332:            public double getStopTimeAverage() {
333:                return this .stopTimeAverage;
334:            }
335:
336:            /**
337:             * @param stopTimeAverage
338:             *            the stopTimeAverage to set
339:             */
340:            public void setStopTimeAverage(long serviceAssemblyStopTime) {
341:                this .stopTimeAverage = serviceAssemblyStopTime;
342:            }
343:
344:            /**
345:             * @return the shutdownTimeAverage
346:             */
347:            public double getShutdownTimeAverage() {
348:                return this .shutdownTimeAverage;
349:            }
350:
351:            /**
352:             * @param shutdownTimeAverage
353:             *            the shutdownTimeAverage to set
354:             */
355:            public void setShutdownTimeAverage(long serviceAssemblyShutdownTime) {
356:                this .shutdownTimeAverage = serviceAssemblyShutdownTime;
357:            }
358:
359:            /**
360:             * @return the serviceUnitStatisticsList
361:             */
362:            public List<ServiceUnitStatisticsData> getServiceUnitStatisticsList() {
363:                return this .serviceUnitStatisticsList;
364:            }
365:
366:            /**
367:             * @return the serviceUnitStatisticsArray
368:             */
369:            public ServiceUnitStatisticsData[] getServiceUnitStatisticsArray() {
370:                ServiceUnitStatisticsData[] result = null;
371:                result = toArray(this .serviceUnitStatisticsList,
372:                        ServiceUnitStatisticsData.class);
373:                return result;
374:
375:            }
376:
377:            /**
378:             * @param serviceUnitStatisticsList
379:             *            the serviceUnitStatisticsList to set
380:             */
381:            public void setServiceUnitStatisticsList(
382:                    List<ServiceUnitStatisticsData> serviceUnitStatisticsList) {
383:                this .serviceUnitStatisticsList = serviceUnitStatisticsList;
384:            }
385:
386:            /**
387:             * @param serviceUnitStatisticsArray
388:             *            the serviceUnitStatisticsArray to set
389:             */
390:            public void setServiceUnitStatisticsList(
391:                    ServiceUnitStatisticsData[] serviceUnitStatisticsArray) {
392:                for (ServiceUnitStatisticsData unitData : serviceUnitStatisticsArray) {
393:                    this .serviceUnitStatisticsList.add(unitData);
394:                }
395:            }
396:
397:            /**
398:             * Convert a collection to an array
399:             * 
400:             * @param collection
401:             * @param componentType
402:             * @return
403:             */
404:            @SuppressWarnings("unchecked")
405:            static protected <Type> Type[] toArray(Collection<Type> collection,
406:                    Class<Type> componentType) {
407:                // unchecked cast
408:                Type[] array = (Type[]) java.lang.reflect.Array.newInstance(
409:                        componentType, collection.size());
410:                int index = 0;
411:                for (Type value : collection) {
412:                    array[index++] = value;
413:                }
414:                return array;
415:            }
416:
417:            /**
418:             * 
419:             * @return
420:             */
421:            public String getDisplayString() {
422:                StringBuffer buffer = new StringBuffer();
423:                buffer.append("\n  Instance Name" + "="
424:                        + this .getInstanceName());
425:                buffer.append("\n  Service Assembly Name" + "="
426:                        + this .getName());
427:                buffer.append("\n  Service Assembly Last Startup Time" + "="
428:                        + this .getLastStartupTime());
429:                buffer.append("\n  Service Assembly Shutdown Time Average"
430:                        + "=" + this .getShutdownTimeAverage());
431:                buffer.append("\n  Service Assembly Start Time Average" + "="
432:                        + this .getStartupTimeAverage());
433:                buffer.append("\n  Service Assembly Stop Time Average" + "="
434:                        + this .getStopTimeAverage());
435:                buffer.append("\n  Service Assembly Up Time" + "="
436:                        + this .getUpTime());
437:                if ((this .getServiceUnitStatisticsList() != null)
438:                        && (this .getServiceUnitStatisticsList().size() > 0)) {
439:                    buffer.append("\n  Service Unit Statistics List:");
440:                    for (ServiceUnitStatisticsData data : this 
441:                            .getServiceUnitStatisticsList()) {
442:                        buffer.append(data.getDisplayString());
443:                    }
444:                }
445:                buffer.append("\n  ========================================\n");
446:                return buffer.toString();
447:
448:            }
449:
450:            /**
451:             * @param args
452:             */
453:            public static void main(String[] args) {
454:                // TODO Auto-generated method stub
455:
456:            }
457:
458:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.