summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-26 00:44:25 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-26 00:44:25 +0000
commit7d035f2da414c81b6a7c34b4f2d946303e59dcee (patch)
treea4a9ed760fbeb2e388e0990f590c6a3c6e7ea631
parent119cbb5b4fd5aef15143ad5c221e4ead831f73ae (diff)
Call all of visitXXX methods on the visitors one by one so that a visitor is always invoked before the other one
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@884348 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java74
1 files changed, 31 insertions, 43 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
index 6cb5e3730b..ff41517862 100644
--- a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
+++ b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
@@ -70,72 +70,60 @@ public class JavaClassIntrospectorImpl {
*/
public void introspectClass(JavaImplementation type, Class<?> clazz)
throws IntrospectionException {
- for (JavaClassVisitor extension : visitors) {
- extension.visitClass(clazz, type);
- }
-
- for (Constructor<?> constructor : clazz.getConstructors()) {
- for (JavaClassVisitor extension : visitors) {
- extension.visitConstructor(constructor, type);
+ for (JavaClassVisitor visitor : visitors) {
+ visitor.visitClass(clazz, type);
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ visitor.visitConstructor(constructor, type);
// Assuming the visitClass or visitConstructor will populate the
// type.getConstructors
JavaConstructorImpl<?> definition = type.getConstructors().get(constructor);
if (definition != null) {
for (JavaParameterImpl p : definition.getParameters()) {
- extension.visitConstructorParameter(p, type);
+ visitor.visitConstructorParameter(p, type);
}
}
}
- }
- Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz, true);
- for (Field field : fields) {
- for (JavaClassVisitor extension : visitors) {
- extension.visitField(field, type);
+ Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz, true);
+ for (Field field : fields) {
+ visitor.visitField(field, type);
}
- }
- // Check if any private fields have illegal annotations that should be raised as errors
- Set<Field> privateFields = JavaIntrospectionHelper.getPrivateFields(clazz);
- for (Field field : privateFields) {
- for (JavaClassVisitor processor : visitors) {
- processor.visitField(field, type);
+ // Check if any private fields have illegal annotations that should be raised as errors
+ Set<Field> privateFields = JavaIntrospectionHelper.getPrivateFields(clazz);
+ for (Field field : privateFields) {
+ visitor.visitField(field, type);
}
- }
-
- Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz, true);
- for (Method method : methods) {
- for (JavaClassVisitor processor : visitors) {
- processor.visitMethod(method, type);
+
+ Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz, true);
+ for (Method method : methods) {
+ visitor.visitMethod(method, type);
}
- }
- // Check if any private methods have illegal annotations that should be raised as errors
- Set<Method> privateMethods = JavaIntrospectionHelper.getPrivateMethods(clazz);
- for (Method method : privateMethods) {
- for (JavaClassVisitor processor : visitors) {
- processor.visitMethod(method, type);
+ // Check if any private methods have illegal annotations that should be raised as errors
+ Set<Method> privateMethods = JavaIntrospectionHelper.getPrivateMethods(clazz);
+ for (Method method : privateMethods) {
+ visitor.visitMethod(method, type);
}
- }
- Class<?> superClass = clazz.getSuperclass();
- if (superClass != null) {
- visitSuperClass(superClass, type);
- }
+ Class<?> superClass = clazz.getSuperclass();
+ if (superClass != null) {
+ visitSuperClass(superClass, type, visitor);
+ }
+
+ visitor.visitEnd(clazz, type);
- for (JavaClassVisitor extension : visitors) {
- extension.visitEnd(clazz, type);
}
+
}
- private void visitSuperClass(Class<?> clazz, JavaImplementation type) throws IntrospectionException {
+ private void visitSuperClass(Class<?> clazz, JavaImplementation type, JavaClassVisitor visitor)
+ throws IntrospectionException {
if (!Object.class.equals(clazz)) {
- for (JavaClassVisitor extension : visitors) {
- extension.visitSuperClass(clazz, type);
- }
+ visitor.visitSuperClass(clazz, type);
clazz = clazz.getSuperclass();
if (clazz != null) {
- visitSuperClass(clazz, type);
+ visitSuperClass(clazz, type, visitor);
}
}
}