Source Code Cross Referenced for InvocationRecorder.java in  » Testing » MockEJB » org » mockejb » interceptor » 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 » MockEJB » org.mockejb.interceptor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.mockejb.interceptor;
002:
003:        import java.util.*;
004:
005:        /**
006:         * Stores the information about all calls to the target object 
007:         * in the list. Clients can examine the list to see the parameters of the calls. 
008:         * Example of usage:
009:         * <code><pre>
010:         *  InvocationRecorder recorder = new InvocationRecorder();
011:         *  aspectSystem.add( new ClassPointcut( SampleHelper.class, false), recorder);        
012:         *  InvocationContext dummyMethodInvocation = recorder.findByTargetMethod( "dummyMethod");
013:         *  assertNotNull(dummyMethodInvocation);
014:         * </pre></code>
015:         * 
016:         * @author Alexander Ananiev
017:         */
018:        public class InvocationRecorder implements  Interceptor {
019:
020:            private List invocationContextList = new ArrayList();
021:
022:            public void intercept(InvocationContext invocationContext)
023:                    throws Exception {
024:
025:                Exception thrownException = null;
026:                Object returnObj = null;
027:
028:                try {
029:                    invocationContext.proceed();
030:                } finally {
031:
032:                    invocationContextList.add(invocationContext);
033:                }
034:
035:            }
036:
037:            /**
038:             * Returns the list of all invocations that happened since the recorder 
039:             * was added.
040:             * @return list of invocations
041:             */
042:            public List getMethodInvocationList() {
043:                return invocationContextList;
044:            }
045:
046:            /**
047:             * Returns true is it has at least one record
048:             * 
049:             * @return true if at least one recording was made
050:             */
051:            public boolean hasRecords() {
052:                return !invocationContextList.isEmpty();
053:            }
054:
055:            /**
056:             * Clears all currently stored invocations
057:             */
058:            public void clear() {
059:                invocationContextList.clear();
060:            }
061:
062:            /**
063:             * Finds the first invocation for a given target method pattern.
064:             * @param methodPattern regexp pattern to run against the string representation of a method  
065:             * @return invocation context or null if method not found 
066:             * 
067:             */
068:            public InvocationContext findByTargetMethod(String methodPattern) {
069:
070:                RegexpWrapper regexp = new RegexpWrapper(methodPattern);
071:
072:                Iterator i = invocationContextList.iterator();
073:
074:                while (i.hasNext()) {
075:                    InvocationContext invocation = (InvocationContext) i.next();
076:                    if (regexp.containedInString(invocation.getTargetMethod()
077:                            .toString()))
078:                        return invocation;
079:                }
080:
081:                return null;
082:            }
083:
084:            /**
085:             * @deprecated Use findByProxyMethod instead
086:             * @param methodPattern regexp pattern to run against the string representation of a method
087:             * @return invocation context or null if method not found
088:             */
089:            public InvocationContext findByInterceptedMethod(
090:                    String methodPattern) {
091:                return findByProxyMethod(methodPattern);
092:            }
093:
094:            /**
095:             * Finds the first invocation for a given proxy method pattern.
096:             * @param methodPattern regexp pattern to run against the string representation of a method  
097:             * @return invocation context or null if method not found 
098:             * 
099:             */
100:            public InvocationContext findByProxyMethod(String methodPattern) {
101:
102:                RegexpWrapper regexp = new RegexpWrapper(methodPattern);
103:                Iterator i = invocationContextList.iterator();
104:
105:                while (i.hasNext()) {
106:                    InvocationContext invocation = (InvocationContext) i.next();
107:                    if (regexp.containedInString(invocation.getProxyMethod()
108:                            .toString()))
109:                        return invocation;
110:                }
111:
112:                return null;
113:            }
114:
115:            public String toString() {
116:                return invocationContextList.toString();
117:            }
118:
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.