Author: gpetracek
Date: Mon Nov 29 11:05:03 2010
New Revision: 1040063

URL: http://svn.apache.org/viewvc?rev=1040063&view=rev
Log:
OWB-474 quickfix

Modified:
    
openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java

Modified: 
openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java?rev=1040063&r1=1040062&r2=1040063&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
 (original)
+++ 
openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
 Mon Nov 29 11:05:03 2010
@@ -45,7 +45,7 @@ public class StandaloneResourceInjection
 
     @Override
     public <X, T extends Annotation> X 
getResourceReference(ResourceReference<X, T> resourceReference)
-    {        
+    {
         if(resourceReference.supports(Resource.class))
         {         
             Resource resource = 
resourceReference.getAnnotation(Resource.class);
@@ -77,40 +77,48 @@ public class StandaloneResourceInjection
     @Override
     public void injectJavaEEResources(Object managedBeanInstance) throws 
Exception
     {
-        Field[] fields = 
SecurityUtil.doPrivilegedGetDeclaredFields(managedBeanInstance.getClass());
-        for(Field field : fields)
+        Class currentClass = managedBeanInstance.getClass();
+
+        while (currentClass != null && 
!Object.class.getName().equals(currentClass.getName()))
         {
-            if(!field.isAnnotationPresent(Produces.class))
+            Field[] fields = 
SecurityUtil.doPrivilegedGetDeclaredFields(currentClass);
+
+            for(Field field : fields)
             {
-                if(!Modifier.isStatic(field.getModifiers()))
+                if(!field.isAnnotationPresent(Produces.class))
                 {
-                    Annotation ann = 
AnnotationUtil.hasOwbInjectableResource(field.getDeclaredAnnotations());        
        
-                    if(ann != null)
+                    if(!Modifier.isStatic(field.getModifiers()))
                     {
-                        @SuppressWarnings("unchecked")
-                        ResourceReference<Object, ?> resourceRef = new 
ResourceReference(field.getDeclaringClass(), field.getName(), field.getType(), 
ann);
-                        boolean acess = field.isAccessible();
-                        try
-                        {
-                            SecurityUtil.doPrivilegedSetAccessible(field, 
true);
-                            field.set(managedBeanInstance, 
getResourceReference(resourceRef));
-                            
-                        }
-                        catch(Exception e)
+                        Annotation ann = 
AnnotationUtil.hasOwbInjectableResource(field.getDeclaredAnnotations());
+                        if(ann != null)
                         {
-                            logger.error(OWBLogConst.ERROR_0025, e, field);
-                            throw new 
WebBeansException(MessageFormat.format(logger.getTokenString(OWBLogConst.ERROR_0025),
 field), e);
-                            
+                            @SuppressWarnings("unchecked")
+                            ResourceReference<Object, ?> resourceRef = new 
ResourceReference(field.getDeclaringClass(), field.getName(), field.getType(), 
ann);
+                            boolean acess = field.isAccessible();
+                            try
+                            {
+                                SecurityUtil.doPrivilegedSetAccessible(field, 
true);
+                                field.set(managedBeanInstance, 
getResourceReference(resourceRef));
+
+                            }
+                            catch(Exception e)
+                            {
+                                logger.error(OWBLogConst.ERROR_0025, e, field);
+                                throw new 
WebBeansException(MessageFormat.format(logger.getTokenString(OWBLogConst.ERROR_0025),
 field), e);
+
+                            }
+                            finally
+                            {
+                                SecurityUtil.doPrivilegedSetAccessible(field, 
acess);
+                            }
                         }
-                        finally
-                        {
-                            SecurityUtil.doPrivilegedSetAccessible(field, 
acess);
-                        }                        
-                    }                    
-                }                
+                    }
+                }
             }
-        }    
-     }
+
+            currentClass = currentClass.getSuperclass();
+        }
+    }
 
     @Override
     public void clear()


Reply via email to