tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r573086 - in /incubator/tuscany/java/sca/modules: binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/ implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/ implementation-java/src/main/jav...
Date Wed, 05 Sep 2007 22:26:35 GMT
Author: rfeng
Date: Wed Sep  5 15:26:34 2007
New Revision: 573086

URL: http://svn.apache.org/viewvc?rev=573086&view=rev
Log:
Fix for TUSCANY-1662

Modified:
    incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
    incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
    incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java

Modified: incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java?rev=573086&r1=573085&r2=573086&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
Wed Sep  5 15:26:34 2007
@@ -192,7 +192,13 @@
             RuntimeWire wire = reference.getRuntimeWire(binding);
             Invoker invoker = getInvoker(wire, operation);
             if (invoker == null) {
-                throw new ServiceUnavailableException("No service invoker is available for:
" + binding.getURI());
+                throw new ServiceUnavailableException("No service invoker is available for
referenc " + reference
+                    .getName()
+                    + " (bindingURI="
+                    + binding.getURI()
+                    + " operation="
+                    + operation.getName()
+                    + ").");
             }
             return invoker;
         }

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java?rev=573086&r1=573085&r2=573086&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
Wed Sep  5 15:26:34 2007
@@ -46,22 +46,22 @@
     }
 
     public void testBean1AllPublicProtectedFields() throws Exception {
-        Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class);
+        Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class,
true);
         assertEquals(4, beanFields.size());                //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS
     }
 
     public void testGetSuperAllMethods() throws Exception {
-        Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class);
+        Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class,
true);
         assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size());
     }
 
     public void testGetBean1AllMethods() throws Exception {
-        Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class);
+        Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class,
true);
         assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size());
     }
 
     public void testOverrideMethod() throws Exception {
-        Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class);
+        Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class,
true);
         boolean invoked = false;
         for (Method method : beanFields) {
             if (method.getName().equals("override")) {
@@ -75,7 +75,7 @@
     }
 
     public void testNoOverrideMethod() throws Exception {
-        Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class);
+        Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class,
true);
         boolean found = false;
         for (Method method : beanFields) {
             if (method.getName().equals("noOverride") && method.getParameterTypes().length
== 0) {

Modified: incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java?rev=573086&r1=573085&r2=573086&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
Wed Sep  5 15:26:34 2007
@@ -86,14 +86,14 @@
             }
         }
 
-        Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz);
+        Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz,
true);
         for (Method method : methods) {
             for (JavaClassVisitor processor : visitors) {
                 processor.visitMethod(method, type);
             }
         }
 
-        Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz);
+        Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz,
true);
         for (Field field : fields) {
             for (JavaClassVisitor extension : visitors) {
                 extension.visitField(field, type);

Modified: incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java?rev=573086&r1=573085&r2=573086&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
Wed Sep  5 15:26:34 2007
@@ -107,7 +107,7 @@
                 addService(type, clazz);
             }
         }
-        Set<Method> methods = getAllUniquePublicProtectedMethods(clazz);
+        Set<Method> methods = getAllUniquePublicProtectedMethods(clazz, false);
         if (!type.getReferenceMembers().isEmpty() || !type.getPropertyMembers().isEmpty())
{
             // references and properties have been explicitly defined
 //            if (type.getServices().isEmpty()) {
@@ -202,7 +202,7 @@
         // Public or protected fields unless there is a public or protected
         // setter method
         // for the same name
-        Set<Field> fields = getAllPublicAndProtectedFields(clazz);
+        Set<Field> fields = getAllPublicAndProtectedFields(clazz, false);
         for (Field field : fields) {
             if (field.isAnnotationPresent(Callback.class) || field.isAnnotationPresent(Context.class))
{
                 continue;

Modified: incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java?rev=573086&r1=573085&r2=573086&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
Wed Sep  5 15:26:34 2007
@@ -19,6 +19,8 @@
 package org.apache.tuscany.sca.implementation.java.introspect.impl;
 
 import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.GenericArrayType;
@@ -33,6 +35,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.logging.Logger;
 
 import org.osoa.sca.CallableReference;
 
@@ -42,7 +45,7 @@
  * @version $Rev$ $Date$
  */
 public final class JavaIntrospectionHelper {
-
+    private static final Logger logger = Logger.getLogger(JavaIntrospectionHelper.class.getName());
     private static final Class[] EMPTY_CLASS_ARRY = new Class[0];
 
     /**
@@ -55,25 +58,38 @@
      * Returns a collection of public, and protected fields declared by a class
      * or one of its supertypes
      */
-    public static Set<Field> getAllPublicAndProtectedFields(Class clazz) {
-        return getAllPublicAndProtectedFields(clazz, new HashSet<Field>());
+    public static Set<Field> getAllPublicAndProtectedFields(Class clazz, boolean validating)
{
+        return getAllPublicAndProtectedFields(clazz, new HashSet<Field>(), validating);
+    }
+    
+
+    private static void checkInvalidAnnotations(AnnotatedElement element) {
+        for (Annotation a : element.getAnnotations()) {
+            if ("org.osoa.sca.annotations".equals(a.annotationType().getPackage().getName()))
{
+                logger.warning("Invalid annotation " + a + " is found on " + element);
+            }
+        }
     }
 
     /**
      * Recursively evaluates the type hierachy to return all fields that are
      * public or protected
      */
-    private static Set<Field> getAllPublicAndProtectedFields(Class clazz, Set<Field>
fields) {
+    private static Set<Field> getAllPublicAndProtectedFields(Class clazz, Set<Field>
fields, boolean validating) {
         if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
             return fields;
         }
-        fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields);
+        fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields, validating);
         Field[] declaredFields = clazz.getDeclaredFields();
         for (Field field : declaredFields) {
             int modifiers = field.getModifiers();
             if ((Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) &&
!Modifier.isStatic(modifiers)) {
                 field.setAccessible(true); // ignore Java accessibility
                 fields.add(field);
+            } else {
+                if(validating) {
+                    checkInvalidAnnotations(field);
+                }
             }
         }
         return fields;
@@ -87,14 +103,14 @@
      * cached. It is assumed that this method will be used during a
      * configuration phase.
      */
-    public static Set<Method> getAllUniquePublicProtectedMethods(Class clazz) {
-        return getAllUniqueMethods(clazz, new HashSet<Method>());
+    public static Set<Method> getAllUniquePublicProtectedMethods(Class clazz, boolean
validating) {
+        return getAllUniqueMethods(clazz, new HashSet<Method>(), validating);
     }
 
     /**
      * Recursively evaluates the type hierarchy to return all unique methods
      */
-    private static Set<Method> getAllUniqueMethods(Class pClass, Set<Method>
methods) {
+    private static Set<Method> getAllUniqueMethods(Class pClass, Set<Method>
methods, boolean validating) {
         if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
             return methods;
         }
@@ -103,6 +119,9 @@
         for (Method declaredMethod : declaredMethods) {
             int modifiers = declaredMethod.getModifiers();
             if ((!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers))
|| Modifier.isStatic(modifiers)) {
+                if(validating) {
+                    checkInvalidAnnotations(declaredMethod);
+                }
                 continue;
             }
             if (methods.size() == 0) {
@@ -130,7 +149,7 @@
         }
         // evaluate class hierarchy - this is done last to track inherited
         // methods
-        methods = getAllUniqueMethods(pClass.getSuperclass(), methods);
+        methods = getAllUniqueMethods(pClass.getSuperclass(), methods, validating);
         return methods;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message