felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1035252 - in /felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm: ./ impl/ impl/dependencies/
Date Mon, 15 Nov 2010 12:52:59 GMT
Author: marrs
Date: Mon Nov 15 12:52:58 2010
New Revision: 1035252

URL: http://svn.apache.org/viewvc?rev=1035252&view=rev
Log:
Work in progress, internal refactorings and bugfixes.

Added:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java
      - copied, changed from r1022558, felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
Removed:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/Component.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/BundleDependencyImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ResourceDependencyImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/Component.java?rev=1035252&r1=1035251&r2=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/Component.java (original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/Component.java Mon
Nov 15 12:52:58 2010
@@ -255,6 +255,8 @@ public interface Component {
 	 */
 	public Object[] getCompositionInstances();
 	
+    public void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures,
Object[][] parameters);
+	
 	/**
 	 * Returns the dependency manager associated with this component.
 	 */

Copied: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java
(from r1022558, felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java)
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java?p2=felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java&p1=felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java&r1=1022558&r2=1035252&rev=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java
Mon Nov 15 12:52:58 2010
@@ -1,4 +1,4 @@
-package org.apache.felix.dm.impl;
+package org.apache.felix.dm;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java?rev=1035252&r1=1035251&r2=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
Mon Nov 15 12:52:58 2010
@@ -40,6 +40,7 @@ import org.apache.felix.dm.Dependency;
 import org.apache.felix.dm.DependencyActivation;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.DependencyService;
+import org.apache.felix.dm.InvocationUtil;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
@@ -484,7 +485,7 @@ public class ComponentImpl implements Co
 	}
 
 	public String toString() {
-	    return "ServiceImpl[" + m_serviceName + " " + m_implementation + "]";
+	    return this.getClass().getSimpleName() + "[" + m_serviceName + " " + m_implementation
+ "]";
 	}
 
 	public synchronized Dictionary getServiceProperties() {
@@ -1007,10 +1008,12 @@ public class ComponentImpl implements Co
     }
 
     private void unconfigureServices(State state) {
+        System.err.println("unconfigureServices " + state);
         Iterator i = state.getDependencies().iterator();
         while (i.hasNext()) {
             Dependency dependency = (Dependency) i.next();
             if (dependency.isRequired()) {
+                System.err.println("unconfigureServices invokeremoved " + dependency);
                 dependency.invokeRemoved(this);
             }
 //            if (dependency instanceof ServiceDependencyImpl) {

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java?rev=1035252&r1=1035251&r2=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
Mon Nov 15 12:52:58 2010
@@ -26,6 +26,7 @@ import java.util.Hashtable;
 import java.util.List;
 
 import org.apache.felix.dm.DependencyManager;
+import org.apache.felix.dm.InvocationUtil;
 import org.apache.felix.dm.PropertyMetaData;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.ComponentStateListener;

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java?rev=1035252&r1=1035251&r2=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
Mon Nov 15 12:52:58 2010
@@ -23,10 +23,10 @@ import java.util.Dictionary;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.felix.dm.Dependency;
-import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.ComponentStateListener;
+import org.apache.felix.dm.Dependency;
+import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.ServiceRegistration;
 
 /**
@@ -253,6 +253,10 @@ public class FilterService implements Co
         m_service.stop();
     }
     
+    public void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures,
Object[][] parameters) {
+        m_service.invokeCallbackMethod(instances, methodName, signatures, parameters);
+    }
+    
     public Object[] getCompositionInstances() {
         return m_service.getCompositionInstances();
     }

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/BundleDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/BundleDependencyImpl.java?rev=1035252&r1=1035251&r2=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/BundleDependencyImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/BundleDependencyImpl.java
Mon Nov 15 12:52:58 2010
@@ -28,8 +28,8 @@ import org.apache.felix.dm.BundleDepende
 import org.apache.felix.dm.Dependency;
 import org.apache.felix.dm.DependencyService;
 import org.apache.felix.dm.ComponentDependencyDeclaration;
+import org.apache.felix.dm.InvocationUtil;
 import org.apache.felix.dm.impl.DefaultNullObject;
-import org.apache.felix.dm.impl.InvocationUtil;
 import org.apache.felix.dm.impl.Logger;
 import org.apache.felix.dm.tracker.BundleTracker;
 import org.apache.felix.dm.tracker.BundleTrackerCustomizer;

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ResourceDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ResourceDependencyImpl.java?rev=1035252&r1=1035251&r2=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ResourceDependencyImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ResourceDependencyImpl.java
Mon Nov 15 12:52:58 2010
@@ -28,11 +28,11 @@ import java.util.Properties;
 import org.apache.felix.dm.Dependency;
 import org.apache.felix.dm.DependencyActivation;
 import org.apache.felix.dm.DependencyService;
+import org.apache.felix.dm.InvocationUtil;
 import org.apache.felix.dm.ResourceDependency;
 import org.apache.felix.dm.ResourceHandler;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.ComponentDependencyDeclaration;
-import org.apache.felix.dm.impl.InvocationUtil;
 import org.apache.felix.dm.impl.Logger;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java?rev=1035252&r1=1035251&r2=1035252&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java
Mon Nov 15 12:52:58 2010
@@ -31,12 +31,14 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.felix.dm.Component;
 import org.apache.felix.dm.ComponentDependencyDeclaration;
 import org.apache.felix.dm.Dependency;
 import org.apache.felix.dm.DependencyService;
+import org.apache.felix.dm.InvocationUtil;
 import org.apache.felix.dm.ServiceDependency;
+import org.apache.felix.dm.ServiceUtil;
 import org.apache.felix.dm.impl.DefaultNullObject;
-import org.apache.felix.dm.impl.InvocationUtil;
 import org.apache.felix.dm.impl.Logger;
 import org.apache.felix.dm.tracker.ServiceTracker;
 import org.apache.felix.dm.tracker.ServiceTrackerCustomizer;
@@ -463,6 +465,8 @@ public class ServiceDependencyImpl exten
     public void removedService(ServiceReference ref, Object service) {
         boolean makeUnavailable = makeUnavailable();
         
+        System.out.println("removedService: " + makeUnavailable + " for " + ServiceUtil.toString(ref));
+        
         Object[] services;
         synchronized (this) {
             services = m_services.toArray();
@@ -488,6 +492,8 @@ public class ServiceDependencyImpl exten
 
     public void invokeAdded(DependencyService dependencyService, ServiceReference reference,
Object service) {
         invoke(dependencyService, reference, service, m_callbackAdded);
+        //marrs
+        m_refs.add(reference);
     }
     
     public void invokeChanged(DependencyService dependencyService, ServiceReference reference,
Object service) {
@@ -496,13 +502,21 @@ public class ServiceDependencyImpl exten
 
     public void invokeRemoved(DependencyService dependencyService, ServiceReference reference,
Object service) {
         invoke(dependencyService, reference, service, m_callbackRemoved);
+        //marrs
+        m_refs.remove(reference);
     }
 
     public void invoke(DependencyService dependencyService, ServiceReference reference, Object
service, String name) {
         if (name != null) {
             dependencyService.invokeCallbackMethod(getCallbackInstances(dependencyService),
name, 
-                new Class[][] {{ServiceReference.class, m_trackedServiceName}, {ServiceReference.class,
Object.class}, {ServiceReference.class}, {m_trackedServiceName}, {Object.class}, {}, {Map.class,
m_trackedServiceName}},
-                new Object[][] {{reference, service}, {reference, service}, {reference},
{service}, {service}, {}, {new ServicePropertiesMap(reference), service}}    
+                new Class[][] {
+                    {Component.class, ServiceReference.class, m_trackedServiceName}, {Component.class,
ServiceReference.class, Object.class}, {Component.class, ServiceReference.class}, {Component.class,
m_trackedServiceName}, {Component.class, Object.class}, {Component.class}, {Component.class,
Map.class, m_trackedServiceName},
+                    {ServiceReference.class, m_trackedServiceName}, {ServiceReference.class,
Object.class}, {ServiceReference.class}, {m_trackedServiceName}, {Object.class}, {}, {Map.class,
m_trackedServiceName}
+                },
+                new Object[][] {
+                    {dependencyService, reference, service}, {dependencyService, reference,
service}, {dependencyService, reference}, {dependencyService, service}, {dependencyService,
service}, {dependencyService}, {dependencyService, new ServicePropertiesMap(reference), service},
+                    {reference, service}, {reference, service}, {reference}, {service}, {service},
{}, {new ServicePropertiesMap(reference), service}
+                }    
             );
         }
     }
@@ -795,28 +809,48 @@ public class ServiceDependencyImpl exten
         return "service";
     }
 
+    private List m_refs = new ArrayList();
+    
     public void invokeAdded(DependencyService service) {
         ServiceReference[] refs = m_tracker.getServiceReferences();
         if (refs != null) {
             for (int i = 0; i < refs.length; i++) {
                 ServiceReference sr = refs[i];
                 Object svc = m_context.getService(sr);
+                System.out.println("invokeAdded " + i + " " + ServiceUtil.toString(sr));
                 invokeAdded(service, sr, svc);
+                
+                //marrs
+                m_refs.add(sr);
             }
         }
         m_references = refs;
+        
     }
     
     public void invokeRemoved(DependencyService service) {
         ServiceReference[] refs = m_references;
+        
+        
         if (refs != null) {
+            //marrs
+            refs = (ServiceReference[]) m_refs.toArray(refs);
+            
             for (int i = 0; i < refs.length; i++) {
                 ServiceReference sr = refs[i];
                 Object svc = m_context.getService(sr);
+                System.out.println("invokeRemoved " + i + " " + ServiceUtil.toString(sr));
+                if (sr.getBundle() == null) {
+                    System.out.println("invokeRemoved OLD SHIT .. SKIPPING .. not");
+//                    break;
+                }
                 invokeRemoved(service, sr, svc);
             }
         }
         m_references = null;
+        
+        //marrs
+        m_refs.clear();
     }
 
     public Dictionary getProperties() {
@@ -867,4 +901,6 @@ public class ServiceDependencyImpl exten
         m_propagateCallbackMethod = method;
         return this;
     }
+    
+    // TODO add equals and hashCode methods, so you can compare dependencies
 }



Mime
View raw message