Source Code Cross Referenced for SignatureFactory.java in  » Net » Terracotta » com » tc » aspectwerkz » joinpoint » management » 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.joinpoint.management 
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.joinpoint.management;
005:
006:        import java.lang.reflect.Constructor;
007:        import java.lang.reflect.Field;
008:        import java.lang.reflect.Method;
009:
010:        import com.tc.aspectwerkz.joinpoint.EnclosingStaticJoinPoint;
011:        import com.tc.aspectwerkz.joinpoint.impl.CatchClauseSignatureImpl;
012:        import com.tc.aspectwerkz.joinpoint.impl.ConstructorSignatureImpl;
013:        import com.tc.aspectwerkz.joinpoint.impl.EnclosingStaticJoinPointImpl;
014:        import com.tc.aspectwerkz.joinpoint.impl.FieldSignatureImpl;
015:        import com.tc.aspectwerkz.joinpoint.impl.MethodSignatureImpl;
016:        import com.tc.aspectwerkz.joinpoint.impl.StaticInitializerSignatureImpl;
017:        import com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfoRepository;
018:        import com.tc.aspectwerkz.reflect.ReflectHelper;
019:        import com.tc.aspectwerkz.transform.TransformationConstants;
020:        import com.tc.aspectwerkz.transform.inlining.AsmHelper;
021:
022:        /**
023:         * Factory class for the signature hierarchy.
024:         * The helper methods here are called by the JIT jp.
025:         * <p/>
026:         * TODO may be worth having a cache
027:         *
028:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
029:         * @author <a href="mailto:the_mindstorm@evolva.ro">Alex Popescu</a>
030:         */
031:        public final class SignatureFactory {
032:
033:            /**
034:             * Method signature factory
035:             *
036:             * @param declaringClass
037:             * @param joinPointHash
038:             * @return
039:             */
040:            public static final MethodSignatureImpl newMethodSignature(
041:                    final Class declaringClass, final int joinPointHash) {
042:                AsmClassInfoRepository.getRepository(
043:                        declaringClass.getClassLoader()).removeClassInfo(
044:                        declaringClass.getName().replace('.', '/'));
045:                Method[] methods = declaringClass.getDeclaredMethods();
046:                for (int i = 0; i < methods.length; i++) {
047:                    Method method = methods[i];
048:                    if (ReflectHelper.calculateHash(method) == joinPointHash) {
049:                        return new MethodSignatureImpl(declaringClass, method);
050:                    }
051:                }
052:                // lookup in the hierarchy
053:                MethodSignatureImpl signature = null;
054:                for (int i = 0; i < declaringClass.getInterfaces().length; i++) {
055:                    signature = newMethodSignature(declaringClass
056:                            .getInterfaces()[i], joinPointHash);
057:                    if (signature != null) {
058:                        return signature;
059:                    }
060:                }
061:                if (declaringClass.getSuperclass() != null) {
062:                    signature = newMethodSignature(declaringClass
063:                            .getSuperclass(), joinPointHash);
064:                } else {
065:                    return null;
066:                }
067:                return signature;
068:            }
069:
070:            /**
071:             * Field signature factory
072:             *
073:             * @param declaringClass
074:             * @param joinPointHash
075:             * @return
076:             */
077:            public static final FieldSignatureImpl newFieldSignature(
078:                    final Class declaringClass, final int joinPointHash) {
079:                Field[] fields = declaringClass.getDeclaredFields();
080:                for (int i = 0; i < fields.length; i++) {
081:                    Field field = fields[i];
082:                    if (ReflectHelper.calculateHash(field) == joinPointHash) {
083:                        return new FieldSignatureImpl(declaringClass, field);
084:                    }
085:                }
086:                // lookup in the hierarchy
087:                if (declaringClass.getSuperclass() != null) {
088:                    return newFieldSignature(declaringClass.getSuperclass(),
089:                            joinPointHash);
090:                } else {
091:                    return null;
092:                }
093:            }
094:
095:            /**
096:             * Constructor signature factory
097:             *
098:             * @param declaringClass
099:             * @param joinPointHash
100:             * @return
101:             */
102:            public static final ConstructorSignatureImpl newConstructorSignature(
103:                    final Class declaringClass, final int joinPointHash) {
104:                for (int i = 0; i < declaringClass.getDeclaredConstructors().length; i++) {
105:                    Constructor c = declaringClass.getDeclaredConstructors()[i];
106:                    if (ReflectHelper.calculateHash(c) == joinPointHash) {
107:                        return new ConstructorSignatureImpl(declaringClass, c);
108:                    }
109:                }
110:                // lookup in the hierarchy
111:                if (declaringClass.getSuperclass() != null) {
112:                    return newConstructorSignature(declaringClass
113:                            .getSuperclass(), joinPointHash);
114:                } else {
115:                    return null;
116:                }
117:            }
118:
119:            /**
120:             * Handler signature factory
121:             *
122:             * @param exceptionClass
123:             * @return
124:             */
125:            public static final CatchClauseSignatureImpl newCatchClauseSignature(
126:                    final Class exceptionClass) {
127:                return new CatchClauseSignatureImpl(exceptionClass);
128:            }
129:
130:            /**
131:             * Enclosing signature factory, wrapped behind an EnclosingStaticJoinPoint for syntax consistency
132:             *
133:             * @param declaringClass
134:             * @param name
135:             * @param description
136:             * @return
137:             */
138:            public static EnclosingStaticJoinPoint newEnclosingStaticJoinPoint(
139:                    final Class declaringClass, final String name,
140:                    final String description) {
141:                if (TransformationConstants.CLINIT_METHOD_NAME.equals(name)) {
142:                    return new EnclosingStaticJoinPointImpl(
143:                            new StaticInitializerSignatureImpl(declaringClass),
144:                            JoinPointType.STATIC_INITIALIZATION);
145:                } else if (TransformationConstants.INIT_METHOD_NAME
146:                        .equals(name)) {
147:                    return new EnclosingStaticJoinPointImpl(
148:                            newConstructorSignature(declaringClass, AsmHelper
149:                                    .calculateConstructorHash(description)),
150:                            JoinPointType.CONSTRUCTOR_EXECUTION);
151:                } else {
152:                    // regular method
153:                    return new EnclosingStaticJoinPointImpl(newMethodSignature(
154:                            declaringClass, AsmHelper.calculateMethodHash(name,
155:                                    description)),
156:                            JoinPointType.METHOD_EXECUTION);
157:                }
158:            }
159:
160:            /**
161:             * Static initialization factory
162:             *
163:             * @param declaringClass
164:             * @return
165:             */
166:            public static StaticInitializerSignatureImpl newStaticInitializationSignature(
167:                    final Class declaringClass) {
168:                return new StaticInitializerSignatureImpl(declaringClass);
169:            }
170:
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.