tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1221454 - in /tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl: JavaInterfaceIntrospectorImpl.java JavaIntrospectionHelper.java
Date Tue, 20 Dec 2011 19:32:07 GMT
Author: antelder
Date: Tue Dec 20 19:32:07 2011
New Revision: 1221454

URL: http://svn.apache.org/viewvc?rev=1221454&view=rev
Log:
TUSCANY-3992: Apply patch from Greg Dritschler to fix AccessControlException occurs when calling
SCAClientFactory.getService

Modified:
    tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
    tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java

Modified: tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java?rev=1221454&r1=1221453&r2=1221454&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
Tue Dec 20 19:32:07 2011
@@ -28,6 +28,8 @@ import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -147,33 +149,39 @@ public class JavaInterfaceIntrospectorIm
 
         // Check if any methods have disallowed annotations
         // Check if any private methods have illegal annotations that should be raised as
errors
-        Set<Method> methods = JavaIntrospectionHelper.getMethods(clazz);
-        for (Method method : methods) {
-            checkMethodAnnotations(method, javaInterface);
-        } // end for 
+        checkMethodAnnotations(clazz, javaInterface);
     } // end method introspectInterface
 
-    private void checkMethodAnnotations(Method method, JavaInterface javaInterface) throws
InvalidAnnotationException {
-        for ( Annotation a : method.getAnnotations() ) {
-            if( a instanceof Remotable ) {
-                // [JCA90053] @Remotable annotation cannot be on a method that is not a setter
method
-                if( !JavaIntrospectionHelper.isSetter(method) ) {
-                    throw new InvalidAnnotationException("[JCA90053] @Remotable annotation
present on an interface method" +
-                                                         " which is not a Setter method:
" + javaInterface.getName() + "/" + method.getName(), Remotable.class);
-                } // end if
-            } // end if		
-        } // end for
+    private void checkMethodAnnotations(Class clazz, JavaInterface javaInterface) throws
InvalidAnnotationException {
 
-        // Parameter annotations
-        for (Annotation[] parmAnnotations : method.getParameterAnnotations()) {
-            for (Annotation annotation : parmAnnotations) {
-                if (annotation instanceof Remotable ) {
-                    throw new InvalidAnnotationException("[JCA90053] @Remotable annotation
present on an interface method" +
-                                                         " parameter: " + javaInterface.getName()
+ "/" + method.getName(), Remotable.class);
-                } // end if
-            } // end for		
-        } // end for
-        method.getParameterAnnotations();
+        final Class _clazz = clazz;
+        Method[] declaredMethods = (Method[])AccessController.doPrivileged(new PrivilegedAction<Method[]>()
{
+            public Method[] run() {
+                return _clazz.getDeclaredMethods();
+            }
+        });
+
+        for (final Method method : declaredMethods) {
+            for ( Annotation a : method.getAnnotations() ) {
+                if( a instanceof Remotable ) {
+                    // [JCA90053] @Remotable annotation cannot be on a method that is not
a setter method
+                    if( !JavaIntrospectionHelper.isSetter(method) ) {
+                        throw new InvalidAnnotationException("[JCA90053] @Remotable annotation
present on an interface method" +
+                                                             " which is not a Setter method:
" + javaInterface.getName() + "/" + method.getName(), Remotable.class);
+                    } // end if
+                } // end if		
+            } // end for
+            
+            // Parameter annotations
+            for (Annotation[] parmAnnotations : method.getParameterAnnotations()) {
+                for (Annotation annotation : parmAnnotations) {
+                    if (annotation instanceof Remotable ) {
+                        throw new InvalidAnnotationException("[JCA90053] @Remotable annotation
present on an interface method" +
+                                                             " parameter: " + javaInterface.getName()
+ "/" + method.getName(), Remotable.class);
+                    } // end if
+                } // end for		
+            } // end for
+        }
     } // end method checkMethodAnnotations
 
     private Class<?>[] getActualTypes(Type[] types, Class<?>[] rawTypes, Map<String,
Type> typeBindings, boolean ignoreAsyncHolder) {

Modified: tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java?rev=1221454&r1=1221453&r2=1221454&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java
Tue Dec 20 19:32:07 2011
@@ -616,16 +616,6 @@ public final class JavaIntrospectionHelp
         return Class.forName(buf.toString(), false, componentType.getClassLoader());
     }
 
-    public static Set<Method> getMethods(Class<?> clazz) {
-        Set<Method> methods = new HashSet<Method>();
-        Method[] declaredMethods = clazz.getDeclaredMethods();
-        for (final Method declaredMethod : declaredMethods) {
-            methods.add(declaredMethod);
-        } // end for
-
-        return methods;
-    } // end method getMethods
-
     public static Set<Field> getPrivateFields(Class<?> clazz) {
         Set<Field> fields = new HashSet<Field>();
         Field[] declaredFields = clazz.getDeclaredFields();



Mime
View raw message