felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1727827 - in /felix/sandbox/pderop/dependencymanager-lambda: org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/ org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambd...
Date Sun, 31 Jan 2016 14:55:22 GMT
Author: pderop
Date: Sun Jan 31 14:55:22 2016
New Revision: 1727827

URL: http://svn.apache.org/viewvc?rev=1727827&view=rev
Log:
Log an error when a method reference is specified on a class that is not part of the composition
of component implementations.

Modified:
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleAdapterBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleDependencyBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java
    felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java?rev=1727827&r1=1727826&r2=1727827&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
Sun Jan 31 14:55:22 2016
@@ -59,5 +59,5 @@ public class Activator extends Dependenc
         component(comp -> comp
             .impl(Configurator.class)
             .withSrv(ConfigurationAdmin.class));
-    }    
+    }
 }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleAdapterBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleAdapterBuilderImpl.java?rev=1727827&r1=1727826&r2=1727827&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleAdapterBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleAdapterBuilderImpl.java
Sun Jan 31 14:55:22 2016
@@ -230,11 +230,11 @@ public class BundleAdapterBuilderImpl im
         checkHasNoReflectionCallbacks();
         List<MethodRef<Object>> list = m_refs.computeIfAbsent(cbType, l ->
new ArrayList<>());
         list.add((instance, component, bundle) -> {
-            Stream.of(component.getInstances()).forEach(inst -> {
-                if (Helpers.getClass(inst).equals(type)) {
-                    ref.accept((U) inst, component, bundle);
-                }
-            });
+            Object componentImpl = Stream.of(component.getInstances())
+                .filter(impl -> Helpers.getClass(impl).equals(type))
+                .findFirst()
+                .orElseThrow(() -> new IllegalStateException("The method reference " +
ref + " does not match any available component impl classes."));           
+            ref.accept((U) componentImpl, component, bundle);
         });
         return this;
     }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleDependencyBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleDependencyBuilderImpl.java?rev=1727827&r1=1727826&r2=1727827&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleDependencyBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleDependencyBuilderImpl.java
Sun Jan 31 14:55:22 2016
@@ -308,11 +308,11 @@ public class BundleDependencyBuilderImpl
 		if (! m_autoConfigInvoked) m_autoConfig = false;
 		List<MethodRef<Object>> list = m_refs.computeIfAbsent(cbType, l -> new ArrayList<>());
 		list.add((instance, component, bundle) -> {
-            Stream.of(component.getInstances()).forEach(inst -> {
-                if (Helpers.getClass(inst).equals(type)) {
-                    ref.accept((T) inst, component, bundle);
-                }
-            });
+            Object componentImpl = Stream.of(component.getInstances())
+                .filter(impl -> Helpers.getClass(impl).equals(type))
+                .findFirst()
+                .orElseThrow(() -> new IllegalStateException("The method reference " +
ref + " does not match any available component impl classes."));           
+            ref.accept((T) componentImpl, component, bundle);
 		});
 		return this;
 	}

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java?rev=1727827&r1=1727826&r2=1727827&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
Sun Jan 31 14:55:22 2016
@@ -676,11 +676,11 @@ public class ComponentBuilderImpl implem
         }
         List<MethodRef<Object>> list = m_refs.computeIfAbsent(cbType, l ->
new ArrayList<>());
         list.add((instance, component) -> {
-            Stream.of(component.getInstances()).forEach(inst -> {
-                if (Helpers.getClass(inst).equals(type)) {
-                    callback.accept((U) inst, component);
-                }
-            });
+            Object componentImpl = Stream.of(component.getInstances())
+                .filter(impl -> Helpers.getClass(impl).equals(type))
+                .findFirst()
+                .orElseThrow(() -> new IllegalStateException("The method reference " +
callback + " does not match any available component impl classes."));   
+            callback.accept((U) componentImpl, component);
         });
         return this;
     }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java?rev=1727827&r1=1727826&r2=1727827&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ConfigurationDependencyBuilderImpl.java
Sun Jan 31 14:55:22 2016
@@ -139,11 +139,11 @@ public class ConfigurationDependencyBuil
         m_hasMethodRefs = true;
         m_hasComponentCallbackRefs = true;
         m_refs.add((instance, component, props) -> {
-            Stream.of(component.getInstances()).forEach(inst -> {
-                if (Helpers.getClass(inst).equals(type)) {
-                    ref.accept((T) inst, component, props);
-                }
-            });
+            Object componentImpl = Stream.of(component.getInstances())
+                .filter(impl -> Helpers.getClass(impl).equals(type))
+                .findFirst()
+                .orElseThrow(() -> new IllegalStateException("The method reference " +
ref + " does not match any available component impl classes."));           
+            ref.accept((T) componentImpl, component, props);
         });
         return this;
     }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java?rev=1727827&r1=1727826&r2=1727827&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/FactoryPidAdapterBuilderImpl.java
Sun Jan 31 14:55:22 2016
@@ -143,11 +143,11 @@ public class FactoryPidAdapterBuilderImp
         checkHasNoReflectionCallbacks();
         m_hasMethodRefs = true;
         m_refs.add((instance, component, props) -> {
-            Stream.of(component.getInstances()).forEach(inst -> {
-                if (Helpers.getClass(inst).equals(type)) {
-                    ref.accept((U) inst, component, props);
-                }
-            });
+            Object componentImpl = Stream.of(component.getInstances())
+                .filter(impl -> Helpers.getClass(impl).equals(type))
+                .findFirst()
+                .orElseThrow(() -> new IllegalStateException("The method reference " +
ref + " does not match any available component impl classes."));
+            ref.accept((U) componentImpl, component, props);
         });
         return this;
     }

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java?rev=1727827&r1=1727826&r2=1727827&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceCallbacksBuilderImpl.java
Sun Jan 31 14:55:22 2016
@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.stream.Stream;
 
 import org.apache.felix.dm.Component;
@@ -38,7 +39,7 @@ import org.apache.felix.dm.lambda.callba
 import org.osgi.framework.ServiceReference;
 
 /**
- * Dependency Callbacks management.
+ * Service Dependency Callback management.
  *
  * @param <S> the type of the service dependency
  * @param <B> the type of the sub-classes which may extend this class
@@ -527,12 +528,12 @@ public class ServiceCallbacksBuilderImpl
        requiresNoCallbacks();
        if (! m_autoConfigInvoked) m_autoConfig = false;
        List<MethodRef<Object, S>> list = m_refs.computeIfAbsent(cbType, l ->
new ArrayList<>());
-       list.add((instance, component, sref, service) -> {
-           Stream.of(component.getInstances()).forEach(inst -> {
-               if (Helpers.getClass(inst).equals(type)) {
-                   ref.accept((I) inst, component, sref, service);
-               }
-           });
+       list.add((instance, component, sref, service) -> {           
+           Object componentImpl = Stream.of(component.getInstances())
+               .filter(impl -> Helpers.getClass(impl).equals(type))
+               .findFirst()
+               .orElseThrow(() -> new IllegalStateException("The method reference " +
ref + " does not match any available component impl classes."));           
+           ref.accept((I) componentImpl, component, sref, service);           
        });
        return (B) this;
     }
@@ -551,11 +552,11 @@ public class ServiceCallbacksBuilderImpl
        requiresNoCallbacks();
        if (! m_autoConfigInvoked) m_autoConfig = false;
        m_swapRefs.add((instance, component, oref, oservice, nref, nservice) -> {
-           Stream.of(component.getInstances()).forEach(componentInstance -> {
-               if (Helpers.getClass(componentInstance).equals(type)) {
-                   ref.accept((I) componentInstance, component, oref, oservice, nref, nservice);
-               }
-           });
+           Object componentImpl = Stream.of(component.getInstances())
+               .filter(impl -> Helpers.getClass(impl).equals(type))
+               .findFirst()
+               .orElseThrow(() -> new IllegalStateException("The method reference " +
ref + " does not match any available component impl classes."));
+           ref.accept((I) componentImpl, component, oref, oservice, nref, nservice);
        });
        return (B) this;
     }



Mime
View raw message