Author: pderop
Date: Sun Feb 28 19:11:09 2016
New Revision: 1732779
URL: http://svn.apache.org/viewvc?rev=1732779&view=rev
Log:
Finished to apply the recommendations made by Jan Willen regarding the new
dm-lambda library.
By default, dependencies are optional, like in the original DM API.
Removed ambiguous methods in ComponentBuilder interface
(initInstance/startInstance ...).
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/bnd.bnd
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterAndConsumerTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithCallbackInstanceTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithInstanceBoundDependencyTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AspectChainTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AutoConfigTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/CFDependencyTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ComponentTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/DynamicProxyAspectTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryConfigurationAdapterTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryInjectedWithConfigurationBeforeTheCreateMethod.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleExtraDependencyTest2.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleServiceDependencyTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyInjectionTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/TemporalServiceDependencyTest.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/dictionary.bndrun
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/DeviceAccessImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/DictionaryImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceDependencyBuilder.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/CbService.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/callbacks/InstanceCb.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/BundleDependencyBuilderImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/Helpers.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ServiceDependencyBuilderImpl.java
felix/trunk/dependencymanager/release/resources/changelog.txt
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java
Sun Feb 28 19:11:09 2016
@@ -232,9 +232,7 @@ public class ScenarioControllerImpl impl
private void forEachScenarioBundle(List<String> tests, Consumer<Bundle>
consumer) {
tests.stream().forEach(test -> {
Optional<Bundle> bundle = Stream.of(m_bctx.getBundles()).filter(b
-> b.getSymbolicName().equals(test)).findFirst();
- bundle.ifPresent(b -> {
- consumer.accept(b);
- });
+ bundle.ifPresent(consumer::accept);
});
}
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/bnd.bnd
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/bnd.bnd?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/bnd.bnd
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/bnd.bnd
Sun Feb 28 19:11:09 2016
@@ -44,8 +44,11 @@ Test-Cases: \
javac.source: 1.8
javac.target: 1.8
-tester: biz.aQute.junit
+
+# all tests are configured to assume that dependencies are required by default
-runproperties: \
org.apache.felix.dependencymanager.loglevel=2,\
+
org.apache.felix.dependencymanager.lambda.defaultRequiredDependency=org.apache.felix.dm.lambda.itest,\
org.apache.felix.log.maxSize=100000,\
org.apache.felix.log.storeDebug=true,\
gosh.args=--noshutdown
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterAndConsumerTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterAndConsumerTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterAndConsumerTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterAndConsumerTest.java
Sun Feb 28 19:11:09 2016
@@ -35,7 +35,7 @@ public class AdapterAndConsumerTest exte
Ensure e = new Ensure();
Component provider =
component(m).provides(OriginalService.class).impl(new
ServiceProvider(e)).build();
- Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(AdaptedService.class).build();
+ Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(AdaptedService.class, true).build();
Component adapter = adapter(m,
OriginalService.class).provides(AdaptedService.class).impl(ServiceAdapter.class).build();
// add the provider and the adapter
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithCallbackInstanceTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithCallbackInstanceTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithCallbackInstanceTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithCallbackInstanceTest.java
Sun Feb 28 19:11:09 2016
@@ -41,7 +41,7 @@ public class AdapterWithCallbackInstance
ServiceProvider serviceProvider = new ServiceProvider(e);
Component provider =
component(m).provides(OriginalService.class).impl(serviceProvider).build();
- Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(AdaptedService.class).build();
+ Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(AdaptedService.class, true).build();
ServiceAdapterCallbackInstance callbackInstance = new
ServiceAdapterCallbackInstance(e);
Component adapter = adapter(m, OriginalService.class)
@@ -82,7 +82,7 @@ public class AdapterWithCallbackInstance
ServiceProvider serviceProvider = new ServiceProvider(e);
Component provider =
component(m).provides(OriginalService.class).impl(serviceProvider).build();
- Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(AdaptedService.class).build();
+ Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(AdaptedService.class, true).build();
ServiceAdapterCallbackInstance callbackInstance = new
ServiceAdapterCallbackInstance(e);
Component adapter = adapter(m, OriginalService.class, adp -> adp
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithInstanceBoundDependencyTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithInstanceBoundDependencyTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithInstanceBoundDependencyTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithInstanceBoundDependencyTest.java
Sun Feb 28 19:11:09 2016
@@ -38,7 +38,7 @@ public class AdapterWithInstanceBoundDep
Component sp = component(m).provides(ServiceInterface.class).impl(new
ServiceProvider(e)).build();
Component sp2 =
component(m).provides(ServiceInterface2.class).impl(new
ServiceProvider2(e)).build();
- Component sc = component(m).impl(new
ServiceConsumer(e)).autoAdd(false).withSvc(ServiceInterface3.class).build();
+ Component sc = component(m).impl(new
ServiceConsumer(e)).autoAdd(false).withSvc(ServiceInterface3.class,
true).build();
Component sa = adapter(m,
ServiceInterface.class).provides(ServiceInterface3.class).impl(new
ServiceAdapter(e)).build();
m.add(sc);
m.add(sp);
@@ -106,7 +106,7 @@ public class AdapterWithInstanceBoundDep
}
public void init() {
m_ensure.step(1);
- component(m_component, c->c.withSvc(ServiceInterface2.class));
+ component(m_component, c->c.withSvc(ServiceInterface2.class,
true));
}
public void start() {
m_ensure.step(2);
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AdapterWithModifiedInstanceBoundDependencyTest.java
Sun Feb 28 19:11:09 2016
@@ -117,7 +117,7 @@ public class AdapterWithModifiedInstance
Component a = component(m).impl(new
AImpl(e)).provides(A.class).properties(foo -> "bar").build();
Component b = adapter(m, A.class).provides(B.class).impl(new
BImpl(e)).add("addA").change("changeA").remove("removeA").build();
- Component c = component(m).impl(new
CImpl()).provides(C.class).withSvc(A.class, "(foo=bar)").build();
+ Component c = component(m).impl(new
CImpl()).provides(C.class).withSvc(A.class, "(foo=bar)", true).build();
m.add(a);
m.add(c);
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AspectChainTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AspectChainTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AspectChainTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AspectChainTest.java
Sun Feb 28 19:11:09 2016
@@ -35,7 +35,7 @@ public class AspectChainTest extends Tes
Ensure e = new Ensure();
// create a service provider and consumer
Component sp = component(m).impl(new
ServiceProvider(e)).provides(ServiceInterface.class).build();
- Component sc = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class).build();
+ Component sc = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class, true).build();
Component sa2 = aspect(m, ServiceInterface.class).rank(20).impl(new
ServiceAspect(e, 3)).build();
Component sa3 = aspect(m, ServiceInterface.class).rank(30).impl(new
ServiceAspect(e, 2)).build();
Component sa1 = aspect(m, ServiceInterface.class).rank(10).impl(new
ServiceAspect(e, 4)).build();
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AutoConfigTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AutoConfigTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AutoConfigTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/AutoConfigTest.java
Sun Feb 28 19:11:09 2016
@@ -148,7 +148,7 @@ public class AutoConfigTest extends Test
}
private Component createConsumer(DependencyManager dm, Object consumer) {
- return component(dm).impl(consumer).withSvc(Provider.class).build();
+ return component(dm).impl(consumer).withSvc(Provider.class,
true).build();
}
public static interface Provider extends Runnable {
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/CFDependencyTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/CFDependencyTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/CFDependencyTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/CFDependencyTest.java
Sun Feb 28 19:11:09 2016
@@ -39,7 +39,7 @@ public class CFDependencyTest extends Te
// Create a consumer depending on a Provider and on the result of a CF.
// (the CF dependency is added from the Consumer.init() method).
CompletableFuture<String> cf = new CompletableFuture<>();
- Component consumer = component(dm).impl(new
Consumer(cf)).withSvc(Provider.class).build();
+ Component consumer = component(dm).impl(new
Consumer(cf)).withSvc(Provider.class, true).build();
// Create provider
Component provider = component(dm).impl(new
ProviderImpl()).provides(Provider.class).build();
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ComponentTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ComponentTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ComponentTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ComponentTest.java
Sun Feb 28 19:11:09 2016
@@ -54,6 +54,30 @@ public class ComponentTest extends TestB
m_ensure.waitForStep(5, 5000);
}
+ public void testSimple2() throws Exception {
+ final DependencyManager dm = getDM();
+
+ // Create consumer (dependency is required by default using builder
api).
+ component(dm, comp -> comp
+ .factory(Consumer::new)
+ .withSvc(Provider.class, srv ->
srv.filter("(name=provider2)").add("add").remove("remove"))
+ .withSvc(Provider.class, "(name=provider1)",
"m_autoConfiguredProvider", true));
+
+ // Create providers (auto added to dependency manager)
+ component(dm, comp -> comp
+ .impl(new Provider() { public String toString() { return
"provider1";}})
+ .provides(Provider.class).properties("name", "provider1"));
+
+ component(dm, comp -> comp
+ .impl(new Provider() { public String toString() { return
"provider2";}})
+ .provides(Provider.class).properties("name", "provider2"));
+
+ m_ensure.waitForStep(2, 5000);
+ dm.clear();
+ m_ensure.waitForStep(5, 5000);
+ }
+
+
public static interface Provider {
}
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/DynamicProxyAspectTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/DynamicProxyAspectTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/DynamicProxyAspectTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/DynamicProxyAspectTest.java
Sun Feb 28 19:11:09 2016
@@ -62,7 +62,7 @@ public class DynamicProxyAspectTest exte
// through the proxy twice
Component sc = component(m)
.impl(new ServiceConsumer(e))
- .withSvc(ServiceInterface.class, ServiceInterface2.class).build();
+ .withSvc(true, ServiceInterface.class,
ServiceInterface2.class).build();
// register both producers, validate that both services are started
m.add(sp1);
@@ -114,7 +114,7 @@ public class DynamicProxyAspectTest exte
// through the proxy twice
Component sc = component(m)
.impl(new ServiceConsumer(e))
- .withSvc(ServiceInterface.class, ServiceInterface2.class).build();
+ .withSvc(true, ServiceInterface.class,
ServiceInterface2.class).build();
// register both producers, validate that both services are started
m.add(sp1);
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryConfigurationAdapterTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryConfigurationAdapterTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryConfigurationAdapterTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryConfigurationAdapterTest.java
Sun Feb 28 19:11:09 2016
@@ -54,13 +54,13 @@ public class FactoryConfigurationAdapter
// Create a Configuration instance, which will create/update/remove a
configuration for factoryPid "MyFactoryPid"
ConfigurationCreator configurator = new
ConfigurationCreator("MyFactoryPid", "key", "value1");
- Component s1 =
component(m).impl(configurator).withSvc(ConfigurationAdmin.class).build();
+ Component s1 =
component(m).impl(configurator).withSvc(ConfigurationAdmin.class, true).build();
// Create an Adapter that will be instantiated, once the configuration
is created.
// This Adapter provides an AdapterService, and depends on an
AdapterExtraDependency service.
Component s2 = factoryPidAdapter(m)
.factoryPid("MyFactoryPid").impl(adapterImplClass).update(adapterUpdate).propagate().provides(AdapterService.class,
"foo", "bar")
- .withSvc(AdapterExtraDependency.class)
+ .withSvc(AdapterExtraDependency.class, true)
.build();
// Create extra adapter service dependency upon which our adapter
depends on.
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryInjectedWithConfigurationBeforeTheCreateMethod.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryInjectedWithConfigurationBeforeTheCreateMethod.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryInjectedWithConfigurationBeforeTheCreateMethod.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/FactoryInjectedWithConfigurationBeforeTheCreateMethod.java
Sun Feb 28 19:11:09 2016
@@ -45,7 +45,7 @@ public class FactoryInjectedWithConfigur
m_e = new Ensure();
// Create the component that creates a configuration.
- Component configurator = component(m).impl(new
Configurator("foobar")).withSvc(ConfigurationAdmin.class).build();
+ Component configurator = component(m).impl(new
Configurator("foobar")).withSvc(ConfigurationAdmin.class, true).build();
// Create the object that has to be injected with the configuration
before its create method is called.
MyFactory factory = new MyFactory();
@@ -67,7 +67,7 @@ public class FactoryInjectedWithConfigur
m_e = new Ensure();
// Create the component that creates a configuration.
- Component configurator = component(m).impl(new
Configurator("foobar")).withSvc(ConfigurationAdmin.class).build();
+ Component configurator = component(m).impl(new
Configurator("foobar")).withSvc(ConfigurationAdmin.class, true).build();
// Create the object that has to be injected with the configuration
before its create method is called.
MyFactory factory = new MyFactory();
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleExtraDependencyTest2.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleExtraDependencyTest2.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleExtraDependencyTest2.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleExtraDependencyTest2.java
Sun Feb 28 19:11:09 2016
@@ -44,7 +44,7 @@ public class MultipleExtraDependencyTest
Component sp = component(m)
.impl(ServiceProvider.class)
.provides(ServiceInterface.class, "foo", "bar")
-
.init(ServiceProvider::init).start(ServiceProvider::start).stop(ServiceProvider::stop)
+ .init("init").start("start").stop("stop")
.build();
Component sc = component(m)
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleServiceDependencyTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleServiceDependencyTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleServiceDependencyTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/MultipleServiceDependencyTest.java
Sun Feb 28 19:11:09 2016
@@ -35,7 +35,7 @@ public class MultipleServiceDependencyTe
// create a service provider and consumer
Component provider = component(m).impl(new
ServiceProvider(e)).provides(ServiceInterface.class.getName()).build();
Component providerWithHighRank = component(m).impl(new
ServiceProvider2(e)).provides(ServiceInterface.class.getName(),
Constants.SERVICE_RANKING, Integer.valueOf(5)).build();
- Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class).build();
+ Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class, true).build();
m.add(provider);
m.add(providerWithHighRank);
m.add(consumer);
@@ -55,7 +55,7 @@ public class MultipleServiceDependencyTe
// create a service provider and consumer
Component provider = component(m).impl(new
ServiceProvider(e)).provides(ServiceInterface.class.getName()).build();
Component provider2 = component(m).impl(new
ServiceProvider2(e)).provides(ServiceInterface.class.getName()).build();
- Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class).build();
+ Component consumer = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class, true).build();
m.add(provider2);
m.add(consumer);
e.waitForStep(3, 5000);
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyInjectionTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyInjectionTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyInjectionTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyInjectionTest.java
Sun Feb 28 19:11:09 2016
@@ -34,7 +34,7 @@ public class ServiceDependencyInjectionT
// create a service provider and consumer
ServiceProvider provider = new ServiceProvider(e);
Component sp =
component(m).impl(provider).provides(ServiceInterface2.class.getName()).build();
- Component sc = component(m).impl(new
ServiceConsumer()).withSvc(ServiceInterface2.class).build();
+ Component sc = component(m).impl(new
ServiceConsumer()).withSvc(ServiceInterface2.class, true).build();
Component sc2 = component(m) // all dependencies are optional
.impl(new ServiceConsumerNamedInjection(false, false))
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/ServiceDependencyTest.java
Sun Feb 28 19:11:09 2016
@@ -33,7 +33,7 @@ public class ServiceDependencyTest exten
Ensure e = new Ensure();
// create a service provider and consumer
Component sp = component(m).impl(new
ServiceProvider(e)).provides(ServiceInterface.class).build();
- Component sc = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class).build();
+ Component sc = component(m).impl(new
ServiceConsumer(e)).withSvc(ServiceInterface.class, true).build();
Component sc2 = component(m).impl(new ServiceConsumerCallbacks(e))
.withSvc(ServiceInterface.class, srv ->
srv.required(false).add(ServiceConsumerCallbacks::add).remove(ServiceConsumerCallbacks::remove))
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/TemporalServiceDependencyTest.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/TemporalServiceDependencyTest.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/TemporalServiceDependencyTest.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/lambda/itest/TemporalServiceDependencyTest.java
Sun Feb 28 19:11:09 2016
@@ -18,6 +18,7 @@
*/
package org.apache.felix.dm.lambda.itest;
+import static org.apache.felix.dm.lambda.DependencyManagerActivator.adapter;
import static org.apache.felix.dm.lambda.DependencyManagerActivator.component;
import static
org.apache.felix.dm.lambda.DependencyManagerActivator.serviceDependency;
@@ -110,7 +111,7 @@ public class TemporalServiceDependencyTe
TemporalServiceProvider2 provider2 = new TemporalServiceProvider2(e);
Component sp2 =
component(m).impl(provider2).provides(TemporalServiceInterface.class.getName()).build();
TemporalServiceConsumerAdapterWithCallback consumer = new
TemporalServiceConsumerAdapterWithCallback(e);
- Component sc = m.createAdapterService(Adaptee.class,
null).setImplementation(consumer);
+ Component sc = adapter(m, Adaptee.class).impl(consumer).build();
ServiceDependency temporalDep = serviceDependency(sc,
TemporalServiceInterface.class).timeout(10000).add("add").remove("remove").build();
sc.add(temporalDep);
Component adaptee = component(m).impl(new
Adaptee()).provides(Adaptee.class.getName()).build();
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/dictionary.bndrun
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/dictionary.bndrun?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/dictionary.bndrun
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/dictionary.bndrun
Sun Feb 28 19:11:09 2016
@@ -36,9 +36,8 @@
org.apache.felix.webconsole;version=4.2.2,\
org.apache.felix.http.api;version=2.3.0,\
org.apache.felix.http.servlet-api;version=1.0.0,\
- org.apache.felix.http.jetty;version="[2.3.0,2.3.0]"
+ org.apache.felix.http.jetty;version='[2.3.0,2.3.0]'
-
-runproperties: \
org.apache.felix.dependencymanager.loglevel=2,\
org.apache.felix.log.maxSize=100000,\
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
Sun Feb 28 19:11:09 2016
@@ -29,13 +29,14 @@ import org.osgi.service.log.LogService;
/**
* Creates a "Provider" service. The implementation for this service
(ProviderImpl) is
* created using a factory class (ProviderFactory) that also creates some
other helper classes
- * (ProviderComposite1 and ProviderComposite2) that are internally used by
ProviderImpl.
+ * that are internally used by ProviderImpl (ProviderComposite1 and
ProviderComposite2).
*
* The ProviderFactory is also injected with a Configuration that can be used
by the Factory
* when creating the ProviderImpl, ProviderComposite1, and ProviderComposite2
classes.
*
* The LogService in only injected to the ProviderImpl and the
ProviderComposite1 classes.
- * Both composites are called in their "start" callbacks, when all required
dependencies are available.
+ * objects being part of the composition are called in "start" lifecycle
callback when all
+ * required dependencies are available.
*
* @author <a href="mailto:[email protected]">Felix Project Team</a>
*/
@@ -53,11 +54,10 @@ public class Activator extends Dependenc
// before creating the composition of classes.
component(comp -> comp
.factory(factory::create, factory::getComposition)
- .start(ProviderImpl::start) // only call start on ProviderImpl
- .withSvc(LogService.class, srv ->
srv.add(ProviderImpl::bind).add(ProviderComposite1::bind))
+ .withSvc(LogService.class, svc ->
svc.required().add(ProviderImpl::bind).add(ProviderComposite1::bind))
.withCnf(conf -> conf.update(MyConfig.class, factory::updated)));
// Creates a configuration with pid name =
"org.apache.felix.dependencymanager.lambda.samples.compositefactory.ProviderFactory"
- component(comp ->
comp.impl(Configurator.class).withSvc(ConfigurationAdmin.class));
+ component(comp ->
comp.impl(Configurator.class).withSvc(ConfigurationAdmin.class, true));
}
}
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java
Sun Feb 28 19:11:09 2016
@@ -46,8 +46,8 @@ public class Activator extends Dependenc
// Creates a component that simply displays all available
DeviceParameter adapter services.
component(comp -> comp
.impl(DeviceAccessConsumer.class)
- .withSvc(LogService.class)
- .withSvc(DeviceAccess.class, device ->
device.add(DeviceAccessConsumer::add)));
+ .withSvc(LogService.class, true)
+ .withSvc(DeviceAccess.class, device ->
device.required().add(DeviceAccessConsumer::add)));
}
private void createDeviceAndParameter(int id) {
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/DeviceAccessImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/DeviceAccessImpl.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/DeviceAccessImpl.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/DeviceAccessImpl.java
Sun Feb 28 19:11:09 2016
@@ -35,7 +35,7 @@ public class DeviceAccessImpl implements
component(c, builder -> builder
.properties("device.access.id", device.getDeviceId())
- .withSvc(DeviceParameter.class, srv -> srv.filter("(device.id=" +
device.getDeviceId() + ")")));
+ .withSvc(DeviceParameter.class, svc -> svc.filter("(device.id=" +
device.getDeviceId() + ")")));
}
@Override
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java
Sun Feb 28 19:11:09 2016
@@ -42,7 +42,7 @@ public class Activator extends Dependenc
.provides(DictionaryService.class)
.propagate()
.update(DictionaryConfiguration.class, DictionaryImpl::updated)
- .withSvc(LogService.class));
+ .withSvc(LogService.class, true));
// Create the Dictionary Aspect that decorates any registered
Dictionary service. For each Dictionary, an instance of the
// DictionaryAspect service is created).
@@ -50,14 +50,13 @@ public class Activator extends Dependenc
.impl(DictionaryAspect.class)
.filter("(lang=en)").rank(10)
.withCnf(conf -> conf.update(DictionaryAspectConfiguration.class,
DictionaryAspect::addWords))
- .withSvc(LogService.class));
+ .withSvc(LogService.class, true));
// Create the SpellChecker component. It depends on all available
DictionaryService instances, possibly
// decorated by some DictionaryAspects.
component(comp -> comp
.impl(SpellChecker.class)
.provides(SpellChecker.class, COMMAND_SCOPE, "dictionary",
COMMAND_FUNCTION, new String[] {"spellcheck"})
- .withSvc(DictionaryService.class)
- .withSvc(LogService.class));
+ .withSvc(true, LogService.class, DictionaryService.class));
}
}
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/DictionaryImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/DictionaryImpl.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/DictionaryImpl.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/DictionaryImpl.java
Sun Feb 28 19:11:09 2016
@@ -53,7 +53,7 @@ public class DictionaryImpl implements D
* Our Dictionary language.
*/
private String m_lang;
-
+
/**
* Our service will be initialized from ConfigAdmin.
* @param config The configuration where we'll lookup our words list
(key=".words").
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java
Sun Feb 28 19:11:09 2016
@@ -36,7 +36,6 @@ public class Activator extends Dependenc
component(comp -> comp
.factory(ProviderFactory::new, ProviderFactory::create)
.provides(Provider.class)
- .start(ProviderImpl::start)
- .withSvc(LogService.class, log -> log.add(ProviderImpl::set)));
+ .withSvc(LogService.class, log ->
log.required().add(ProviderImpl::set)));
}
}
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java
Sun Feb 28 19:11:09 2016
@@ -51,7 +51,7 @@ public class Activator extends Dependenc
component(comp -> comp
.factory(() -> new PageLinksImpl("http://felix.apache.org/"))
.provides(PageLinks.class)
- .withSvc(LogService.class, log -> log.add(PageLinksImpl::bind)));
+ .withSvc(LogService.class, log ->
log.required().add(PageLinksImpl::bind)));
// Just wait for the PageLinks service and display all links found
from the Felix web site.
component(comp -> comp.impl(this).withSvc(PageLinks.class, page ->
page.add(this::setPageLinks)));
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java
Sun Feb 28 19:11:09 2016
@@ -20,14 +20,16 @@ package org.apache.felix.dm.lambda.sampl
import static org.apache.felix.dm.lambda.DependencyManagerActivator.component;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Scanner;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.apache.felix.dm.Component;
import org.osgi.service.log.LogService;
@@ -73,19 +75,12 @@ public class PageLinksImpl implements Pa
return m_links;
}
- private String download(String url) {
- try (Scanner in = new Scanner(new URL(url).openStream())) {
- StringBuilder builder = new StringBuilder();
- while (in.hasNextLine()) {
- builder.append(in.nextLine());
- builder.append("\n");
- }
- return builder.toString();
- } catch (IOException ex) {
- RuntimeException rex = new RuntimeException();
- rex.initCause(ex);
- throw rex;
- }
+ public static String download(String url) {
+ try (BufferedReader buffer = new BufferedReader(new
InputStreamReader(new URL(url).openStream()))) {
+ return buffer.lines().collect(Collectors.joining("\n"));
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
}
private List<String> parseLinks(String content) {
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
Sun Feb 28 19:11:09 2016
@@ -28,6 +28,8 @@ import org.osgi.service.event.EventAdmin
import org.osgi.service.log.LogService;
/**
+ * Hello world example.
+ *
* @author <a href="mailto:[email protected]">Felix Project Team</a>
*/
public class Activator extends DependencyManagerActivator {
@@ -35,26 +37,29 @@ public class Activator extends Dependenc
public void init(BundleContext ctx, DependencyManager dm) throws Exception
{
out.println("type \"log warn\" to see the logs emitted by this test.");
+ // Creates a component that populates some properties in the
Configuration Admin.
+ // Here, we inject the CM (Configuration Admin) service dependency
using a method reference:
+
+ component(comp -> comp.factory(() -> new
Configurator(Configuration.class.getName()))
+ .withSvc(ConfigurationAdmin.class, svc ->
svc.required().add(Configurator::bind)));
+
// Creates a Service Provider (property names are deduced from lambda
parameter names).
- // (service dependencies are required by default)
+ // The provider depends on a required log service, injected by
reflection on compatible class fields.
+
component(comp -> comp.impl(ServiceProviderImpl.class)
.provides(ServiceProvider.class, p1 -> "v1", p2 -> 123)
- .withSvc(LogService.class));
+ .withSvc(LogService.class, true /* required */));
- // Creates a Service Consumer. we depend on LogService, EventAdmin and
on our ServiceProvider.
- // (LogService and EventAdmin are declared in one single method call).
+ // Creates a Service Consumer which depends on LogService, EventAdmin
and on the ServiceProvider.
+ // LogService and EventAdmin are declared in one single method call,
and are injected in class fields.
// We also depend on a configuration. the configuration callback is
assumed to be the "ServiceConsumer.updated" method which
// takes as argument a "Configuration" interface. This interface is
used to wrap the actual properties behind a dynamic proxy
// that is implemented by Dependency Manager.
// The pid is assumed to be by default the fqdn of the specified
Configuration interface
("org.apache.felix.dm.lambda.samples.hello.Configuration").
- component(comp -> comp.impl(ServiceConsumer.class)
- .withSvc(LogService.class, EventAdmin.class)
- .withSvc(ServiceProvider.class, srv -> srv.filter("(p1=v1)"))
- .withCnf(Configuration.class)); // shortcut for
"withCnf(Configuration.class, cnf -> cnf.updated(Configuration.class,
ServiceConsumer::updated)"
- // Creates a component that populates some properties in the
Configuration Admin.
- // Here, we inject the CM (Configuration Admin) service dependency
using a method reference:
- component(comp -> comp.factory(() -> new
Configurator(Configuration.class.getName()))
- .withSvc(ConfigurationAdmin.class, srv ->
srv.add(Configurator::bind)));
+ component(comp -> comp.impl(ServiceConsumer.class)
+ .withSvc(true /* required */, LogService.class, EventAdmin.class)
+ .withSvc(ServiceProvider.class, "(p1=v1)", true /* required */)
+ .withCnf(Configuration.class));
}
}
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceConsumer.java
Sun Feb 28 19:11:09 2016
@@ -32,7 +32,7 @@ public class ServiceConsumer {
volatile EventAdmin eventAdmin;
public void updated(Configuration conf) {
- System.out.println(conf.getFoo());
+ // conf.getFoo() returns "bar"
}
public void start() {
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/ServiceProviderImpl.java
Sun Feb 28 19:11:09 2016
@@ -34,7 +34,7 @@ public class ServiceProviderImpl impleme
* as volatile will ensure safe publication if the log service is replaced
at runtime.
*/
volatile LogService log;
-
+
void start() {
// Default lifecycle start calback (all required dependencies have
been injected when start is called,
// and all optional dependency callbacks will be invoked after the
start method. This allows to easily
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/BundleDependencyBuilder.java
Sun Feb 28 19:11:09 2016
@@ -30,7 +30,6 @@ import org.osgi.framework.Bundle;
/**
* Builds a Dependency Manager Bundle Dependency.
- * When a bundle dependency is not explicitly defined as "required" or
"optional", then it is assumed to be required by default.
*
* <p> Example of a Pojo Component which tracks a started bundle having a
given bundle symbolic name:
*
@@ -80,6 +79,13 @@ public interface BundleDependencyBuilder
public BundleDependencyBuilder required();
/**
+ * Sets the dependency to be optional.
+ *
+ * @return the bundle dependency builder
+ */
+ public BundleDependencyBuilder optional();
+
+ /**
* Sets the bundle to depend on directly.
*
* @param bundle the bundle to depend on
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
Sun Feb 28 19:11:09 2016
@@ -26,8 +26,6 @@ import java.util.function.Supplier;
import java.util.stream.Stream;
import org.apache.felix.dm.Component;
-import org.apache.felix.dm.lambda.callbacks.Cb;
-import org.apache.felix.dm.lambda.callbacks.CbComponent;
import org.apache.felix.dm.lambda.callbacks.InstanceCb;
import org.apache.felix.dm.lambda.callbacks.InstanceCbComponent;
@@ -38,13 +36,13 @@ import org.apache.felix.dm.lambda.callba
* required dependencies are available. This interface is also the base
interface for extended components like
* aspects, adapters, etc ...
*
- * <p> Example of a component that depends on a ConfigurationAdmin service.
The dependency is injected by reflection
- * on a class field which type matches the ConfigurationAdmin interface:
+ * <p> Example of a component that depends on a LogServce service. The
dependency is injected by reflection
+ * on fields having a compatible type with the LogService interface:
*
* <pre>{@code
* public class Activator extends DependencyManagerActivator {
* public void init(BundleContext ctx, DependencyManager dm) throws
Exception {
- * component(comp ->
comp.impl(Configurator.class).withSvc(ConfigurationAdmin.class));
+ * component(comp -> comp.impl(Pojo.class).withSvc(LogService.class));
* }
* }
* } </pre>
@@ -356,30 +354,79 @@ public interface ComponentBuilder<B exte
B properties(FluentProperty ... properties);
/**
- * Adds a required/autoconfig service dependency.
+ * Adds a service dependency built using a Consumer lambda that is
provided with a ServiceDependencyBuilder.
*
- * @param service the service dependency filter
- * @param filter the service filter
+ * @param <U> the type of the dependency service
+ * @param service the service
+ * @param consumer the lambda used to build the service dependency
+ * @return this builder.
+ */
+ <U> B withSvc(Class<U> service, Consumer<ServiceDependencyBuilder<U>>
consumer);
+
+ /**
+ * Adds in one shot multiple service dependencies injected in compatible
class fields.
+ *
+ * @param services some dependencies to inject in compatible class fields.
* @return this builder
*/
- B withSvc(Class<?> service, String filter);
+ @SuppressWarnings("unchecked")
+ default B withSvc(Class<?> ... services) {
+ Stream.of(services).forEach(s -> withSvc(s, svc -> svc.autoConfig()));
+ return (B) this;
+ }
/**
- * Adds in one shot multiple required/autoconfig service dependencies.
- * @param services the dependencies that are required and that will be
injected in any field with the same dependency type.
+ * Adds in one shot multiple service dependencies injected in compatible
class fields.
+ *
+ * @param required true if the dependency is required, false if not
+ * @param services some dependencies to inject in compatible class fields.
* @return this builder
*/
- B withSvc(Class<?> ... services);
-
+ @SuppressWarnings("unchecked")
+ default B withSvc(boolean required, Class<?> ... services) {
+ Stream.of(services).forEach(s -> withSvc(s, svc ->
svc.required(required)));
+ return (B) this;
+ }
+
/**
- * Adds a service dependency built using a Consumer lambda that is
provided with a ServiceDependencyBuilder.
+ * Adds a service dependency injected in compatible class fields.
*
- * @param <U> the type of the dependency service
- * @param service the service
- * @param consumer the lambda for building the service dependency
- * @return this builder.
+ * @param service a service dependency
+ * @param required true if the dependency is required, false if not
+ * @return this builder
*/
- <U> B withSvc(Class<U> service, Consumer<ServiceDependencyBuilder<U>>
consumer);
+ @SuppressWarnings("unchecked")
+ default B withSvc(Class<?> service, boolean required) {
+ withSvc(service, svc -> svc.required(required));
+ return (B) this;
+ }
+
+ /**
+ * Adds a service dependency injected in compatible class fields.
+ *
+ * @param <T> the service dependency type
+ * @param service the service dependency.
+ * @param filter the service filter
+ * @param required true if the dependency is required, false if not
+ * @return this builder
+ */
+ default <T> B withSvc(Class<T> service, String filter, boolean required) {
+ return withSvc(service, svc -> svc.filter(filter).required(required));
+ }
+
+ /**
+ * Adds a service dependency injected in a given compatible class field.
+ *
+ * @param <T> the service dependency type
+ * @param service the service dependency
+ * @param filter the service filter
+ * @param field the class field when the dependency has to be injected
+ * @param required true if the dependency is required, false if not
+ * @return this builder
+ */
+ default <T> B withSvc(Class<T> service, String filter, String field,
boolean required) {
+ return withSvc(service, svc ->
svc.filter(filter).autoConfig(field).required(required));
+ }
/**
* Adds a configuration dependency.
@@ -402,6 +449,8 @@ public interface ComponentBuilder<B exte
/**
* Adds a configuration dependency using a configuration type. The
configuration is injected in an updated callback which takes in argument
* an implementation of the specified configuration type.
+ *
+ * @param configType the configuration type that will be injected to the
"updated" callback
* @return this builder
* @see ConfigurationDependencyBuilder
*/
@@ -425,26 +474,7 @@ public interface ComponentBuilder<B exte
* @return this builder.
*/
<U> B withFuture(CompletableFuture<U> future,
Consumer<FutureDependencyBuilder<U>> consumer);
-
- /**
- * Sets the instance to invoke with the reflection based lifecycle
callbacks. By default, reflection based
- * lifecycle callbacks (init/start/stop/destroy) methods are invoked on
the component implementation instance(s).
- * But you can set a specific callback instance using this method.
- * <p>
- * Specifying an instance means you can create a manager
- * that will be invoked whenever the life cycle of a component changes and
this manager
- * can then decide how to expose this life cycle to the actual component,
offering an
- * important indirection when developing your own component models.
- *
- * @see #init(String)
- * @see #start(String)
- * @see #stop(String)
- * @see #destroy(String)
- * @param lifecycleCallbackInstance the instance the lifecycle callback
will be invoked on.
- * @return this builder.
- */
- B lifecycleCallbackInstance(Object lifecycleCallbackInstance);
-
+
/**
* Sets the name of the method used as the "init" callback. This method,
when found, is
* invoked as part of the life cycle management of the component
implementation.
@@ -464,22 +494,52 @@ public interface ComponentBuilder<B exte
B init(String callback);
/**
- * Sets the name of the method used as the "start" callback. This method,
when found, is
- * invoked as part of the life cycle management of the component
implementation. <p>The
- * dependency manager will look for a method of this name with the
following signatures,
+ * Sets a callback instance and the name of the method used as the "init"
callback. This method, when found, is
+ * invoked as part of the life cycle management of the component
implementation.
+ * This method is useful because when it is invoked, all required
dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from
the init() method.
+ * And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
+ * <p>The dependency manager will look for a method of this name with the
following signatures,
* in this order:
* <ol>
* <li>method(Component component)</li>
* <li>method()</li>
* </ol>
*
+ * @param callbackInstance a callback instance object the callback is
invoked on
* @param callback the callback name
* @return this builder.
*/
- B start(String callback);
-
+ B init(Object callbackInstance, String callback);
+
/**
- * Sets the name of the method used as the "stop" callback. This method,
when found, is
+ * Sets an Object instance method reference used as the "init" callback.
It is invoked as part of the life cycle management of the component
+ * implementation.
+ * This method is useful because when it is invoked, all required
dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from
the init() method.
+ * And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
+ * The method does not take any parameters.
+ *
+ * @param callback an Object instance method reference. The method does
not take any parameters.
+ * @return this builder
+ */
+ B init(InstanceCb callback);
+
+ /**
+ * Sets an Object instance method reference used as the "init" callback.
It is invoked as part of the life cycle management of the component
+ * implementation.
+ * This method is useful because when it is invoked, all required
dependencies defines in the Activator
+ * are already injected, and you can then add more extra dependencies from
the init() method.
+ * And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback an Object instance method reference. The method takes
as argument a Component parameter.
+ * @return this builder
+ */
+ B init(InstanceCbComponent callback);
+
+ /**
+ * Sets a callback instance and the name of the method used as the "start"
callback. This method, when found, is
* invoked as part of the life cycle management of the component
implementation. <p>The
* dependency manager will look for a method of this name with the
following signatures,
* in this order:
@@ -491,10 +551,10 @@ public interface ComponentBuilder<B exte
* @param callback the callback name
* @return this builder.
*/
- B stop(String callback);
+ B start(String callback);
/**
- * Sets the name of the method used as the "destroy" callback. This
method, when found, is
+ * Sets the name of the method used as the "start" callback. This method,
when found, is
* invoked as part of the life cycle management of the component
implementation. <p>The
* dependency manager will look for a method of this name with the
following signatures,
* in this order:
@@ -503,107 +563,65 @@ public interface ComponentBuilder<B exte
* <li>method()</li>
* </ol>
*
+ * @param callbackInstance a callback instance object the callback is
invoked on
* @param callback the callback name
* @return this builder.
*/
- B destroy(String callback);
-
- /**
- * Sets a reference to a component implementation class "init" callback
method.
- * This method does not take any arguments and is
- * invoked as part of the life cycle management of the component
implementation.
- * This method is useful because when it is invoked, all required
dependencies defines in the Activator
- * are already injected, and you can then add more extra dependencies from
the init() method.
- * And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
- *
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from the
component implementation class(es).
- * @return this builder
- */
- <T> B init(Cb<T> callback);
-
- /**
- * Sets a reference to a component implementation class "start" callback
method.
- * This method does not take any arguments and is
- * invoked as part of the life cycle management of the component
implementation.
- *
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from one of
the component implementation classes.
- * @return this builder.
- */
- <T> B start(Cb<T> callback);
-
+ B start(Object callbackInstance, String callback);
+
/**
- * Sets a reference to a component implementation class "stop" callback
method.
- * This method does not take any arguments and is
- * invoked as part of the life cycle management of the component
implementation.
- *
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from one of
the component implementation classes.
+ * Sets an Object instance method reference used as the "start" callback.
+ * This method is invoked as part of the life cycle management of the
component implementation.
+ * The method does not take any parameters.
+ *
+ * @param callback an Object instance method reference. The method does
not take any parameters.
* @return this builder.
*/
- <T> B stop(Cb<T> callback);
+ B start(InstanceCb callback);
/**
- * Sets a reference to a component implementation class "destroy" callback
method.
- * This method does not take any arguments and is
- * invoked as part of the life cycle management of the component
implementation.
- *
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from one of
the component implementation classes.
+ * Sets an Object instance method reference used as the "start" callback.
+ * This method is invoked as part of the life cycle management of the
component implementation.
+ * The method takes as argument a Component parameter.
+ *
+ * @param callback an Object instance method reference. The method takes
as argument a Component parameter.
* @return this builder.
*/
- <T> B destroy(Cb<T> callback);
-
- /**
- * Sets a reference to a component implementation class "init" callback
method.
- * This method takes a Component argument and is
- * invoked as part of the life cycle management of the component
implementation.
- * This method is useful because when it is invoked, all required
dependencies defines in the Activator
- * are already injected, and you can then add more extra dependencies from
the init() method.
- * And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
- *
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from one of the
component implementation classes. The method takes as argument a Component
parameter.
- * @return this builder
- */
- <T> B init(CbComponent<T> callback);
+ B start(InstanceCbComponent callback);
/**
- * Sets a reference to a component implementation class "start" callback
method.
- * This method takes a Component argument and is
- * invoked as part of the life cycle management of the component
implementation.
- *
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from one of the
component implementation classes. The method takes as argument a Component
parameter.
- * @return this builder.
- */
- <T> B start(CbComponent<T> callback);
-
- /**
- * Sets a reference to a component implementation class "stop" callback
method.
- * This method takes a Component argument and is
- * invoked as part of the life cycle management of the component
implementation.
+ * Sets the name of the method used as the "stop" callback. This method,
when found, is
+ * invoked as part of the life cycle management of the component
implementation. <p>The
+ * dependency manager will look for a method of this name with the
following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
*
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from one of the
component implementation classes. The method takes as argument a Component
parameter.
+ * @param callback the callback name
* @return this builder.
*/
- <T> B stop(CbComponent<T> callback);
-
+ B stop(String callback);
+
/**
- * Sets a reference to a component implementation class "destroy" callback
method.
- * This method takes a Component argument and is
- * invoked as part of the life cycle management of the component
implementation.
+ * Sets a callback instance and the name of the method used as the "stop"
callback. This method, when found, is
+ * invoked as part of the life cycle management of the component
implementation. <p>The
+ * dependency manager will look for a method of this name with the
following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
*
- * @param <T> the type of the component class on which the callback is
invoked on.
- * @param callback a method reference must point to method from one of the
component implementation classes. The method takes as argument a Component
parameter.
+ * @param callbackInstance a callback instance object the callback is
invoked on
+ * @param callback the callback name
* @return this builder.
*/
- <T> B destroy(CbComponent<T> callback);
+ B stop(Object callbackInstance, String callback);
/**
- * Sets an Object instance method reference used as the "init" callback.
It is invoked as part of the life cycle management of the component
+ * Sets an Object instance method reference used as the "stop" callback.
It is invoked as part of the life cycle management of the component
* implementation.
* This method is useful because when it is invoked, all required
dependencies defines in the Activator
* are already injected, and you can then add more extra dependencies from
the init() method.
@@ -613,77 +631,62 @@ public interface ComponentBuilder<B exte
* @param callback an Object instance method reference. The method does
not take any parameters.
* @return this builder
*/
- B initInstance(InstanceCb callback);
-
+ B stop(InstanceCb callback);
+
/**
- * Sets an Object instance method reference used as the "start" callback.
+ * Sets an Object instance method reference used as the "stop" callback.
* This method is invoked as part of the life cycle management of the
component implementation.
- * The method does not take any parameters.
+ * The method takes as argument a Component parameter.
*
- * @param callback an Object instance method reference. The method does
not take any parameters.
+ * @param callback an Object instance method reference. The method takes
as argument a Component parameter.
* @return this builder.
*/
- B startInstance(InstanceCb callback);
+ B stop(InstanceCbComponent callback);
/**
- * Sets an Object instance method reference used as the "stop" callback.
It is invoked as part of the life cycle management of the component
- * implementation.
- * This method is useful because when it is invoked, all required
dependencies defines in the Activator
- * are already injected, and you can then add more extra dependencies from
the init() method.
- * And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
- * The method does not take any parameters.
+ * Sets the name of the method used as the "destroy" callback. This
method, when found, is
+ * invoked as part of the life cycle management of the component
implementation. <p>The
+ * dependency manager will look for a method of this name with the
following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
*
- * @param callback an Object instance method reference. The method does
not take any parameters.
- * @return this builder
+ * @param callback the callback name
+ * @return this builder.
*/
- B stopInstance(InstanceCb callback);
-
+ B destroy(String callback);
+
/**
- * Sets an Object instance method reference used as the "destroy"
callback. It is invoked as part of the life cycle management of the component
- * implementation.
- * This method is useful because when it is invoked, all required
dependencies defines in the Activator
- * are already injected, and you can then add more extra dependencies from
the init() method.
- * And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
- * The method does not take any parameters.
+ * Sets a callback instance and the name of the method used as the
"destroy" callback. This method, when found, is
+ * invoked as part of the life cycle management of the component
implementation. <p>The
+ * dependency manager will look for a method of this name with the
following signatures,
+ * in this order:
+ * <ol>
+ * <li>method(Component component)</li>
+ * <li>method()</li>
+ * </ol>
*
- * @param callback an Object instance method reference. The method does
not take any parameters.
- * @return this builder
+ * @param callbackInstance a callback instance object the callback is
invoked on
+ * @param callback the callback name
+ * @return this builder.
*/
- B destroyInstance(InstanceCb callback);
+ B destroy(Object callbackInstance, String callback);
/**
- * Sets an Object instance method reference used as the "init" callback.
It is invoked as part of the life cycle management of the component
+ * Sets an Object instance method reference used as the "destroy"
callback. It is invoked as part of the life cycle management of the component
* implementation.
* This method is useful because when it is invoked, all required
dependencies defines in the Activator
* are already injected, and you can then add more extra dependencies from
the init() method.
* And once all extra dependencies will be available and injected, then
the "start" callback will be invoked.
- * The method takes as argument a Component parameter.
+ * The method does not take any parameters.
*
- * @param callback an Object instance method reference. The method takes
as argument a Component parameter.
+ * @param callback an Object instance method reference. The method does
not take any parameters.
* @return this builder
*/
- B initInstance(InstanceCbComponent callback);
-
- /**
- * Sets an Object instance method reference used as the "start" callback.
- * This method is invoked as part of the life cycle management of the
component implementation.
- * The method takes as argument a Component parameter.
- *
- * @param callback an Object instance method reference. The method takes
as argument a Component parameter.
- * @return this builder.
- */
- B startInstance(InstanceCbComponent callback);
-
- /**
- * Sets an Object instance method reference used as the "stop" callback.
- * This method is invoked as part of the life cycle management of the
component implementation.
- * The method takes as argument a Component parameter.
- *
- * @param callback an Object instance method reference. The method takes
as argument a Component parameter.
- * @return this builder.
- */
- B stopInstance(InstanceCbComponent callback);
-
+ B destroy(InstanceCb callback);
+
/**
* Sets an Object instance method reference used as the "destroy"
callback.
* This method is invoked as part of the life cycle management of the
component implementation.
@@ -692,7 +695,7 @@ public interface ComponentBuilder<B exte
* @param callback an Object instance method reference. The method takes
as argument a Component parameter.
* @return this builder.
*/
- B destroyInstance(InstanceCbComponent callback);
+ B destroy(InstanceCbComponent callback);
/**
* Configures OSGi object (BundleContext, Component, etc ...) that will be
injected in any field having the same OSGi object type.
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java
Sun Feb 28 19:11:09 2016
@@ -85,6 +85,11 @@ import org.osgi.framework.BundleContext;
* }
* }
* }</pre>
+ *
+ * When a dependency is not explicitly defined as "required" or "optional",
+ * then it is assumed to be optional by default, like it is the case with the
original DM API.
+ * You can change the default mode using the
"org.apache.felix.dependencymanager.lambda.defaultRequiredDependency system
property"
+ * (see Felix dm-lambda online documentation).
*/
public abstract class DependencyManagerActivator implements BundleActivator {
/**
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java?rev=1732779&r1=1732778&r2=1732779&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ServiceCallbacksBuilder.java
Sun Feb 28 19:11:09 2016
@@ -40,8 +40,7 @@ import org.apache.felix.dm.lambda.callba
import org.apache.felix.dm.lambda.callbacks.InstanceCbServiceServiceComponent;
/**
- * Builds a service dependency callback. When a service dependency is not
explicitly defined as "required" or "optional",
- * then it is assumed to be required by default.
+ * Builds a service dependency callback.
*
* <p> A Service may be injected in a bind-method of a component or an object
instance using this builder.
* The builder supports reflection based callbacks (same as with the original
DM API), as well as java8 method reference based callbacks.