Source Code Cross Referenced for MemberMethodTestAspect.java in  » Aspect-oriented » aspectwerkz-2.0 » test » aspect » 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 » Aspect oriented » aspectwerkz 2.0 » test.aspect 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************************
002:         * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
003:         * http://aspectwerkz.codehaus.org                                                    *
004:         * ---------------------------------------------------------------------------------- *
005:         * The software in this package is published under the terms of the LGPL license      *
006:         * a copy of which has been included with this distribution in the license.txt file.  *
007:         **************************************************************************************/package test.aspect;
008:
009:        import test.Loggable;
010:        import org.codehaus.aspectwerkz.definition.Pointcut;
011:        import org.codehaus.aspectwerkz.definition.Pointcut;
012:        import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
013:        import org.codehaus.aspectwerkz.joinpoint.MethodRtti;
014:        import org.codehaus.aspectwerkz.joinpoint.Rtti;
015:
016:        import java.io.File;
017:        import java.io.FileInputStream;
018:        import java.io.FileOutputStream;
019:        import java.io.ObjectInputStream;
020:        import java.io.ObjectOutput;
021:        import java.io.ObjectOutputStream;
022:
023:        /**
024:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
025:         * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
026:         * @Aspect perJVM
027:         */
028:        public class MemberMethodTestAspect {
029:            // ============ Pointcuts ============
030:
031:            /**
032:             * @Expression call(* test.MemberMethodAdviceTest.get*(..)) && within(test.MemberMethodAdviceTest)
033:             */
034:            Pointcut member_pc1;
035:
036:            /**
037:             * @Expression execution(* test.MemberMethodAdviceTest.*Param**(..))
038:             */
039:            Pointcut member_pc2;
040:
041:            /**
042:             * @Expression execution(* test.MemberMethodAdviceTest.exceptionThrower*(..))
043:             */
044:            Pointcut member_pc3;
045:
046:            /**
047:             * @Expression call(* test.MemberMethodAdviceTest.methodAdvicedMethod()) && within(test.MemberMethodAdviceTest)
048:             */
049:            Pointcut member_pc4;
050:
051:            /**
052:             * @Expression execution(* test.MemberMethodAdviceTest.meth*AdvicedMethod())
053:             */
054:            Pointcut member_pc5;
055:
056:            /**
057:             * @Expression call(* test.MemberMethodAdviceTest.method*icedMethodNewThread(..)) && within(test.MemberMethodAdviceTest)
058:             */
059:            Pointcut member_pc6;
060:
061:            /**
062:             * @Expression execution(* test.MemberMethodAdviceTest.method*dvicedMethodNewThread(..))
063:             */
064:            Pointcut member_pc7;
065:
066:            /**
067:             * @Expression call(* test.MemberMethodAdviceTest.multipleMethodAdvicedMethod(..)) && within(test.MemberMethodAdviceTest)
068:             */
069:            Pointcut member_pc8;
070:
071:            /**
072:             * @Expression execution(* test.MemberMethodAdviceTest.multipleChainedMethodAdvicedMethod(..))
073:             */
074:            Pointcut member_pc9;
075:
076:            /**
077:             * @Expression call(* test.MemberMethodAdviceTest.joinPointMetaData(..)) && within(test.MemberMethodAdviceTest)
078:             */
079:            Pointcut member_pc10;
080:
081:            /**
082:             * @Expression call(void test.MemberMethodAdviceTest.passingParameterToAdviceMethod(..)) && within(test.MemberMethodAdviceTest)
083:             */
084:            Pointcut member_pc11;
085:
086:            /**
087:             * @Expression execution(void test.MemberMethodAdviceTest.multiplePointcutsMethod(..))
088:             */
089:            Pointcut member_pc12;
090:
091:            /**
092:             * @Expression call(void test.MemberMethodAdviceTest.multiplePointcutsMethod(..)) && within(test.MemberMethodAdviceTest)
093:             */
094:            Pointcut member_pc13;
095:
096:            /**
097:             * @Expression execution(* test.MemberMethodAdviceTest.takesArrayAsArgument(String[]))
098:             */
099:            Pointcut member_pc14;
100:
101:            /**
102:             * @Expression call(long test.MemberMethodAdviceTest.getPrimitiveAndNullFromAdvice()) && within(test.MemberMethodAdviceTest)
103:             */
104:            Pointcut member_pc15;
105:
106:            /**
107:             * @Expression execution(void test.MemberMethodAdviceTest.beforeAdvicedMethod())
108:             */
109:            Pointcut member_pc16;
110:
111:            /**
112:             * @Expression call(void test.MemberMethodAdviceTest.afterAdvicedMethod()) && within(test.MemberMethodAdviceTest)
113:             */
114:            Pointcut member_pc17;
115:
116:            /**
117:             * @Expression execution(void test.MemberMethodAdviceTest.beforeAfterAdvicedMethod())
118:             */
119:            Pointcut member_pc18;
120:
121:            /**
122:             * @Expression call(void test.MemberMethodAdviceTest.beforeAroundAfterAdvicedMethod()) && within(test.MemberMethodAdviceTest)
123:             */
124:            Pointcut member_pc19;
125:
126:            /**
127:             * @Expression call(* test.MemberMethodAdviceTest.longNoAroundAdvice(..)) && within(test.MemberMethodAdviceTest)
128:             */
129:            Pointcut noAroundAdvice;
130:
131:            // ============ Advices ============
132:
133:            /**
134:             * @Around member_pc1 || member_pc2 || member_pc3 || member_pc4 || member_pc14 || member_pc9
135:             */
136:            public Object advice1(final JoinPoint joinPoint) throws Throwable {
137:                return joinPoint.proceed();
138:            }
139:
140:            /**
141:             * @Around member_pc5 || member_pc8 || member_pc9 || member_pc12 || member_pc19
142:             */
143:            public Object advice2(final JoinPoint joinPoint) throws Throwable {
144:                ((Loggable) joinPoint.getTarget()).log("before1 ");
145:                final Object result = joinPoint.proceed();
146:                ((Loggable) joinPoint.getTarget()).log("after1 ");
147:                return result;
148:            }
149:
150:            /**
151:             * @Around member_pc8 || member_pc9 || member_pc13 || member_pc19
152:             */
153:            public Object advice3(final JoinPoint joinPoint) throws Throwable {
154:                ((Loggable) joinPoint.getTarget()).log("before2 ");
155:                final Object result = joinPoint.proceed();
156:                ((Loggable) joinPoint.getTarget()).log("after2 ");
157:                return result;
158:            }
159:
160:            /**
161:             * @Around member_pc10
162:             */
163:            public Object advice4(JoinPoint joinPoint) throws Throwable {
164:                final Object result = joinPoint.proceed();
165:                MethodRtti mrtti = (MethodRtti) joinPoint.getRtti();
166:                String metadata = joinPoint.getCalleeClass().getName()
167:                        + mrtti.getMethod().getName()
168:                        + joinPoint.getTarget().hashCode()
169:                        + mrtti.getParameterValues()[0]
170:                        + mrtti.getParameterTypes()[0].getName()
171:                        + mrtti.getReturnType().getName()
172:                        + mrtti.getReturnValue();
173:                return metadata;
174:            }
175:
176:            /**
177:             * @Around member_pc6 || member_pc7
178:             */
179:            public Object advice5(final JoinPoint joinPoint) throws Throwable {
180:                ((Loggable) joinPoint.getTarget()).log("before ");
181:                final Object result = joinPoint.proceed();
182:                ((Loggable) joinPoint.getTarget()).log("after ");
183:                return result;
184:            }
185:
186:            /**
187:             * @Around member_pc15
188:             */
189:            public Object advice6(JoinPoint joinPoint) throws Throwable {
190:                // test to serialize the join point instance
191:                try {
192:                    ObjectOutput out = new ObjectOutputStream(
193:                            new FileOutputStream("joinpoint.ser"));
194:                    out.writeObject(joinPoint);
195:                    out.close();
196:                    File file = new File("joinpoint.ser");
197:                    ObjectInputStream in = new ObjectInputStream(
198:                            new FileInputStream(file));
199:                    joinPoint = (JoinPoint) in.readObject();
200:                    in.close();
201:                } catch (Exception e) {
202:                    System.err
203:                            .println("FIXME: serialization for JIT compiled join points");
204:                }
205:                return null;
206:            }
207:
208:            /**
209:             * @Before member_pc16 || member_pc18 || member_pc19 || noAroundAdvice
210:             */
211:            public void before(final JoinPoint joinPoint) throws Throwable {
212:                ((Loggable) joinPoint.getTarget()).log("pre ");
213:            }
214:
215:            /**
216:             * @After member_pc17 || member_pc18 || member_pc19
217:             */
218:            public void after(final JoinPoint joinPoint) throws Throwable {
219:                ((Loggable) joinPoint.getTarget()).log("post ");
220:            }
221:
222:            /**
223:             * @After call(* test.MemberMethodAdviceTest.callWithincodeCtor(..))
224:             * && withincode(test.MemberMethodAdviceTest.new(int))
225:             */
226:            public void afterWithinCtor(final JoinPoint joinPoint) {
227:                ((Loggable) joinPoint.getTarget()).log("post ");
228:            }
229:
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.