felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1691133 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: helper/FieldHandler.java metadata/ReferenceMetadata.java
Date Wed, 15 Jul 2015 06:59:52 GMT
Author: cziegeler
Date: Wed Jul 15 06:59:51 2015
New Revision: 1691133

URL: http://svn.apache.org/r1691133
Log:
FELIX-4957 : [DS][RFC-212] Various issues with field references

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java?rev=1691133&r1=1691132&r2=1691133&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/FieldHandler.java Wed Jul
15 06:59:51 2015
@@ -275,6 +275,15 @@ public class FieldHandler
         final Class<?> referenceType = ClassUtils.getClassFromComponentClassLoader(
                 this.componentClass, metadata.getInterface(), logger);
 
+        // ignore static fields
+        if ( Modifier.isStatic(f.getModifiers()))
+        {
+            logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must not be static",
new Object[]
+                    {metadata.getField(), this.componentClass}, null );
+        	valueType = ParamType.ignore;
+        	return f;
+        }
+
         // unary reference
         if ( !metadata.isMultiple() )
         {
@@ -380,6 +389,13 @@ public class FieldHandler
                 }
             }
         }
+        // static references only allowed for replace strategy
+        if ( metadata.isStatic() && !metadata.isReplace() )
+        {
+            logger.log( LogService.LOG_ERROR, "Update strategy for field {0} in component
{1} only allowed for non static field references.", new Object[]
+                    {metadata.getField(), this.componentClass}, null );
+            valueType = ParamType.ignore;
+        }
         return f;
     }
 
@@ -706,7 +722,7 @@ public class FieldHandler
         // no static fields
         if ( Modifier.isStatic( mod ) )
         {
-            return false;
+            return true;
         }
 
         // accept public and protected fields

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java?rev=1691133&r1=1691132&r2=1691133&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
Wed Jul 15 06:59:51 2015
@@ -721,15 +721,6 @@ public class ReferenceMetadata
                     throw componentMetadata.validationFailure( "Field value type must be
one of " + FIELD_VALUE_TYPE_VALID );
                 }
             }
-
-            // static references only allow replace strategy
-            if ( m_isStatic )
-            {
-                if ( ! m_field_option.equals(FIELD_STRATEGY_REPLACE) )
-                {
-                    throw componentMetadata.validationFailure( "Field strategy update not
allowed for static field references." );
-                }
-            }
         }
 
         m_validated = true;



Mime
View raw message