tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r652566 - in /incubator/tuscany/java/sca: itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/ modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/ modules/implementation-java/src/m...
Date Thu, 01 May 2008 16:31:00 GMT
Author: slaws
Date: Thu May  1 09:30:59 2008
New Revision: 652566

URL: http://svn.apache.org/viewvc?rev=652566&view=rev
Log:
TUSCANY-2272 Thanks for the patch Vamsi

Modified:
    incubator/tuscany/java/sca/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.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/DestroyProcessor.java
    incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
    incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
    incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java

Modified: incubator/tuscany/java/sca/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java?rev=652566&r1=652565&r2=652566&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java
(original)
+++ incubator/tuscany/java/sca/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java
Thu May  1 09:30:59 2008
@@ -119,7 +119,7 @@
      * Shuts down the Event Processor
      */
     @Destroy
-    protected void shutdown()
+    public void shutdown()
     {
         System.out.println("Shutting down the EventProcessor");
         

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=652566&r1=652565&r2=652566&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
Thu May  1 09:30:59 2008
@@ -100,6 +100,14 @@
             }
         }
 
+        // 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);
+            }
+        }
+
         Class superClass = clazz.getSuperclass();
         if (superClass != null) {
             visitSuperClass(superClass, type);

Modified: incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.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/DestroyProcessor.java?rev=652566&r1=652565&r2=652566&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
Thu May  1 09:30:59 2008
@@ -53,8 +53,8 @@
         if (type.getDestroyMethod() != null) {
             throw new DuplicateDestructorException("More than one destructor found on implementation");
         }
-        if (Modifier.isProtected(method.getModifiers())) {
-            method.setAccessible(true);
+        if (!Modifier.isPublic(method.getModifiers())) {
+            throw new IllegalDestructorException("Destructor must be a public method. Invalid
annotation @Destroy found on "+method);
         }
         type.setDestroyMethod(method);
     }

Modified: incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.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/InitProcessor.java?rev=652566&r1=652565&r2=652566&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
Thu May  1 09:30:59 2008
@@ -53,8 +53,8 @@
         if (type.getInitMethod() != null) {
             throw new DuplicateInitException("More than one initializer found on implementaton");
         }
-        if (Modifier.isProtected(method.getModifiers())) {
-            method.setAccessible(true);
+        if (!Modifier.isPublic(method.getModifiers())) {
+            throw new IllegalInitException("Initializer must be a public method. Invalid
annotation @Init found on "+method);
         }
         type.setInitMethod(method);
     }

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=652566&r1=652565&r2=652566&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
Thu May  1 09:30:59 2008
@@ -548,4 +548,17 @@
         buf.append(getSignature(componentType));
         return Class.forName(buf.toString(), false, componentType.getClassLoader());
     }
+
+    public static Set<Method> getPrivateMethods(Class clazz) {
+        Set<Method> methods = new HashSet<Method>();
+        Method[] declaredMethods = clazz.getDeclaredMethods();
+        for (final Method declaredMethod : declaredMethods) {
+            int modifiers = declaredMethod.getModifiers();
+            if(Modifier.isPrivate(modifiers)) {
+                methods.add(declaredMethod);
+            }
+        }
+        
+        return methods;
+    }
 }

Modified: incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java?rev=652566&r1=652565&r2=652566&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
Thu May  1 09:30:59 2008
@@ -71,11 +71,22 @@
         }
     }
 
+    public void testProtectedDestroy() throws Exception {
+        DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Method method = Bar.class.getDeclaredMethod("protectedDestroy");
+        try {
+            processor.visitMethod(method, type);
+            fail();
+        } catch (IllegalDestructorException e) {
+            // expected
+        }
+    }
 
-    public void testBadDestroy2() throws Exception {
+    public void testPrivateDestroy() throws Exception {
         DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
         JavaImplementation type = javaImplementationFactory.createJavaImplementation();
-        Method method = Bar.class.getDeclaredMethod("badDestroy2");
+        Method method = Bar.class.getDeclaredMethod("privateDestroy");
         try {
             processor.visitMethod(method, type);
             fail();
@@ -106,10 +117,13 @@
         public void badDestroy(String foo) {
         }
 
+        @Destroy
+        protected void protectedDestroy(){
+        }
 
         @Destroy
-        public String badDestroy2() {
-            return null;
+        private void privateDestroy(){
         }
+
     }
 }

Modified: incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java?rev=652566&r1=652565&r2=652566&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java
Thu May  1 09:30:59 2008
@@ -72,7 +72,30 @@
             // expected
         }
     }
+    
+    public void testProtectedInit() throws Exception {
+        InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Method method = InitProcessorTestCase.Bar.class.getDeclaredMethod("protectedInit");
+        try {
+            processor.visitMethod(method, type);
+            fail();
+        } catch (IllegalInitException e) {
+            // expected
+        }
+    }
 
+    public void testPrivateInit() throws Exception {
+        InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Method method = InitProcessorTestCase.Bar.class.getDeclaredMethod("privateInit");
+        try {
+            processor.visitMethod(method, type);
+            fail();
+        } catch (IllegalInitException e) {
+            // expected
+        }
+    }
 
     public void testBadInit2() throws Exception {
         InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
@@ -105,11 +128,18 @@
         @Init
         public void badInit(String foo) {
         }
-
-
+        
         @Init
         public String badInit2() {
             return null;
+        }        
+
+        @Init
+        protected void protectedInit() {
+        }
+
+        @Init
+        private void privateInit() {
         }
     }
 }



Mime
View raw message