Source Code Cross Referenced for HandlerJoinPointCompiler.java in  » Net » Terracotta » com » tc » aspectwerkz » transform » inlining » compiler » 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 » Net » Terracotta » com.tc.aspectwerkz.transform.inlining.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.aspectwerkz.transform.inlining.compiler;
005:
006:        import com.tc.asm.MethodVisitor;
007:        import com.tc.asm.Type;
008:
009:        /**
010:         * A compiler that compiles/generates a class that represents a specific join point, a class which invokes the advices
011:         * and the target join point statically.
012:         * <p/>
013:         * In this case, CALLEE is the catched exception instance itself.
014:         *
015:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
016:         * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur </a>
017:         */
018:        public class HandlerJoinPointCompiler extends AbstractJoinPointCompiler {
019:
020:            /**
021:             * Creates a new join point compiler instance.
022:             *
023:             * @param model
024:             */
025:            HandlerJoinPointCompiler(final CompilationInfo.Model model) {
026:                super (model);
027:            }
028:
029:            /**
030:             * Creates join point specific fields.
031:             */
032:            protected void createJoinPointSpecificFields() {
033:                // create the field argument field
034:                String[] fieldNames = null;
035:                Type fieldType = Type.getType(m_calleeClassSignature);
036:                fieldNames = new String[1];
037:                String fieldName = ARGUMENT_FIELD + 0;
038:                fieldNames[0] = fieldName;
039:                m_cw.visitField(ACC_PRIVATE, fieldName, fieldType
040:                        .getDescriptor(), null, null);
041:                m_fieldNames = fieldNames;
042:                m_cw.visitField(ACC_PRIVATE + ACC_STATIC, SIGNATURE_FIELD_NAME,
043:                        HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE, null, null);
044:            }
045:
046:            /**
047:             * Creates the signature for the join point.
048:             *
049:             * @param cv
050:             */
051:            protected void createSignature(final MethodVisitor cv) {
052:                cv.visitFieldInsn(GETSTATIC, m_joinPointClassName,
053:                        TARGET_CLASS_FIELD_NAME_IN_JP, CLASS_CLASS_SIGNATURE);
054:
055:                cv.visitMethodInsn(INVOKESTATIC, SIGNATURE_FACTORY_CLASS,
056:                        NEW_CATCH_CLAUSE_SIGNATURE_METHOD_NAME,
057:                        NEW_HANDLER_SIGNATURE_METHOD_SIGNATURE);
058:                cv.visitFieldInsn(PUTSTATIC, m_joinPointClassName,
059:                        SIGNATURE_FIELD_NAME,
060:                        HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE);
061:
062:            }
063:
064:            /**
065:             * Optimized implementation that does not retrieve the parameters from the join point instance but is passed
066:             * directly to the method from the input parameters in the 'invoke' method. Can only be used if no around advice
067:             * exists.
068:             *
069:             * @param cv
070:             * @param input
071:             */
072:            protected void createInlinedJoinPointInvocation(
073:                    final MethodVisitor cv, final CompilerInput input) {
074:                // load the exception
075:                cv.visitVarInsn(ALOAD, 0);//TODO if changed perhaps load CALLEE instead that host the exception ?
076:            }
077:
078:            /**
079:             * Creates a call to the target join point, the parameter(s) to the join point are retrieved from the invocation
080:             * local join point instance.
081:             *
082:             * @param cv
083:             */
084:            protected void createJoinPointInvocation(final MethodVisitor cv) {
085:                cv.visitInsn(ACONST_NULL);
086:            }
087:
088:            /**
089:             * Returns the join points return type.
090:             *
091:             * @return
092:             */
093:            protected Type getJoinPointReturnType() {
094:                return Type.getType(m_calleeClassSignature);
095:            }
096:
097:            /**
098:             * Returns the join points argument type(s).
099:             *
100:             * @return
101:             */
102:            protected Type[] getJoinPointArgumentTypes() {
103:                return new Type[] { Type.getType(m_calleeClassSignature) };//TODO should callee be arg instead ? to bind it later ?
104:            }
105:
106:            /**
107:             * Creates the getRtti method
108:             */
109:            protected void createGetRttiMethod() {
110:                MethodVisitor cv = m_cw.visitMethod(ACC_PUBLIC,
111:                        GET_RTTI_METHOD_NAME, GET_RTTI_METHOD_SIGNATURE, null,
112:                        null);
113:
114:                // new CtorRttiImpl( .. )
115:                cv.visitTypeInsn(NEW, HANDLER_RTTI_IMPL_CLASS_NAME);
116:                cv.visitInsn(DUP);
117:                cv.visitFieldInsn(GETSTATIC, m_joinPointClassName,
118:                        SIGNATURE_FIELD_NAME,
119:                        HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE);
120:                cv.visitVarInsn(ALOAD, 0);
121:                cv.visitFieldInsn(GETFIELD, m_joinPointClassName,
122:                        CALLER_INSTANCE_FIELD_NAME, m_callerClassSignature);
123:                cv.visitVarInsn(ALOAD, 0);
124:                cv.visitFieldInsn(GETFIELD, m_joinPointClassName,
125:                        CALLEE_INSTANCE_FIELD_NAME, m_calleeClassSignature);
126:                cv.visitMethodInsn(INVOKESPECIAL, HANDLER_RTTI_IMPL_CLASS_NAME,
127:                        INIT_METHOD_NAME, HANDLER_RTTI_IMPL_INIT_SIGNATURE);
128:
129:                cv.visitInsn(ARETURN);
130:                cv.visitMaxs(0, 0);
131:            }
132:
133:            /**
134:             * Creates the getSignature method.
135:             */
136:            protected void createGetSignatureMethod() {
137:                MethodVisitor cv = m_cw.visitMethod(ACC_PUBLIC,
138:                        GET_SIGNATURE_METHOD_NAME,
139:                        GET_SIGNATURE_METHOD_SIGNATURE, null, null);
140:                cv.visitFieldInsn(GETSTATIC, m_joinPointClassName,
141:                        SIGNATURE_FIELD_NAME,
142:                        HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE);
143:                cv.visitInsn(ARETURN);
144:                cv.visitMaxs(0, 0);
145:            }
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.