felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1572346 - /felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DependencyImpl.java
Date Wed, 26 Feb 2014 23:31:21 GMT
Author: pderop
Date: Wed Feb 26 23:31:21 2014
New Revision: 1572346

URL: http://svn.apache.org/r1572346
Log:
Added support for callback instance

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DependencyImpl.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DependencyImpl.java?rev=1572346&r1=1572345&r2=1572346&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DependencyImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DependencyImpl.java Wed
Feb 26 23:31:21 2014
@@ -20,7 +20,8 @@ public class DependencyImpl implements D
 	protected String m_autoConfigInstance;
 	protected boolean m_autoConfigInvoked;
     protected volatile boolean m_isStarted; // volatile because accessed by getState method
-
+    private Object m_callbackInstance;
+    
 	// TODO when we start injecting the "highest" one, this needs to be sorted at
 	// some point in time (note that we could choose to only do that if the dependency is
 	// actually injected (auto config is on for it)
@@ -40,6 +41,7 @@ public class DependencyImpl implements D
 		m_autoConfig = prototype.m_autoConfig;
 		m_autoConfigInstance = prototype.m_autoConfigInstance;
 		m_autoConfigInvoked = prototype.m_autoConfigInvoked;
+		m_callbackInstance = prototype.m_callbackInstance;
 	}
 	
 	public synchronized void add(final Event e) {
@@ -152,9 +154,18 @@ public class DependencyImpl implements D
 	}
 	
 	public Dependency setCallbacks(String add, String change, String remove) {
+		return setCallbacks(null, add, change, remove);		
+	}
+	
+	public Dependency setCallbacks(Object instance, String add, String remove) {
+		return setCallbacks(instance, add, null, remove);
+	}
+	
+	public Dependency setCallbacks(Object instance, String add, String change, String remove)
{
         if ((add != null || change != null || remove != null) && !m_autoConfigInvoked)
{
             setAutoConfig(false);
         }
+        m_callbackInstance = instance;
 		m_add = add;
 		m_change = change;
 		m_remove = remove;
@@ -186,8 +197,11 @@ public class DependencyImpl implements D
 	}
 	
 	public Object[] getInstances() {
-		// TODO what instance(s) should be called should be configurable
-		return m_component.getInstances();
+        if (m_callbackInstance == null) {
+        	return m_component.getInstances();
+        } else {
+            return new Object[]{m_callbackInstance};
+        }
 	}
 
 	public void invoke(String method, Event e) {



Mime
View raw message