Source Code Cross Referenced for TIJMPController.java in  » Testing » TIJmp » tijmp » 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 » Testing » TIJmp » tijmp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package tijmp;
002:
003:        import java.lang.management.ManagementFactory;
004:        import java.lang.management.MemoryMXBean;
005:        import java.lang.management.MemoryPoolMXBean;
006:        import java.util.ArrayList;
007:        import java.util.Collections;
008:        import java.util.HashMap;
009:        import java.util.List;
010:        import java.util.Map;
011:        import java.util.concurrent.LinkedBlockingQueue;
012:        import tijmp.UIHandler;
013:        import tijmp.ui.InVMUI;
014:
015:        /** This is a class that can be used to control the tijmp profiler from within java code.
016:         */
017:        public class TIJMPController {
018:            private static List<HeapWalkEntry> previousEntries;
019:            private static LinkedBlockingQueue<Runnable> lbq;
020:            private static UIHandler uiHandler;
021:            private static boolean showStrings = false;
022:
023:            static {
024:                System.loadLibrary("tijmp");
025:            }
026:
027:            /** This will run the garbage collector. 
028:             *  According to the specification this type of gc will 
029:             *  actually be guaranteed to run the garbage collector.
030:             */
031:            static native void runGC();
032:
033:            /** Walk the heap and gather object information.
034:             */
035:            static native void walkHeap();
036:
037:            /** Find all entries of a given class and then call back into java to 
038:             *  show them.
039:             */
040:            static native void showInstances(Class<?> clz);
041:
042:            /** Finds all strings and then call back to java to show them.
043:             */
044:            static void showStrings() {
045:                showStrings = true;
046:                showInstances(char[].class);
047:            }
048:
049:            /** Find owners for all objects of the given class and show them.
050:             */
051:            static native void showOwners(Class<?> clz);
052:
053:            /** Find all objects below the given object and show a summary.
054:             */
055:            static native void childObjectsSummary(Object o);
056:
057:            /** Find the objects for a set of tags. 
058:             */
059:            static native Object[] getObjectsForTags(long[] tags);
060:
061:            public static void init() {
062:                lbq = new LinkedBlockingQueue<Runnable>();
063:                Thread runner = new Thread(new EventHandler(lbq));
064:                runner.start();
065:                uiHandler = new InVMUI();
066:                uiHandler.init(new InVMPH());
067:            }
068:
069:            /** Submit a long running task to the tijmp task handler.
070:             */
071:            static void submitTask(Runnable r) {
072:                try {
073:                    lbq.put(r);
074:                } catch (InterruptedException e) {
075:                    e.printStackTrace();
076:                }
077:            }
078:
079:            public static void heapWalkResult(Class<?>[] carr, long[] counts,
080:                    long[] sizes) {
081:                Map<Class<?>, HeapWalkEntry> m = Collections.emptyMap();
082:                if (previousEntries != null) {
083:                    m = new HashMap<Class<?>, HeapWalkEntry>(previousEntries
084:                            .size());
085:                    for (HeapWalkEntry e : previousEntries)
086:                        m.put(e.getEntryClass(), e);
087:                }
088:                final List<HeapWalkEntry> ls = new ArrayList<HeapWalkEntry>(
089:                        carr.length);
090:                for (int i = 0; i < carr.length; i++) {
091:                    // for now we ignore null entries and also no-count entries.
092:                    if (carr[i] != null && counts[i] > 0) {
093:                        HeapWalkEntry pe = m.get(carr[i]);
094:                        long countChange = 0;
095:                        long sizeChange = 0;
096:                        if (pe != null) {
097:                            countChange = counts[i] - pe.getInstanceCount();
098:                            sizeChange = sizes[i] - pe.getTotalSize();
099:                        }
100:                        ls.add(new HeapWalkEntry(carr[i], counts[i],
101:                                countChange, sizes[i], sizeChange));
102:                    }
103:                }
104:                previousEntries = ls;
105:                uiHandler.showHeapWalkResult(ls);
106:            }
107:
108:            public static void instances(Class<?> clz, Object[] objects,
109:                    long[] sizes, int[] lengths) {
110:                if (showStrings)
111:                    uiHandler.strings(objects);
112:                else
113:                    uiHandler.instances(clz, objects, sizes, lengths);
114:                showStrings = false;
115:            }
116:
117:            public static void childObjects(Object[] childs) {
118:                uiHandler.childObjects(childs);
119:            }
120:
121:            public static void owners(Map<Long, OwnerInfoHeader> owners,
122:                    long[] startObjects) {
123:                uiHandler.owners(owners, startObjects);
124:            }
125:
126:            public static void setStatus(String status) {
127:                uiHandler.showStatus(status);
128:            }
129:        }
130:
131:        class InVMPH implements  ProfilerHandler {
132:            public void submitTask(Runnable r) {
133:                TIJMPController.submitTask(r);
134:            }
135:
136:            public void runGC() {
137:                TIJMPController.runGC();
138:            }
139:
140:            public void walkHeap() {
141:                TIJMPController.walkHeap();
142:            }
143:
144:            public void childObjectsSummary(Object o) {
145:                TIJMPController.childObjectsSummary(o);
146:            }
147:
148:            public Object[] getObjectsForTags(long[] tags) {
149:                return TIJMPController.getObjectsForTags(tags);
150:            }
151:
152:            public void showInstances(Class<?> clz) {
153:                TIJMPController.showInstances(clz);
154:            }
155:
156:            public void showStrings() {
157:                TIJMPController.showStrings();
158:            }
159:
160:            public void showOwners(Class<?> clz) {
161:                TIJMPController.showOwners(clz);
162:            }
163:
164:            public MemoryMXBean getMemoryMXBean() {
165:                return ManagementFactory.getMemoryMXBean();
166:            }
167:
168:            public List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
169:                return ManagementFactory.getMemoryPoolMXBeans();
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.