cleanup.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1728193 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
index 2aab3bc..6dbf187 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/compositefactory/Activator.java
@@ -20,7 +20,9 @@
import static java.lang.System.out;
+import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.lambda.DependencyManagerActivator;
+import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.log.LogService;
@@ -39,7 +41,7 @@
*/
public class Activator extends DependencyManagerActivator {
@Override
- public void activate() throws Exception {
+ public void init(BundleContext ctx, DependencyManager dm) throws Exception {
out.println("type \"log info\" to see the logs emitted by this test.");
// Create the Factory used to instantiate ProvuderImpl, ProviderComposite1 and ProviderComposite2
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java
index 978367c..b9a86ae 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/device/Activator.java
@@ -20,7 +20,9 @@
import static java.lang.System.out;
+import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.lambda.DependencyManagerActivator;
+import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
/**
@@ -28,7 +30,7 @@
*/
public class Activator extends DependencyManagerActivator {
@Override
- public void activate() throws Exception {
+ public void init(BundleContext ctx, DependencyManager dm) throws Exception {
out.println("type \"log info\" to see the logs emitted by this test.");
// Create a pair of Device/DeviceParameter service with id=1
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java
index a60db9c..3fc5a4f 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/Activator.java
@@ -20,7 +20,9 @@
import static java.lang.System.out;
+import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.lambda.DependencyManagerActivator;
+import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
import static org.apache.felix.service.command.CommandProcessor.COMMAND_FUNCTION;
import static org.apache.felix.service.command.CommandProcessor.COMMAND_SCOPE;
@@ -30,7 +32,7 @@
*/
public class Activator extends DependencyManagerActivator {
@Override
- public void activate() throws Exception {
+ public void init(BundleContext ctx, DependencyManager dm) throws Exception {
out.println("type \"log info\" to see the logs emitted by this test.");
// Create the factory configuration for our DictionaryImpl service. An instance of the DictionaryImpl is created for each
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/README b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/README
index 2dda5b8..4c3e374 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/README
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/dictionary/README
@@ -15,27 +15,27 @@
* limitations under the License.
*/
-This sample shows a "SpellChecker" application (using DM API) which provides a
+This sample shows a "SpellChecker" application which provides a
"dictionary:spellcheck" GOGO shell command. The GOGO "dictionary:spellcheck" command accepts a
-string as parameter, which is checked for proper existence. The SpellChecker class has a
+string as parameter, which is checked for proper exactness. The SpellChecker class has a
required/multiple (1..N) dependency over every available "DictionaryService" services, which are
-internally used by the SpellChecker command, when checking word existence.
+internally used by the SpellChecker command, when checking word exactness.
A DictionaryService is defined using a FactoryConfigurationAdapterService , allowing to instantiate
many "DictionaryService" instances for each configuration that are added to the
-factory pid "Spell Checker Configuration (api)" from web console.
+factory pid "Spell Checker Configuration" from web console.
The factory pid configuration metatypes are defined using the bnd "metatype" annotations
(see DictionaryConfiguration.java).
The DictionaryService is decorated with a DictionaryAspect, which you can instantiate by adding a
-configuration to the "Spell Checker Aspect Dictionary (api)" pid from web console. The
+configuration to the "Spell Checker Aspect Dictionary" pid from web console. The
aspect configuration metatype is also declared using the bnd metatype annotations (see
DictionaryAspectConfiguration.java).
-Before running this sample, go to webconsole, and add some words in the Spell Checker Configuration (api) factory PID, and
-in the Spell Checker Aspect Dictionary (api) PID.
+Before running this sample, go to webconsole, and add some words in the "Spell Checker Configuration"factory PID, and
+in the "Spell Checker Dictionary Aspect" PID.
Then go to gogo shell, and type dm help. You will normally see the dictionary:spellcheck command.
Type dictionary:spellcheck <some words configured either in the spell checker configuration, or in the spell checker aspect configuration,
-and the dictionary will check for proper word existance in the configuration.
+and the dictionary will check for proper word exactness in the configuration.
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java
index 3f4080b..54bbee3 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/factory/Activator.java
@@ -20,7 +20,9 @@
import static java.lang.System.out;
+import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.lambda.DependencyManagerActivator;
+import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
/**
@@ -28,13 +30,13 @@
*/
public class Activator extends DependencyManagerActivator {
@Override
- public void activate() throws Exception {
+ public void init(BundleContext ctx, DependencyManager dm) throws Exception {
out.println("type \"log info\" to see the logs emitted by this test.");
component(comp -> comp
.factory(ProviderFactory::new, ProviderFactory::create)
.provides(Provider.class)
.start(ProviderImpl::start)
- .withSrv(LogService.class, log -> log.required().cb(ProviderImpl::set)));
+ .withSrv(LogService.class, log -> log.cb(ProviderImpl::set)));
}
}
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java
index 117af23..ec580ae 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/Activator.java
@@ -20,7 +20,9 @@
import static java.lang.System.out;
+import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.lambda.DependencyManagerActivator;
+import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
/**
@@ -38,7 +40,7 @@
* Initialize our components using new DM-lambda activator base.
*/
@Override
- public void activate() throws Exception {
+ public void init(BundleContext ctx, DependencyManager dm) throws Exception {
out.println("type \"log info\" to see the logs emitted by this test.");
// System.setProperty("http.proxyHost","your.http.proxy.host");
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java
index c6e0895..3017ccf 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/future/PageLinksImpl.java
@@ -37,7 +37,7 @@
.thenApply(this::parseLinks);
// Add the future dependency so we'll be started once the CompletableFuture "futureLinks" has completed.
- component(c, comp -> comp.withFuture(futureLinks, links -> links.cbi(this::setLinks)));
+ component(c, comp -> comp.withFuture(futureLinks, future -> future.cbi(this::setLinks)));
}
// Called when our future has completed.
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
index 8dfd611..8da879d 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/dm/lambda/samples/hello/Activator.java
@@ -20,7 +20,9 @@
import static java.lang.System.out;
+import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.lambda.DependencyManagerActivator;
+import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.log.LogService;
@@ -30,7 +32,7 @@
*/
public class Activator extends DependencyManagerActivator {
@Override
- public void activate() throws Exception {
+ public void init(BundleContext ctx, DependencyManager dm) throws Exception {
out.println("type \"log info\" to see the logs emitted by this test.");
// Creates a Service Provider (property names are deduced from lambda parameter names).
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
index 8ac2366..0c978ea 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/ComponentBuilder.java
@@ -152,10 +152,10 @@
*
* @param iface the public interfaces to register in the OSGI service registry.
* @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
- * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+ * {@link FluentProperty} interface that allows to define a property name using a lambda parameter.
* @return this builder.
*/
- B provides(Class<?> iface, FluentProperties ... properties);
+ B provides(Class<?> iface, FluentProperty ... properties);
/**
* Sets the public interface under which this component should be registered in the OSGi service registry.
@@ -195,10 +195,10 @@
*
* @param ifaces the public interfaces to register in the OSGI service registry.
* @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
- * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+ * {@link FluentProperty} interface that allows to define a property name using a lambda parameter.
* @return this builder.
*/
- B provides(Class<?>[] ifaces, FluentProperties ... properties);
+ B provides(Class<?>[] ifaces, FluentProperty ... properties);
/**
* Sets the public interfaces under which this component should be registered in the OSGi service registry.
@@ -238,10 +238,10 @@
*
* @param iface the public interfaces to register in the OSGI service registry.
* @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
- * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+ * {@link FluentProperty} interface that allows to define a property name using a lambda parameter.
* @return this builder.
*/
- B provides(String iface, FluentProperties ... properties);
+ B provides(String iface, FluentProperty ... properties);
/**
* Sets the public interface under which this component should be registered in the OSGi service registry.
@@ -281,10 +281,10 @@
*
* @param ifaces the public interfaces to register in the OSGI service registry.
* @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the
- * {@link FluentProperties} interface that allows to define a property name using a lambda parameter.
+ * {@link FluentProperty} interface that allows to define a property name using a lambda parameter.
* @return this builder.
*/
- B provides(String[] ifaces, FluentProperties ... properties);
+ B provides(String[] ifaces, FluentProperty ... properties);
/**
* Sets the public interfaces under which this component should be registered in the OSGi service registry.
@@ -330,7 +330,7 @@
* @param properties the fluent properties
* @return this builder
*/
- B properties(FluentProperties ... properties);
+ B properties(FluentProperty ... properties);
/**
* Adds a required/autoconfig service dependency.
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java
index ae511e5..60724c8 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/DependencyManagerActivator.java
@@ -72,21 +72,15 @@
/**
* DependencyManager object used to create/register real DM Components that are built by this activator.
*/
- protected DependencyManager m_manager;
+ private DependencyManager m_manager;
/**
- * Bundle Context asociated to the activator bundle.
- */
- protected BundleContext m_ctx;
-
- /**
* Our Activator is starting.
*/
@Override
public void start(BundleContext context) throws Exception {
m_manager = new DependencyManager(context);
- m_ctx = context;
- activate();
+ init(context, m_manager);
}
/**
@@ -94,20 +88,23 @@
*/
@Override
public void stop(BundleContext context) throws Exception {
- deactivate();
+ destroy();
}
/**
* Sub classes must override this method in order to build some DM components.
+ *
+ * @param ctx the BundleContext associated to the bundle activator.
+ * @param dm the DependencyManager object that can be used to add/remove components.
* @throws Exception if the activation fails
*/
- protected abstract void activate() throws Exception;
+ protected abstract void init(BundleContext ctx, DependencyManager dm) throws Exception;
/**
* Sub classes may override this method that is called when the Activator is stopped.
* @throws Exception if the deactivation fails
*/
- protected void deactivate() throws Exception {
+ protected void destroy() throws Exception {
}
/**
@@ -125,7 +122,7 @@
* @return the bundle context
*/
protected BundleContext getBundleContext() {
- return m_ctx;
+ return m_manager.getBundleContext();
}
/**
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FluentProperties.java b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FluentProperty.java
similarity index 94%
rename from dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FluentProperties.java
rename to dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FluentProperty.java
index 7ee7724..3409ea3 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FluentProperties.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/FluentProperty.java
@@ -24,7 +24,7 @@
* }</pre>
*/
@FunctionalInterface
-public interface FluentProperties extends SerializableLambda {
+public interface FluentProperty extends SerializableLambda {
/**
* Represents a fluent property
*
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java
index c884793..1fd3038 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/AdapterBase.java
@@ -9,7 +9,7 @@
import org.apache.felix.dm.lambda.BundleDependencyBuilder;
import org.apache.felix.dm.lambda.ComponentBuilder;
import org.apache.felix.dm.lambda.ConfigurationDependencyBuilder;
-import org.apache.felix.dm.lambda.FluentProperties;
+import org.apache.felix.dm.lambda.FluentProperty;
import org.apache.felix.dm.lambda.FutureDependencyBuilder;
import org.apache.felix.dm.lambda.ServiceDependencyBuilder;
import org.apache.felix.dm.lambda.callbacks.CbComponent;
@@ -71,7 +71,7 @@
return (B) this;
}
- default B provides(Class<?> iface, FluentProperties ... properties) {
+ default B provides(Class<?> iface, FluentProperty ... properties) {
andThenBuild(compBuilder -> compBuilder.provides(iface, properties));
return (B) this;
}
@@ -91,7 +91,7 @@
return (B) this;
}
- default B provides(Class<?>[] ifaces, FluentProperties ... properties) {
+ default B provides(Class<?>[] ifaces, FluentProperty ... properties) {
andThenBuild(compBuilder -> compBuilder.provides(ifaces, properties));
return (B) this;
}
@@ -111,7 +111,7 @@
return (B) this;
}
- default B provides(String iface, FluentProperties ... properties) {
+ default B provides(String iface, FluentProperty ... properties) {
andThenBuild(compBuilder -> compBuilder.provides(iface, properties));
return (B) this;
}
@@ -131,7 +131,7 @@
return (B) this;
}
- default B provides(String[] ifaces, FluentProperties ... properties) {
+ default B provides(String[] ifaces, FluentProperty ... properties) {
andThenBuild(compBuilder -> compBuilder.provides(ifaces, properties));
return (B) this;
}
@@ -151,7 +151,7 @@
return (B) this;
}
- default B properties(FluentProperties ...properties) {
+ default B properties(FluentProperty ...properties) {
andThenBuild(compBuilder -> compBuilder.properties(properties));
return (B) this;
}
diff --git a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
index 73f2687..a5bab10 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/lambda/impl/ComponentBuilderImpl.java
@@ -26,7 +26,7 @@
import org.apache.felix.dm.lambda.ComponentBuilder;
import org.apache.felix.dm.lambda.ConfigurationDependencyBuilder;
import org.apache.felix.dm.lambda.DependencyBuilder;
-import org.apache.felix.dm.lambda.FluentProperties;
+import org.apache.felix.dm.lambda.FluentProperty;
import org.apache.felix.dm.lambda.FutureDependencyBuilder;
import org.apache.felix.dm.lambda.ServiceDependencyBuilder;
import org.apache.felix.dm.lambda.callbacks.CbComponent;
@@ -98,7 +98,7 @@
}
@Override
- public ComponentBuilderImpl provides(Class<?> iface, FluentProperties ... properties) {
+ public ComponentBuilderImpl provides(Class<?> iface, FluentProperty ... properties) {
provides(iface);
properties(properties);
return this;
@@ -125,7 +125,7 @@
}
@Override
- public ComponentBuilderImpl provides(Class<?>[] ifaces, FluentProperties ... properties) {
+ public ComponentBuilderImpl provides(Class<?>[] ifaces, FluentProperty ... properties) {
provides(ifaces);
properties(properties);
return this;
@@ -152,7 +152,7 @@
}
@Override
- public ComponentBuilderImpl provides(String iface, FluentProperties ... properties) {
+ public ComponentBuilderImpl provides(String iface, FluentProperty ... properties) {
provides(iface);
properties(properties);
return this;
@@ -179,7 +179,7 @@
}
@Override
- public ComponentBuilderImpl provides(String[] ifaces, FluentProperties ... properties) {
+ public ComponentBuilderImpl provides(String[] ifaces, FluentProperty ... properties) {
provides(ifaces);
properties(properties);
return this;
@@ -218,7 +218,7 @@
}
@Override
- public ComponentBuilderImpl properties(FluentProperties ... properties) {
+ public ComponentBuilderImpl properties(FluentProperty ... properties) {
Dictionary<Object, Object> props = new Hashtable<>();
Stream.of(properties).forEach(property -> {
String name = Helpers.getLambdaParameterName(property, 0);