Added two patches suggested by Pierre and Arjun to fix an issue with service dependencies that use a filter, where the filter can return services that are of a different type than the specified type. Also added some logging.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@738105 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java b/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
index 9a53bdf..2da0a23 100644
--- a/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
+++ b/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
@@ -173,6 +173,11 @@
 
     public Object addingService(ServiceReference ref) {
         Object service = m_context.getService(ref);
+        // first check to make sure the service is actually an instance of our service
+        if (!m_trackedServiceName.isInstance(service)) {
+            return null;
+        }
+            
         // we remember these for future reference, needed for required service callbacks
         m_reference = ref;
         m_serviceInstance = service;
diff --git a/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java b/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java
index b2848d1..5fbcd35 100644
--- a/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java
+++ b/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceImpl.java
@@ -630,6 +630,7 @@
                 wrapper.setServiceRegistration(registration);
             }
             catch (IllegalArgumentException iae) {
+                m_logger.log(Logger.LOG_ERROR, "Could not register service " + m_serviceInstance, iae);
                 // set the registration to an illegal state object, which will make all invocations on this
                 // wrapper fail with an ISE (which also occurs when the SR becomes invalid)
                 wrapper.setIllegalState();