Source Code Cross Referenced for CallerTraceService.java in  » Code-Analyzer » hammurapi-3.20.0.3 » org » hammurapi » inspectors » metrics » callertrace » 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 » Code Analyzer » hammurapi 3.20.0.3 » org.hammurapi.inspectors.metrics.callertrace 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Nov 2, 2003
003:         *
004:         * To change the template for this generated file go to
005:         * Window>Preferences>Java>Code Generation>Code and Comments
006:         */
007:        package org.hammurapi.inspectors.metrics.callertrace;
008:
009:        import java.io.File;
010:        import java.util.Enumeration;
011:        import java.util.Hashtable;
012:        import java.util.Vector;
013:
014:        import org.w3c.dom.Document;
015:        import org.w3c.dom.Element;
016:
017:        /**
018:         * @author mucbj0
019:         *
020:         * To change the template for this generated type comment go to
021:         * Window>Preferences>Java>Code Generation>Code and Comments
022:         */
023:        public class CallerTraceService {
024:            private File projectBaseDir = null;
025:            // private static Logger logger = Logger.getLogger(CallerTraceService.class.getName());
026:
027:            private Hashtable allClasses = new Hashtable();
028:            private Hashtable allInterfacesAndImplementors = new Hashtable();
029:            private Vector allInterfaceOperations = new Vector();
030:            private MethodMap allInvokedMethodTable = new MethodMap();
031:            private MethodMap allMethodsImplemented = new MethodMap();
032:
033:            private MethodMap allMethodsImplementedButNotInvoked = new MethodMap();
034:
035:            // private AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix(new DepthFirstSearch(	));
036:            private AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix(
037:                    new BreadthSearch());
038:            private MethodMap allMethods = new MethodMap();
039:            private TraceTable traceTable = new TraceTable();
040:
041:            public void doIt() {
042:                init();
043:                traceCaller();
044:                return;
045:            }
046:
047:            public void init() {
048:                adjacencyMatrix.setAllMethods(allMethods);
049:            }
050:
051:            public static boolean doYouPassMethodNameFilter(String methodName) {
052:                if (methodName != null) {
053:                    return true;
054:                }
055:                return false;
056:            }
057:
058:            public void traceCaller() {
059:
060:                MethodWrapper mi = null;
061:                int i = 0;
062:                String[] key = {
063:                        //					"java.sql.Statement>>executeQuery(String)",
064:                        //					"java.sql.Connection>>rollback()",
065:                        //					"java.sql.Connection>>commit()"
066:
067:                        //-- Na Fac Induction
068:                        /*  "ConnectionObject>>exeSelectPreparedStmt",
069:                         "ConnectionObject>>exeSelectPrepStmt",
070:                         "ConnectionObject>>exeUpdatePrepStmt",
071:
072:                         "ConnectionObject>>rollbackDataBase",
073:                         "ConnectionObject>>commitDataBase",
074:                         "ConnectionObject>>closeAllStmt",
075:                         "ConnectionObject>>closeAllStatement",
076:                         "ConnectionObject>>close",
077:                         */
078:                        //NPI
079:                        //		"DocumentDAO>>update",
080:                        //		"ApplicationUserDAO>>update",
081:                        //		"DocumentActionReportDAO>>update",
082:                        //		"DocumentTaskDAO>>update",
083:                        "java.sql.Connection>>createStatement()",
084:                        "java.sql.Connection>>close()",
085:                        "java.sql.Statement>>executeQuery(java.lang.String)",
086:                        "java.sql.PreparedStatement>>executeQuery(java.lang.String)",
087:                        "java.sql.Connection>>rollback()",
088:                        "java.sql.Connection>>commit()",
089:                        "javax.transaction.UserTransaction>>commit()",
090:                        "javax.transaction.UserTransaction>>rollback()",
091:                        "com.inconcert.icjava.IcTask>>acquire()",
092:                        "com.inconcert.icjava.IcTask>>complete()",
093:                        "com.inconcert.icjava.IcTask>>release()"
094:
095:                //ADB shot
096:                // "BaseDao>>doCommit","BaseDao>>doRollback","BaseDao>>doUpdate",
097:
098:                /*
099:                "ConnectionObject>>updateDataBase","ConnectionObject>>exeUpdatePrepStmt",
100:                "ConnectionObject>>deleteDataBase","ConnectionObject>>insertDataBase",
101:                "ConnectionObject>>close", "ConnectionObject>>rollbackTransaction", "ConnectionObject>>commitTransaction"
102:                 */
103:
104:                // "Dao>>insert",
105:                // "IcClient>>close"
106:                //			"ukcBeanDataAccess>>updateRecord",
107:                //			"ukcBeanDataAccess>>insertRecord",
108:                //			"ukcBeanDataAccess>>deleteRecord",
109:                };
110:
111:                for (int j = 0; j < key.length; j++) {
112:
113:                    // System.out.println("Trace Callers for : " + key[j]);
114:                    adjacencyMatrix.clearAllVisitFlags();
115:
116:                    boolean isLeaf;
117:                    Trace trace;
118:                    // 		TraceList traceList = depthFirstSearchForTraces(key[j]);
119:                    TraceList traceList = breadthSearchForTraces(key[j]);
120:                    traceTable.put(key[j], traceList);
121:                }
122:                checkForSiblings(key);
123:                return;
124:            }
125:
126:            private void checkForSiblings(String[] key) {
127:		
128:		for (Enumeration enum = traceTable.elements(); enum.hasMoreElements();) {
129:			TraceList traceLst = (TraceList) enum.nextElement();
130:
131:			for (Enumeration enumLst = traceLst.elements(); enumLst.hasMoreElements();) {
132:				Trace trace = (Trace) enumLst.nextElement();
133:
134:				for (Enumeration enumTrc = trace.elements(); enumTrc.hasMoreElements();) {
135:					TracedMethod tm = (TracedMethod) enumTrc.nextElement();
136:
137:					innerCheckForSiblings(key, tm);
138:				}
139:			}
140:		}
141:	}
142:
143:            /**
144:             * @param key
145:             * @param tm
146:             */
147:            private void innerCheckForSiblings(String[] key, TracedMethod tm) {
148:                tm.innerCheckForSiblings(key);
149:            }
150:
151:            private TraceList breadthSearchForTraces(String key) {
152:                TraceList traceList = new TraceList(key);
153:
154:                traceList.setEndpointMethod(
155:                        (MethodWrapper) allMethods.get(key), key);
156:                traceList.addAll(this .adjacencyMatrix.getTraceOf(key));
157:                // System.out.println(traceList);
158:                return traceList;
159:            }
160:
161:            private TraceList depthFirstSearchForTraces(String key) {
162:                TraceList traceList = new TraceList(key);
163:
164:                // logger.error(" ** " + (MethodWrapper)allMethods.get(key));
165:                traceList.setEndpointMethod(
166:                        (MethodWrapper) allMethods.get(key), key);
167:
168:                boolean isLeaf = false;
169:                while (!isLeaf) {
170:
171:                    Trace trace = new Trace(adjacencyMatrix.getTraceOf(key),
172:                            this .allMethods);
173:                    // System.out.println(trace);
174:
175:                    //-- termination
176:                    if (trace.size() < 2) {
177:                        isLeaf = true;
178:                    } else {
179:                        traceList.add(trace);
180:                    }
181:                }
182:                // System.out.println(traceList);
183:                return traceList;
184:            }
185:
186:            public Element toDom(Document document, Element root) {
187:                root.appendChild(traceTable.toDom(document));
188:                root.appendChild(allMethodsImplemented.toDom(document));
189:                return root;
190:            }
191:
192:            /**
193:             * @return Returns the allMethods.
194:             */
195:            public MethodMap getAllMethods() {
196:                return allMethods;
197:            }
198:
199:            /**
200:             * @return Returns the allMethodsImplemented.
201:             */
202:            public MethodMap getAllMethodsImplemented() {
203:                return allMethodsImplemented;
204:            }
205:
206:            /**
207:             * @return Returns the adjacencyMatrix.
208:             */
209:            public AdjacencyMatrix getAdjacencyMatrix() {
210:                return adjacencyMatrix;
211:            }
212:
213:            /**
214:             * @param adjacencyMatrix The adjacencyMatrix to set.
215:             */
216:            public void setAdjacencyMatrix(AdjacencyMatrix adjacencyMatrix) {
217:                this .adjacencyMatrix = adjacencyMatrix;
218:            }
219:
220:            /**
221:             * @return Returns the allInterfacesAndImplementors.
222:             */
223:            public Hashtable getAllInterfacesAndImplementors() {
224:                return allInterfacesAndImplementors;
225:            }
226:
227:            /**
228:             * @return Returns the allInvokedMethodTable.
229:             */
230:            public Hashtable getAllInvokedMethodTable() {
231:                return allInvokedMethodTable;
232:            }
233:
234:            /**
235:             * @return Returns the allInterfaceOperations.
236:             */
237:            public Vector getAllInterfaceOperations() {
238:                return allInterfaceOperations;
239:            }
240:
241:            public void resolveInvokeesImplementors() {
242:
243:                Enumeration enumAdj = getAdjacencyMatrix().getAllKeys();
244:                MethodMap mp = getAllMethodsImplemented();
245:                // System.out.println( mp );
246:                while (enumAdj.hasMoreElements()) {
247:                    EdgeImpl edge = (EdgeImpl) enumAdj.nextElement();
248:                    //	System.out.println( edge );
249:                    String leftHandKey = (String) edge.getNodeA();
250:                    String rightHandKey = (String) edge.getNodeA();
251:                    // System.out.println( leftHandKey );
252:                    MethodWrapperDeclaration mwd = (MethodWrapperDeclaration) mp
253:                            .get(leftHandKey);
254:                    if (mwd == null) {
255:                        mwd = (MethodWrapperDeclaration) mp
256:                                .selectMethodsBothWithoutHashkey(leftHandKey);
257:                        if (mwd != null) {
258:                            //	System.out.println( "Found: " + mwd.getMethodKey());
259:                            //!! delete the original one ..
260:                            mwd.afferentMethodCoupling++;
261:                            mwd.setCalled();
262:                            // System.out.println("Ma " + mwd.afferentMethodCoupling );
263:                            edge.setNodeA(mwd.getMethodKey());
264:                            // this.callerTraceService.getAdjacencyMatrix().put(mwd.getMethodKey(), rightHandKey );
265:                        } else {
266:                            //-- keep the exisitin edge, because no implemetor is known
267:                        }
268:                    }
269:                }
270:            }
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.