felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1691322 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: helper/FieldHandler.java manager/DependencyManager.java
Date Thu, 16 Jul 2015 07:04:22 GMT
Author: cziegeler
Date: Thu Jul 16 07:04:22 2015
New Revision: 1691322

URL: http://svn.apache.org/r1691322
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/manager/DependencyManager.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=1691322&r1=1691321&r2=1691322&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 Thu Jul
16 07:04:22 2015
@@ -645,26 +645,32 @@ public class FieldHandler
                     }
                 }
             }
-            // updated needs only be done, if reference is dynamic
-            // and the value type is map or tuple
+            // updated needs only be done, if the value type is map or tuple
             else if ( mType == METHOD_TYPE.UPDATED)
             {
-                if ( !this.metadata.isStatic()
-                     && (this.valueType == ParamType.map || this.valueType == ParamType.tuple
) )
-                {
-                    final Object obj = getValue(key, refPair);
-                    final Object oldObj = this.boundValues.put(refPair, obj);
-
-                    if ( metadata.isReplace() )
+            	if ( this.valueType == ParamType.map || this.valueType == ParamType.tuple )

+            	{
+                    if ( !this.metadata.isStatic() )
                     {
-                        this.setFieldValue(componentInstance, getReplaceCollection());
+	                    final Object obj = getValue(key, refPair);
+	                    final Object oldObj = this.boundValues.put(refPair, obj);
+	
+	                    if ( metadata.isReplace() )
+	                    {
+	                        this.setFieldValue(componentInstance, getReplaceCollection());
+	                    }
+	                    else
+	                    {
+	                        @SuppressWarnings("unchecked")
+	                        final Collection<Object> col = (Collection<Object>)this.getFieldValue(componentInstance);
+	                        col.add(obj);
+	                        col.remove(oldObj);
+	                    }
                     }
                     else
                     {
-                        @SuppressWarnings("unchecked")
-                        final Collection<Object> col = (Collection<Object>)this.getFieldValue(componentInstance);
-                        col.add(obj);
-                        col.remove(oldObj);
+                    	// if it's static we need to reactivate
+                    	return MethodResult.REACTIVATE;
                     }
                 }
             }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1691322&r1=1691321&r2=1691322&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
Thu Jul 16 07:04:22 2015
@@ -462,12 +462,18 @@ public class DependencyManager<S, T> imp
         public void modifiedService( ServiceReference<T> serviceReference, RefPair<S,
T> refPair, int trackingCount )
         {
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy
modified {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            boolean reactivate = false;
             if (isActive())
             {
-                m_componentManager.invokeUpdatedMethod( DependencyManager.this, refPair,
trackingCount );
+            	reactivate = m_componentManager.invokeUpdatedMethod( DependencyManager.this,
refPair, trackingCount );
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy
modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
             tracked( trackingCount );
+            if ( reactivate )
+            {
+                m_componentManager.deactivateInternal( ComponentConstants.DEACTIVATION_REASON_REFERENCE,
false, false );
+                m_componentManager.activateInternal( );
+            }
+            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy
modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
         }
 
         public void removedService( ServiceReference<T> serviceReference, RefPair<S,
T> refPair, int trackingCount )
@@ -563,13 +569,19 @@ public class DependencyManager<S, T> imp
         public void modifiedService( ServiceReference<T> serviceReference, RefPair<S,
T> refPair, int trackingCount )
         {
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant
modified {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            boolean reactivate = false;
             Collection<RefPair<S, T>> refs = this.refs.get();
             if (isActive() && refs.contains( refPair ))
             {
-                m_componentManager.invokeUpdatedMethod( DependencyManager.this, refPair,
trackingCount );
+                reactivate = m_componentManager.invokeUpdatedMethod( DependencyManager.this,
refPair, trackingCount );
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant
modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
             tracked( trackingCount );
+            if ( reactivate )
+            {
+                m_componentManager.deactivateInternal( ComponentConstants.DEACTIVATION_REASON_REFERENCE,
false, false );
+                m_componentManager.activateInternal( );
+            }
+            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant
modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
         }
 
         public void removedService( ServiceReference<T> serviceReference, RefPair<S,
T> refPair, int trackingCount )



Mime
View raw message