Source Code Cross Referenced for StatisticWrapper.java in  » Portal » Open-Portal » com » sun » portal » monitoring » statistics » 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 » Portal » Open Portal » com.sun.portal.monitoring.statistics 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.monitoring.statistics;
006:
007:        import com.sun.portal.monitoring.*;
008:        import com.sun.portal.log.common.PortalLogger;
009:
010:        import javax.management.*;
011:        import javax.management.openmbean.*;
012:        import java.util.*;
013:        import java.util.logging.Logger;
014:        import java.util.logging.LogRecord;
015:        import java.util.logging.Level;
016:
017:        public class StatisticWrapper implements  ResourceBundleWrapper,
018:                CompositeDataWrapper, TabularDataWrapper, MBeanInfoWrapper {
019:            private static final Logger logger = PortalLogger
020:                    .getLogger(StatisticWrapper.class);
021:
022:            private static LogRecord getLogRecord(Level level, String message,
023:                    Object[] parameters, Throwable t) {
024:                LogRecord result = new LogRecord(level, message);
025:                result.setLoggerName(logger.getName());
026:                result.setParameters(parameters);
027:                result.setThrown(t);
028:                return result;
029:            }
030:
031:            public String getResourceBundleBaseName() {
032:                return resourceBundleBaseName;
033:            }
034:
035:            public void setResourceBundleBaseName(String resourceBundleBaseName) {
036:                this .resourceBundleBaseName = resourceBundleBaseName;
037:            }
038:
039:            public Locale getLocale() {
040:                return locale;
041:            }
042:
043:            public void setLocale(Locale locale) {
044:                this .locale = locale;
045:            }
046:
047:            private String resourceBundleBaseName;
048:            private Locale locale;
049:
050:            private ResourceBundle getResourceBundle() {
051:                if (resourceBundle == null) {
052:                    resourceBundle = ResourceBundleHelper
053:                            .getResourceBundle(this );
054:                }
055:
056:                return resourceBundle;
057:            }
058:
059:            private ResourceBundle resourceBundle;
060:
061:            public String getCompositeTypeName() {
062:                if (compositeTypeName != null) {
063:                    return compositeTypeName;
064:                }
065:
066:                return getClass().getName();
067:            }
068:
069:            public void setCompositeTypeName(String compositeTypeName) {
070:                this .compositeTypeName = compositeTypeName;
071:            }
072:
073:            public String getCompositeTypeDescription() {
074:                try {
075:                    ResourceBundle resourceBundle = getResourceBundle();
076:                    if (resourceBundle != null) {
077:                        return resourceBundle.getString(getCompositeTypeName()
078:                                + "." + COMPOSITE_TYPE_DESCRIPTION);
079:                    }
080:
081:                    return COMPOSITE_TYPE_DESCRIPTION;
082:                } catch (MissingResourceException e) {
083:                    if (logger.isLoggable(Level.CONFIG)) {
084:                        logger.log(getLogRecord(Level.CONFIG, "PSMN_CSPM0001",
085:                                new Object[] { e.getLocalizedMessage() }, e));
086:                    }
087:                    return COMPOSITE_TYPE_DESCRIPTION;
088:                }
089:            }
090:
091:            public String[] getItemNames() {
092:                return new String[] { "Description", "LastSampleTime", "Name",
093:                        "StartTime", "Unit" };
094:            }
095:
096:            public String[] getItemDescriptions() {
097:                return new String[] { "DescriptionDescription",
098:                        "LastSampleTimeDescription", "NameDescription",
099:                        "StartTimeDescription", "UnitDescription" };
100:            }
101:
102:            public OpenType[] getItemTypes() {
103:                return new OpenType[] { SimpleType.STRING, SimpleType.LONG,
104:                        SimpleType.STRING, SimpleType.LONG, SimpleType.STRING };
105:            }
106:
107:            public StatisticImpl getStatisticImpl() {
108:                if (statisticImpl == null) {
109:                    statisticImpl = new StatisticImpl();
110:                }
111:
112:                return statisticImpl;
113:            }
114:
115:            public void setStatisticImpl(StatisticImpl statisticImpl) {
116:                this .statisticImpl = statisticImpl;
117:            }
118:
119:            protected StatisticImpl statisticImpl;
120:
121:            public Object[] getItemValues() {
122:                StatisticImpl statistic = getStatisticImpl();
123:
124:                return new Object[] { statistic.getDescription(),
125:                        new Long(statistic.getLastSampleTime()),
126:                        statistic.getName(),
127:                        new Long(statistic.getStartTime()), statistic.getUnit() };
128:            }
129:
130:            public void setItemValues(CompositeData compositeData) {
131:                Object[] values = compositeData.getAll(getItemNames());
132:                StatisticImpl statistic = getStatisticImpl();
133:
134:                statistic.setDescription((String) values[0]);
135:                statistic.setLastSampleTime(((Long) values[1]).longValue());
136:                statistic.setName((String) values[2]);
137:                statistic.setStartTime(((Long) values[3]).longValue());
138:                statistic.setUnit((String) values[4]);
139:            }
140:
141:            public CompositeType getCompositeType() throws OpenDataException {
142:                if (compositeType == null) {
143:                    String[] itemNames = getItemNames();
144:                    String[] itemDescriptions = getItemDescriptions();
145:                    OpenType[] itemTypes = getItemTypes();
146:
147:                    ResourceBundle resourceBundle = getResourceBundle();
148:                    if (resourceBundle != null) {
149:                        for (int i = 0; i < itemDescriptions.length; i++) {
150:                            try {
151:                                itemDescriptions[i] = resourceBundle
152:                                        .getString(getCompositeTypeName() + "."
153:                                                + itemDescriptions[i]);
154:                            } catch (MissingResourceException e) {
155:                                if (logger.isLoggable(Level.CONFIG)) {
156:                                    logger
157:                                            .log(getLogRecord(
158:                                                    Level.CONFIG,
159:                                                    "PSMN_CSPM0001",
160:                                                    new Object[] { e
161:                                                            .getLocalizedMessage() },
162:                                                    e));
163:                                }
164:                            }
165:                        }
166:                    }
167:
168:                    compositeType = new CompositeType(getCompositeTypeName(),
169:                            getCompositeTypeDescription(), itemNames,
170:                            itemDescriptions, itemTypes);
171:                }
172:
173:                return compositeType;
174:            }
175:
176:            public CompositeData toCompositeData() throws OpenDataException {
177:                return new CompositeDataSupport(getCompositeType(),
178:                        getItemNames(), getItemValues());
179:            }
180:
181:            public void fromCompositeData(CompositeData compositeData)
182:                    throws OpenDataException {
183:                if (!getCompositeType()
184:                        .equals(compositeData.getCompositeType())) {
185:                    throw new InvalidOpenTypeException(
186:                            "CompositeType mismatch: supports <"
187:                                    + getCompositeType().getTypeName()
188:                                    + "> and received <"
189:                                    + compositeData.getCompositeType()
190:                                            .getTypeName() + ">");
191:                }
192:
193:                setItemValues(compositeData);
194:            }
195:
196:            private CompositeType compositeType;
197:            private String compositeTypeName;
198:            private static final String COMPOSITE_TYPE_DESCRIPTION = "CompositeTypeDescription";
199:
200:            public String getTabularTypeName() {
201:                return tabularTypeName;
202:            }
203:
204:            public void setTabularTypeName(String tabularTypeName) {
205:                this .tabularTypeName = tabularTypeName;
206:            }
207:
208:            public String getTabularTypeDescription() {
209:                return tabularTypeDescription;
210:            }
211:
212:            public void setTabularTypeDescription(String tabularTypeDescription) {
213:                this .tabularTypeDescription = tabularTypeDescription;
214:            }
215:
216:            public String[] getIndexNames() {
217:                return new String[] { "Name" };
218:            }
219:
220:            public TabularType getTabularType() throws OpenDataException {
221:                if (tabularType == null) {
222:                    tabularTypeName = (tabularTypeName == null) ? getClass()
223:                            .getName() : tabularTypeName;
224:
225:                    ResourceBundle resourceBundle = ResourceBundleHelper
226:                            .getResourceBundle(this );
227:                    if (resourceBundle != null) {
228:                        try {
229:                            tabularTypeDescription = resourceBundle
230:                                    .getString(tabularTypeName + "."
231:                                            + tabularTypeDescription);
232:                        } catch (MissingResourceException e) {
233:                            if (logger.isLoggable(Level.CONFIG)) {
234:                                logger.log(getLogRecord(Level.CONFIG,
235:                                        "PSMN_CSPM0001", new Object[] { e
236:                                                .getLocalizedMessage() }, e));
237:                            }
238:                        }
239:                    }
240:
241:                    tabularType = new TabularType(tabularTypeName,
242:                            tabularTypeDescription, getCompositeType(),
243:                            getIndexNames());
244:                }
245:
246:                return tabularType;
247:            }
248:
249:            public TabularData toTabularData() throws OpenDataException {
250:                if (tabularData == null) {
251:                    tabularData = new TabularDataSupport(getTabularType());
252:                    tabularData.put(toCompositeData());
253:                }
254:
255:                return tabularData;
256:            }
257:
258:            public void fromTabularData(TabularData tabularData)
259:                    throws OpenDataException {
260:                if (getTabularType().getRowType() != tabularData
261:                        .getTabularType().getRowType()) {
262:                    throw new InvalidOpenTypeException(
263:                            "TabularType mismatch: supports <"
264:                                    + getTabularType().getRowType()
265:                                            .getTypeName()
266:                                    + "> and received <"
267:                                    + tabularData.getTabularType().getRowType()
268:                                            .getTypeName() + ">");
269:                }
270:
271:                this .tabularData = tabularData;
272:            }
273:
274:            private String tabularTypeName;
275:            private String tabularTypeDescription = "TabularTypeDescription";
276:            private TabularType tabularType;
277:            private TabularData tabularData;
278:
279:            public Map getMBeanAttributeInfo() throws OpenDataException {
280:                Set itemNames = getCompositeType().keySet();
281:                Map result = new HashMap(itemNames.size());
282:                for (Iterator iterator = itemNames.iterator(); iterator
283:                        .hasNext();) {
284:                    String itemName = (String) iterator.next();
285:                    MBeanAttributeInfo mBeanAttributeInfo = new OpenMBeanAttributeInfoSupport(
286:                            itemName, getCompositeType().getDescription(
287:                                    itemName), getCompositeType().getType(
288:                                    itemName), true, false, false);
289:                    result.put(itemName, mBeanAttributeInfo);
290:                }
291:
292:                return result;
293:            }
294:
295:            public MBeanConstructorInfo[] getMBeanConstructorInfo() {
296:                return new MBeanConstructorInfo[0];
297:            }
298:
299:            public Map getMBeanOperationInfo() {
300:                Map result = new HashMap(1);
301:
302:                ResourceBundle resourceBundle = ResourceBundleHelper
303:                        .getResourceBundle(this );
304:                if (resourceBundle != null) {
305:                    try {
306:                        resetDescription = resourceBundle
307:                                .getString(getCompositeTypeName() + "."
308:                                        + resetDescription);
309:                    } catch (MissingResourceException e) {
310:                        if (logger.isLoggable(Level.CONFIG)) {
311:                            logger.log(getLogRecord(Level.CONFIG,
312:                                    "PSMN_CSPM0001", new Object[] { e
313:                                            .getLocalizedMessage() }, e));
314:                        }
315:                    }
316:                }
317:
318:                MBeanOperationInfo mBeanOperationInfo = new MBeanOperationInfo(
319:                        "reset", resetDescription, null, "void",
320:                        MBeanOperationInfo.ACTION);
321:                result.put("reset", mBeanOperationInfo);
322:
323:                return result;
324:            }
325:
326:            public Map getMBeanNotificationInfo() {
327:                Map result = new HashMap();
328:                return result;
329:            }
330:
331:            public MBeanInfo getMBeanInfo() throws OpenDataException {
332:                if (mBeanInfo == null) {
333:                    Collection attributeInfos = getMBeanAttributeInfo()
334:                            .values();
335:                    MBeanAttributeInfo[] mBeanAttributeInfos = (MBeanAttributeInfo[]) attributeInfos
336:                            .toArray(new MBeanAttributeInfo[attributeInfos
337:                                    .size()]);
338:
339:                    Collection operationInfos = getMBeanOperationInfo()
340:                            .values();
341:                    MBeanOperationInfo[] mBeanOperationInfos = (MBeanOperationInfo[]) operationInfos
342:                            .toArray(new MBeanOperationInfo[operationInfos
343:                                    .size()]);
344:
345:                    Collection notificationInfos = getMBeanNotificationInfo()
346:                            .values();
347:                    MBeanNotificationInfo[] mBeanNotificationInfos = (MBeanNotificationInfo[]) notificationInfos
348:                            .toArray(new MBeanNotificationInfo[notificationInfos
349:                                    .size()]);
350:
351:                    mBeanInfo = new MBeanInfo(getCompositeType().getTypeName(),
352:                            getCompositeType().getDescription(),
353:                            mBeanAttributeInfos, getMBeanConstructorInfo(),
354:                            mBeanOperationInfos, mBeanNotificationInfos);
355:                }
356:
357:                return mBeanInfo;
358:            }
359:
360:            public void setMBeanInfo(MBeanInfo mBeanInfo) {
361:                this .mBeanInfo = mBeanInfo;
362:            }
363:
364:            private String resetDescription = "resetDescription";
365:            protected MBeanInfo mBeanInfo;
366:
367:            public void reset() {
368:                getStatisticImpl().reset();
369:            }
370:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.