Source Code Cross Referenced for AfterObjectInitializationCodeAdapter.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » aspectwerkz » transform » inlining » weaver » 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 » org.codehaus.aspectwerkz.transform.inlining.weaver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /**************************************************************************************
02:         * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved.                 *
03:         * http://aspectwerkz.codehaus.org                                                    *
04:         * ---------------------------------------------------------------------------------- *
05:         * The software in this package is published under the terms of the LGPL license      *
06:         * a copy of which has been included with this distribution in the license.txt file.  *
07:         **************************************************************************************/package org.codehaus.aspectwerkz.transform.inlining.weaver;
08:
09:        import org.objectweb.asm.CodeAdapter;
10:        import org.objectweb.asm.CodeVisitor;
11:        import org.codehaus.aspectwerkz.transform.TransformationConstants;
12:        import org.codehaus.aspectwerkz.annotation.instrumentation.asm.AsmAnnotationHelper;
13:
14:        /**
15:         * A visitor that keeps track of NEW and INVOKESPECIAL when within a constructor
16:         * to flag when the object initialization has been reached (after this/super call).
17:         * <p/>
18:         * No regular weaving should occur before it since this(XXJP.invoke(this)) is not allowed Java code
19:         *
20:         * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
21:         */
22:        public class AfterObjectInitializationCodeAdapter extends CodeAdapter
23:                implements  TransformationConstants {
24:
25:            private String m_callerMemberName;
26:            private int m_newCount = 0;
27:            private int m_invokeSpecialCount = 0;
28:            protected boolean m_isObjectInitialized = false;
29:
30:            public AfterObjectInitializationCodeAdapter(CodeVisitor cv,
31:                    String callerMemberName) {
32:                super (cv);
33:                m_callerMemberName = callerMemberName;
34:                // object initialization matters within constructors only
35:                if (!m_callerMemberName.equals(INIT_METHOD_NAME)) {
36:                    m_isObjectInitialized = true;
37:                }
38:            }
39:
40:            public void visitTypeInsn(int opcode, String desc) {
41:                if (opcode == NEW) {
42:                    m_newCount++;
43:                }
44:                super .visitTypeInsn(opcode, desc);
45:            }
46:
47:            protected boolean queryCurrentMethodInsn(final int opcode,
48:                    final String calleeClassName,
49:                    final String calleeMethodName, final String calleeMethodDesc) {
50:                int localInvokeSpecialCount = m_invokeSpecialCount;
51:                int localNewCount = m_newCount;
52:
53:                if (opcode == INVOKESPECIAL) {
54:                    localInvokeSpecialCount++;
55:                }
56:
57:                if (m_callerMemberName.equals(INIT_METHOD_NAME)) {
58:                    // in ctor
59:                    // make sure we are after object initialization ie after
60:                    // the INVOKESPECIAL for this(..) / super(..)
61:                    // that is we have seen an INVOKESPECIAL while newCount == 0
62:                    // or while newCount == invokeSpecialCount - 1
63:                    // [ ie same with numberOfInvokeSpecialCount = 1 ]
64:                    if (opcode == INVOKESPECIAL) {
65:                        if (localNewCount == localInvokeSpecialCount - 1) {
66:                            return true;
67:                        }
68:                    }
69:                    return false;
70:                }
71:                return false;
72:            }
73:
74:            public void visitMethodInsn(final int opcode,
75:                    final String calleeClassName,
76:                    final String calleeMethodName, final String calleeMethodDesc) {
77:                if (opcode == INVOKESPECIAL) {
78:                    m_invokeSpecialCount++;
79:                }
80:
81:                if (m_callerMemberName.equals(INIT_METHOD_NAME)) {
82:                    // in ctor
83:                    // make sure we are after object initialization ie after
84:                    // the INVOKESPECIAL for this(..) / super(..)
85:                    // that is we have seen an INVOKESPECIAL while newCount == 0
86:                    // or while newCount == invokeSpecialCount - 1
87:                    // [ ie same with numberOfInvokeSpecialCount = 1 ]
88:                    if (opcode == INVOKESPECIAL) {
89:                        if (m_newCount == m_invokeSpecialCount - 1) {
90:                            m_isObjectInitialized = true;
91:                        }
92:                    }
93:                }
94:                super.visitMethodInsn(opcode, calleeClassName,
95:                        calleeMethodName, calleeMethodDesc);
96:            }
97:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.