You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2015/02/28 08:23:22 UTC

svn commit: r1662903 [3/4] - in /felix/sandbox/pderop/dependencymanager: ./ cnf/localrepo/ cnf/localrepo/org.apache.felix.eventadmin/ cnf/localrepo/org.apache.felix.http.api/ cnf/localrepo/org.apache.felix.http.servlet-api/ cnf/releaserepo/ org.apache....

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryAspectConfiguration.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryAspectConfiguration.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryAspectConfiguration.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryAspectConfiguration.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,19 @@
+package org.apache.felix.dependencymanager.samples.dictionary.annot;
+
+import java.util.List;
+
+import aQute.bnd.annotation.metatype.Meta.AD;
+import aQute.bnd.annotation.metatype.Meta.OCD;
+
+/**
+ * This interface describes the configuration for our DictionaryAspect component. We are using the bnd metatype
+ * annotations, allowing to configure our Dictionary Services from web console.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@OCD(name="Spell Checker Aspect Dictionary (annotation)",
+     description = "Declare here the list of english words to be added into the default english dictionary")
+public interface DictionaryAspectConfiguration {
+    @AD(description = "Dictionary aspect words")
+    List<String> words();
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryConfiguration.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryConfiguration.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryConfiguration.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryConfiguration.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,23 @@
+package org.apache.felix.dependencymanager.samples.dictionary.annot;
+
+import java.util.List;
+
+import aQute.bnd.annotation.metatype.Meta.AD;
+import aQute.bnd.annotation.metatype.Meta.OCD;
+
+/**
+ * This interface describes the configuration for our DictionaryImpl component. We are using the bnd metatype
+ * annotations, allowing to configure our Dictionary Services from web console.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@OCD(name="Spell Checker Dictionary (annotation)", 
+     factory = true, 
+     description = "Declare here some Dictionary instances, allowing to instantiates some DictionaryService services for a given dictionary language")
+public interface DictionaryConfiguration {
+    @AD(description = "Describes the dictionary language", deflt = "en")
+    String lang();
+
+    @AD(description = "Declare here the list of words supported by this dictionary. This properties starts with a Dot and won't be propagated with Dictionary OSGi service properties")
+    List<String> words();
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dependencymanager.samples.dictionary.annot;
+
+import java.util.Dictionary;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.felix.dm.annotation.api.FactoryConfigurationAdapterService;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.osgi.service.log.LogService;
+
+import aQute.bnd.annotation.metatype.Configurable;
+
+/**
+ * A Dictionary Service. This service uses a FactoryConfigurationAdapterService annotation, 
+ * allowing to instantiate this service from webconsole. This annotation will actually register
+ * a ManagedServiceFactory in the registry. The Configuration metatype informations is described using the
+ * bnd metatype information (see the DictionaryConfiguration interface).
+ * 
+ * You must configure at least one Dictionary from web console, since the SpellCheck won't start if no Dictionary
+ * Service is available.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@FactoryConfigurationAdapterService(factoryPidClass = DictionaryConfiguration.class, propagate = true, updated = "updated")
+public class DictionaryImpl implements DictionaryService {
+    /**
+     * We store all configured words in a thread-safe data structure, because ConfigAdmin
+     * may invoke our updated method at any time.
+     */
+    private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>();
+
+    /**
+     * We'll use the OSGi log service for logging. If no log service is available, then we'll use a NullObject.
+     */
+    @ServiceDependency(required = false)
+    private LogService m_log;
+
+    /**
+     * 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").
+     */
+    protected void updated(Dictionary<String, ?> config) {
+        if (config != null) {
+            // We use the bnd "Configurable" helper in order to get an implementation for our DictionaryConfiguration interface.
+            DictionaryConfiguration cnf = Configurable.createConfigurable(
+                DictionaryConfiguration.class, config);
+
+            m_lang = cnf.lang();
+            m_words.clear();
+            for (String word : cnf.words()) {
+                m_words.add(word);
+            }
+        }
+    }
+
+    /**
+     * A new Dictionary Service is starting (because a new factory configuration has been created
+     * from webconsole).
+     */
+    @Start
+    protected void start() {
+        m_log.log(LogService.LOG_INFO, "Starting Dictionary Service with language: " + m_lang);
+    }
+
+    /**
+     * Check if a word exists if the list of words we have been configured from ConfigAdmin/WebConsole.
+     */
+    public boolean checkWord(String word) {
+        return m_words.contains(word);
+    }
+
+    @Override
+    public String toString() {
+        return "Dictionary: language=" + m_lang + ", words=" + m_words;
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryService.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryService.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryService.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dependencymanager.samples.dictionary.annot;
+
+/**
+ * A simple service interface that defines a dictionary service. A dictionary
+ * service simply verifies the existence of a word. 
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface DictionaryService {
+    /**
+     * Check for the existence of a word.
+     * 
+     * @param word the word to be checked.
+     * @return true if the word is in the dictionary, false otherwise.
+     */
+    public boolean checkWord(String word);
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/README?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/README (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/README Sat Feb 28 07:23:20 2015
@@ -0,0 +1,16 @@
+This sample shows a "SpellChecker" application (using DM Annotations) 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
+required/multiple (1..N) dependency over every available "DictionaryService" services, which are
+internally used by the SpellChecker command, when checking word existence.
+
+A DictionaryService is defined using a FactoryConfigurationAdapterService , allowing to instantiate
+many "DictionaryService" instances when some configurations are added to the
+"Spell Checker Dictionary (api)" factory pid 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 (annotation)" factory pid from web console. The
+aspect configuration metatype is also declared using the bnd metatype annotations (see
+DictionaryAspectConfiguration.java). 

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/SpellChecker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/SpellChecker.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/SpellChecker.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/SpellChecker.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dependencymanager.samples.dictionary.annot;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.service.command.CommandProcessor;
+import org.apache.felix.service.command.Descriptor;
+import org.osgi.service.log.LogService;
+
+/**
+ * Felix "spellcheck" Gogo Shell Command. This command allows to check if some given words are valid or not.
+ * This command will be activated only if (at least) one DictionaryService has been injected.
+ * To create a Dictionary Service, you have to go the the web console and define a "Dictionary Services" factory
+ * configuration instance, which will fire an instantiation of the corresponding dictionary service.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component(provides = { SpellChecker.class }, properties = {
+        @Property(name = CommandProcessor.COMMAND_SCOPE, value = "dictionary.annotation"),
+        @Property(name = CommandProcessor.COMMAND_FUNCTION, value = "spellcheck" ) })
+public class SpellChecker {
+    /**
+     * We'll use the OSGi log service for logging. If no log service is available, then we'll use a NullObject.
+     */
+    @ServiceDependency(required = false)
+    private volatile LogService m_log;
+
+    /**
+     * We'll store all Dictionaries in a concurrent list, in order to avoid method synchronization.
+     */
+    @ServiceDependency(service = DictionaryService.class)
+    private final Iterable<DictionaryService> m_dictionaries = new ConcurrentLinkedQueue<>();
+
+    /**
+     * Lifecycle method callback, used to check if our service has been activated.
+     */
+    @Start
+    protected void start() {
+        m_log.log(LogService.LOG_WARNING, "Spell Checker started");
+    }
+
+    /**
+     * Lifecycle method callback, used to check if our service has been activated.
+     */
+    @Stop
+    protected void stop() {
+        m_log.log(LogService.LOG_WARNING, "Spell Checker stopped");
+    }
+
+    // --- Gogo Shell command
+
+    @Descriptor("checks if word is found from an available dictionary")
+    public void spellcheck(@Descriptor("the word to check") String word) {
+        m_log.log(LogService.LOG_INFO, "Checking spelling of word \"" + word + "\" using the following dictionaries: "
+            + m_dictionaries);
+
+        for (DictionaryService dictionary : m_dictionaries) {
+            if (dictionary.checkWord(word)) {
+                System.out.println("word " + word + " is correct");
+                return;
+            }
+        }
+        System.err.println("word " + word + " is incorrect");
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/Activator.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/Activator.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/Activator.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,36 @@
+package org.apache.felix.dependencymanager.samples.dictionary.api;
+
+import java.util.Hashtable;
+
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.apache.felix.service.command.CommandProcessor;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+public class Activator extends DependencyActivatorBase {
+    @Override
+    public void init(BundleContext context, DependencyManager dm) throws Exception {
+        // Create the factory configuration for our DictionaryImpl service.
+        dm.add(createFactoryConfigurationAdapterService(DictionaryConfiguration.class.getName(), "updated", true)
+            .setInterface(DictionaryService.class.getName(), null)
+            .setImplementation(DictionaryImpl.class)
+            .add(createServiceDependency().setService(LogService.class))); // NullObject 
+        
+        // Create the Dictionary Aspect
+        dm.add(createAspectService(DictionaryService.class, "(lang=en)", 10)
+            .setImplementation(DictionaryAspect.class)
+            .add(createConfigurationDependency().setPid(DictionaryAspectConfiguration.class.getName()))
+            .add(createServiceDependency().setService(LogService.class))); // NullObject
+        
+        // Create the SpellChecker component
+        Hashtable<String, Object> props = new Hashtable<>();
+        props.put(CommandProcessor.COMMAND_SCOPE, "dictionary");
+        props.put(CommandProcessor.COMMAND_FUNCTION, new String[] { "spellcheck" });
+        dm.add(createComponent()
+            .setImplementation(SpellChecker.class)
+            .setInterface(SpellChecker.class.getName(), props)
+            .add(createServiceDependency().setService(DictionaryService.class).setRequired(true))
+            .add(createServiceDependency().setService(LogService.class))); // NullObject
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspect.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspect.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspect.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspect.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless
+ * required by applicable law or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dependencymanager.samples.dictionary.api;
+
+import java.util.Dictionary;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.osgi.service.log.LogService;
+
+import aQute.bnd.annotation.metatype.Configurable;
+
+/**
+ * This aspect applies to the English DictionaryService, and allows to decorate it with some
+ * custom English words, which are configurable from WebConsole.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class DictionaryAspect implements DictionaryService {
+    /**
+     * This is the service this aspect is applying to.
+     */
+    private volatile DictionaryService m_originalDictionary;
+
+    /**
+     * We store all configured words in a thread-safe data structure, because ConfigAdmin may
+     * invoke our updated method at any time.
+     */
+    private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>();
+
+    /**
+     * We'll use the OSGi log service for logging. If no log service is available, then we'll
+     * use a NullObject.
+     */
+    private LogService m_log;
+
+    /**
+     * Defines a configuration dependency for retrieving our english custom words (by default,
+     * our PID is our full class name).
+     */
+    protected void updated(Dictionary<String, ?> config) {
+        if (config != null) {
+            // We use the bnd "Configurable" helper in order to get an implementation for our DictionaryConfiguration interface.
+            DictionaryConfiguration cnf = Configurable.createConfigurable(DictionaryConfiguration.class, config);
+            m_words.clear();
+            for (String word : cnf.words()) {
+                m_words.add(word);
+            }
+        }
+    }
+
+    /**
+     * Our Aspect Service is starting and is about to be registered in the OSGi regsitry.
+     */
+    protected void start() {
+        m_log.log(LogService.LOG_INFO, "Starting aspect Dictionary with words: " + m_words
+            + "; original dictionary service=" + m_originalDictionary);
+    }
+
+    /**
+     * Checks if a word is found from our custom word list. if not, delegate to the decorated
+     * dictionary.
+     */
+    public boolean checkWord(String word) {
+        m_log.log(LogService.LOG_INFO, "DictionaryAspect: checking word " + word + " (original dictionary="
+            + m_originalDictionary + ")");
+        if (m_words.contains(word)) {
+            return true;
+        }
+        return m_originalDictionary.checkWord(word);
+    }
+
+    public String toString() {
+        return "DictionaryAspect: words=" + m_words + "; original dictionary=" + m_originalDictionary;
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspectConfiguration.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspectConfiguration.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspectConfiguration.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryAspectConfiguration.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,19 @@
+package org.apache.felix.dependencymanager.samples.dictionary.api;
+
+import java.util.List;
+
+import aQute.bnd.annotation.metatype.Meta.AD;
+import aQute.bnd.annotation.metatype.Meta.OCD;
+
+/**
+ * This interface describes the configuration for our DictionaryAspect component. We are using the bnd metatype
+ * annotations, allowing to configure our Dictionary Services from web console.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@OCD(name="Spell Checker Aspect Dictionary (api)",
+     description = "Declare here the list of english words to be added into the default english dictionary")
+public interface DictionaryAspectConfiguration {
+    @AD(description = "Dictionary aspect words")
+    List<String> words();
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryConfiguration.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryConfiguration.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryConfiguration.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryConfiguration.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,23 @@
+package org.apache.felix.dependencymanager.samples.dictionary.api;
+
+import java.util.List;
+
+import aQute.bnd.annotation.metatype.Meta.AD;
+import aQute.bnd.annotation.metatype.Meta.OCD;
+
+/**
+ * This interface describes the configuration for our DictionaryImpl component. We are using the bnd metatype
+ * annotations, allowing to configure our Dictionary Services from web console.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@OCD(name="Spell Checker Dictionary (api)",
+     factory = true, 
+     description = "Declare here some Dictionary instances, allowing to instantiates some DictionaryService services for a given dictionary language")
+public interface DictionaryConfiguration {
+    @AD(description = "Describes the dictionary language", deflt = "en")
+    String lang();
+
+    @AD(description = "Declare here the list of words supported by this dictionary.")
+    List<String> words();
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryImpl.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryImpl.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryImpl.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dependencymanager.samples.dictionary.api;
+
+import java.util.Dictionary;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.osgi.service.log.LogService;
+
+import aQute.bnd.annotation.metatype.Configurable;
+
+/**
+ * A Dictionary Service, instantiated from webconsole, when you add some configurations instances to the
+ * DictionaryConfiguration factory pid. The Configuration metatype informations is described using the
+ * bnd metatype information (see the DictionaryConfiguration interface).
+ * 
+ * You must configure at least one Dictionary from web console, since the SpellCheck won't start if no Dictionary
+ * Service is available.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class DictionaryImpl implements DictionaryService {
+    /**
+     * The key of our config admin dictionary values.
+     */
+    final static String WORDS = "words";
+
+    /**
+     * We store all configured words in a thread-safe data structure, because ConfigAdmin
+     * may invoke our updated method at any time.
+     */
+    private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>();
+
+    /**
+     * We'll use the OSGi log service for logging. If no log service is available, then we'll use a NullObject.
+     */
+    private LogService m_log;
+
+    /**
+     * 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").
+     */
+    protected void updated(Dictionary<String, ?> config) {
+        if (config != null) {
+            // We use the bnd "Configurable" helper in order to get an implementation for our DictionaryConfiguration interface.
+            DictionaryConfiguration cnf = Configurable.createConfigurable(DictionaryConfiguration.class, config);
+
+            m_lang = cnf.lang();
+            m_words.clear();
+            for (String word : cnf.words()) {
+                m_words.add(word);
+            }
+        }
+    }
+
+    /**
+     * A new Dictionary Service is starting (because a new factory configuration has been created
+     * from webconsole).
+     */
+    protected void start() {
+        m_log.log(LogService.LOG_INFO, "Starting Dictionary Service with language: " + m_lang);
+    }
+
+    /**
+     * Check if a word exists if the list of words we have been configured from ConfigAdmin/WebConsole.
+     */
+    public boolean checkWord(String word) {
+        return m_words.contains(word);
+    }
+
+    @Override
+    public String toString() {
+        return "Dictionary: language=" + m_lang + ", words=" + m_words;
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryService.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryService.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/DictionaryService.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dependencymanager.samples.dictionary.api;
+
+/**
+ * A simple service interface that defines a dictionary service. A dictionary
+ * service simply verifies the existence of a word. 
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface DictionaryService {
+    /**
+     * Check for the existence of a word.
+     * 
+     * @param word the word to be checked.
+     * @return true if the word is in the dictionary, false otherwise.
+     */
+    public boolean checkWord(String word);
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/README?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/README (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/README Sat Feb 28 07:23:20 2015
@@ -0,0 +1,16 @@
+This sample shows a "SpellChecker" application (using DM API) 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
+required/multiple (1..N) dependency over every available "DictionaryService" services, which are
+internally used by the SpellChecker command, when checking word existence.
+
+A DictionaryService is defined using a FactoryConfigurationAdapterService , allowing to instantiate
+many "DictionaryService" instances when some configurations are added to the
+"Spell Checker Configuration (api)" factory pid 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
+aspect configuration metatype is also declared using the bnd metatype annotations (see
+DictionaryAspectConfiguration.java). 

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/SpellChecker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/SpellChecker.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/SpellChecker.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/SpellChecker.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dependencymanager.samples.dictionary.api;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.felix.service.command.Descriptor;
+import org.osgi.service.log.LogService;
+
+/**
+ * Felix "spellcheck" Gogo Shell Command. This command allows to check if some given words are valid or not.
+ * This command will be activated only if (at least) one DictionaryService has been injected.
+ * To create a Dictionary Service, you have to go the the web console and add a configuration in the 
+ * "Dictionary Configuration" factory pid.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class SpellChecker {
+    /**
+     * We'll use the OSGi log service for logging. If no log service is available, then we'll use a NullObject.
+     */
+    private volatile LogService m_log;
+
+    /**
+     * We'll store all Dictionaries in a concurrent list, in order to avoid method synchronization.
+     * (Auto-Injected from Activator, at any time).
+     */
+    private final Iterable<DictionaryService> m_dictionaries = new ConcurrentLinkedQueue<>();
+
+    /**
+     * Lifecycle method callback, used to check if our service has been activated.
+     */
+    protected void start() {
+        m_log.log(LogService.LOG_WARNING, "Spell Checker started");
+    }
+
+    /**
+     * Lifecycle method callback, used to check if our service has been activated.
+     */
+    protected void stop() {
+        m_log.log(LogService.LOG_WARNING, "Spell Checker stopped");
+    }
+
+    // --- Gogo Shell command
+
+    @Descriptor("checks if word is found from an available dictionary")
+    public void spellcheck(@Descriptor("the word to check") String word) {
+        m_log.log(LogService.LOG_INFO, "Checking spelling of word \"" + word + "\" using the following dictionaries: "
+            + m_dictionaries);
+
+        for (DictionaryService dictionary : m_dictionaries) {
+            if (dictionary.checkWord(word)) {
+                System.out.println("word " + word + " is correct");
+                return;
+            }
+        }
+        System.err.println("word " + word + " is incorrect");
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependency.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependency.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependency.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,75 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.annot;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.ConfigurationDependency;
+import org.apache.felix.dm.annotation.api.Init;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.log.LogService;
+
+import aQute.bnd.annotation.metatype.Configurable;
+
+/**
+ * This Component depends on the following services declared from the Activator:
+ * - LogService
+ * - Configuration with PID="org.apache.felix.dependencymanager.samples.dynamicdep.api.DynamicDependencyConfiguration"
+ * 
+ * We the define a dynamic dependency on a Storage Service from our init method and we configure the dependency filter and
+ * required from using the injected configuration in our updated method.
+ */
+@Component
+public class DynamicDependency {
+	@ServiceDependency
+	volatile EventAdmin eventAdmin;
+	
+	@ServiceDependency
+	volatile LogService log; 
+		
+	@ServiceDependency(name="storage")
+	volatile Storage storage; // dependency defined dynamically from our init() method
+
+	private String storageType; // type of Storage to depend on (we get that from configadmin)
+	private boolean storageRequired; // is our Storage dependency required or not (we get that from configadmin)
+
+	/**
+	 * This is the first callback: we are injected with our configuration.
+	 */
+	@ConfigurationDependency(pidClass=DynamicDependencyConfiguration.class)
+	public void updated(Dictionary<String, Object> properties) throws ConfigurationException {
+        // We use the bnd "Configurable" helper in order to get an implementation for our DictionaryConfiguration interface.
+		DynamicDependencyConfiguration cnf = Configurable.createConfigurable(DynamicDependencyConfiguration.class, properties);
+		storageType = cnf.storageType();
+		storageRequired = cnf.storageRequired();
+	}
+
+	/**
+	 * The configuration has been injected and also other required dependencies defined from the Activator.
+	 * Now, define some dynamic dependencies (here we use the configuration injected from our updated method in 
+	 * order to configure the filter and required flag for the "Storage" dependency).
+	 */
+	@Init
+	Map<String, String> init() {
+		log.log(LogService.LOG_WARNING, "init: storage type=" + storageType + ", storageRequired=" + storageRequired);
+		Map<String, String> props = new HashMap<>();
+		props.put("storage.required", Boolean.toString(storageRequired));
+		props.put("storage.filter", "(type=" + storageType + ")");
+		return props;		
+	}
+	
+	/**
+	 * All dependencies injected, including dynamic dependencies defined from init method.
+	 */
+	@Start
+	void start() {
+		log.log(LogService.LOG_WARNING, "start");
+		// Use storage to load/store some key-value pairs ...
+		storage.store("gabu", "zo");
+	}
+	
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependencyConfiguration.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependencyConfiguration.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependencyConfiguration.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/DynamicDependencyConfiguration.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,25 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.annot;
+
+import aQute.bnd.annotation.metatype.Meta.AD;
+import aQute.bnd.annotation.metatype.Meta.OCD;
+
+/**
+ * This interface describes the configuration for our DynamicDependencyComponent component. We are using the bnd metatype
+ * annotations, allowing to configure our component  from web console.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@OCD(name = "Dynamic Dependency Configuration (annotation)",
+     description = "Declare here the configuration for the DynamicDependency component.")
+public interface DynamicDependencyConfiguration {
+    
+    @AD(description = "Enter the storage type to use", 
+        deflt = "mapdb", 
+        optionLabels = { "Map DB Storage implementation", "File Storage implementation" },
+        optionValues = { "mapdb", "file" })
+    String storageType();
+
+    @AD(description = "Specifies here is the storage dependency is required or not (if false, a null object will be used)", deflt = "true")
+    boolean storageRequired();
+
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/FileStorage.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/FileStorage.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/FileStorage.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/FileStorage.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,26 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.annot;
+
+import java.io.Serializable;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.osgi.service.log.LogService;
+
+@Component(properties={@Property(name="type", value="file")})
+public class FileStorage implements Storage {
+	@ServiceDependency
+	volatile LogService log; // injected
+
+	@Override
+	public void store(String key, Serializable data) {
+		log.log(LogService.LOG_WARNING, "FileStorage.store(" + key + "," + data + ")");
+	}
+
+	@Override
+	public Serializable get(String key) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/MapDBStorage.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/MapDBStorage.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/MapDBStorage.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/MapDBStorage.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,25 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.annot;
+
+import java.io.Serializable;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.osgi.service.log.LogService;
+
+@Component(properties={@Property(name="type", value="mapdb")})
+public class MapDBStorage implements Storage {
+	@ServiceDependency
+	volatile LogService log; // injected
+
+	@Override
+	public void store(String key, Serializable data) {
+		log.log(LogService.LOG_WARNING, "MapDBStorage.store(" + key + "," + data + ")");
+	}
+
+	@Override
+	public Serializable get(String key) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/README?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/README (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/README Sat Feb 28 07:23:20 2015
@@ -0,0 +1,16 @@
+This sample shows how to define a dynamic dependency using annotations.
+
+When you declare a Component:
+
+- the configuration (if any) is first injected (updated callback).
+- then all required dependencies are injected, except "named" dependencies whose required flag and filter can be configured
+dynamically from the init method.
+- then the init method (annotated with @Init) is invoked; And from there you are then able return a Map that will be used
+to configure the required flag and the filter of all named dependencies.
+- then the start callback (annotated with @Start) is invoked when all required dependencies are injected, including named 
+dependencies that have been configured from the init method.
+
+In this sample, the "DynamicDependency" Components configures in its "init" method the dependency having a "storage" name. 
+the dependency "required" flag and filter string are loaded from a Configuration PID 
+(see the "Dynamic Dependency Configuration (annotation)" PID, from webconsole), which is defined using 
+Bnd MetaType Annotations.
\ No newline at end of file

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/Storage.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/Storage.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/Storage.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/annot/Storage.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,8 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.annot;
+
+import java.io.Serializable;
+
+public interface Storage {
+	Serializable get(String key);
+	void store(String key, Serializable data);
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Activator.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Activator.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Activator.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,34 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.api;
+
+import java.util.Properties;
+
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.log.LogService;
+
+public class Activator extends DependencyActivatorBase {
+
+	@Override
+	public void init(BundleContext bc, DependencyManager dm)throws Exception {
+		Properties props = new Properties();
+		props.put("type", "mapdb");
+		dm.add(createComponent()
+				.setImplementation(MapDBStorage.class).setInterface(Storage.class.getName(), props)
+				.add(createServiceDependency().setService(LogService.class).setRequired(true)));
+		
+		props = new Properties();
+		props.put("type", "file");
+		dm.add(createComponent()
+				.setImplementation(FileStorage.class).setInterface(Storage.class.getName(), props)
+				.add(createServiceDependency().setService(LogService.class).setRequired(true)));
+
+		dm.add(createComponent()
+				.setImplementation(DynamicDependency.class)
+				.add(createServiceDependency().setService(LogService.class).setRequired(true))
+				.add(createConfigurationDependency().setPid(DynamicDependencyConfiguration.class.getName()))
+				.add(createServiceDependency().setService(EventAdmin.class).setRequired(true)));
+	}
+
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependency.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependency.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependency.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,60 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.api;
+
+import java.util.Dictionary;
+
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.log.LogService;
+
+import aQute.bnd.annotation.metatype.Configurable;
+
+/**
+ * This Component depends on the following services declared from the Activator:
+ * - LogService
+ * - Configuration with PID="org.apache.felix.dependencymanager.samples.dynamicdep.api.DynamicDependencyConfiguration"
+ * 
+ * We the define a dynamic dependency on a Storage Service from our init method and we configure the dependency filter and
+ * required from using the injected configuration in our updated method.
+ */
+public class DynamicDependency {
+
+	volatile EventAdmin eventAdmin; // injected and defined in Activator
+	volatile LogService log; // injected and defined in Activator
+	volatile Storage storage; // dependency defined dynamically from our init() method
+	private String storageType; // type of Storage to depend on (we get that from configadmin)
+	private boolean storageRequired; // is our Storage dependency required or not (we get that from configadmin)
+
+	/**
+	 * This is the first callback: we are injected with our configuration.
+	 */
+	public void updated(Dictionary<String, Object> properties) throws ConfigurationException {
+        // We use the bnd "Configurable" helper in order to get an implementation for our DictionaryConfiguration interface.
+		DynamicDependencyConfiguration cnf = Configurable.createConfigurable(DynamicDependencyConfiguration.class, properties);
+		storageType = cnf.storageType();
+		storageRequired = cnf.storageRequired();
+	}
+
+	/**
+	 * The configuration has been injected and also other required dependencies defined from the Activator.
+	 * Now, define some dynamic dependencies (here we use the configuration injected from our updated method in 
+	 * order to configure the filter and required flag for the "Storage" dependency).
+	 */
+	public void init(Component c) {
+		log.log(LogService.LOG_WARNING, "init: storage type=" + storageType + ", storageRequired=" + storageRequired);
+		DependencyManager dm = c.getDependencyManager();
+		// all dynamic dependencies must be declared atomically in the Component.add(...) method, which accepts varargs.
+		c.add(dm.createServiceDependency().setService(Storage.class, "(type=" + storageType + ")").setRequired(storageRequired));
+	}
+
+	/**
+	 * All dependencies injected, including dynamic dependencies defined from init method.
+	 */
+	void start() {
+		log.log(LogService.LOG_WARNING, "start");
+		// Use storage to load/store some key-value pairs ...
+		storage.store("gabu", "zo");
+	}
+	
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependencyConfiguration.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependencyConfiguration.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependencyConfiguration.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/DynamicDependencyConfiguration.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,23 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.api;
+
+import aQute.bnd.annotation.metatype.Meta.AD;
+import aQute.bnd.annotation.metatype.Meta.OCD;
+
+/**
+ * This interface describes the configuration for our DynamicDependencyComponent component. We are using the bnd metatype
+ * annotations, allowing to configure our component  from web console.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@OCD(name = "Dynamic Dependency Configuration (api)", 
+     description = "Declare here the configuration for the DynamicDependency component.")
+public interface DynamicDependencyConfiguration {
+    @AD(description = "Enter the storage type to use", 
+    		deflt = "mapdb", 
+    		optionLabels= {"Map DB Storage implementation", "File Storage implementation"},
+    		optionValues={"mapdb", "file"})
+    String storageType();
+
+    @AD(description = "Specifies here is the storage dependency is required or not (if false, a null object will be used)", deflt = "true")
+    boolean storageRequired();
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/FileStorage.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/FileStorage.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/FileStorage.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/FileStorage.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,21 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.api;
+
+import java.io.Serializable;
+
+import org.osgi.service.log.LogService;
+
+public class FileStorage implements Storage {
+	volatile LogService log; // injected
+
+	@Override
+	public void store(String key, Serializable data) {
+		log.log(LogService.LOG_WARNING, "FileStorage.store(" + key + "," + data + ")");
+	}
+
+	@Override
+	public Serializable get(String key) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/MapDBStorage.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/MapDBStorage.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/MapDBStorage.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/MapDBStorage.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,20 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.api;
+
+import java.io.Serializable;
+
+import org.osgi.service.log.LogService;
+
+public class MapDBStorage implements Storage {
+	volatile LogService log; // injected
+
+	@Override
+	public void store(String key, Serializable data) {
+		log.log(LogService.LOG_WARNING, "MapDBStorage.store(" + key + "," + data + ")");
+	}
+
+	@Override
+	public Serializable get(String key) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/README?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/README (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/README Sat Feb 28 07:23:20 2015
@@ -0,0 +1,13 @@
+This sample shows how to define a dynamic dependency from a Component's init method.
+
+When you declare a Component:
+
+- the configuration (if any) is first injected (updated callback).
+- then all required dependencies are injected.
+- then the init(Component c) method is invoked; And from there you are then able to add dynamic dependencies using any previously
+injected services (either configuration injected in update method, or other injected services declared from the Activator).
+- then the start callback is invoked when all required dependencies declared from the init method are injected.
+
+In this sample, the "DynamicDependency" Components defines in its "init" method a dynamic dependency on a Storage service. 
+But it first loads the "storage type" and "storage required" dependency informations from a Configuration PID 
+(see the "Dynamic Dependency Configuration (api)" PID from webconsole), which is defined using Bnd MetaType Annotations.
\ No newline at end of file

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Storage.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Storage.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Storage.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dynamicdep/api/Storage.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,8 @@
+package org.apache.felix.dependencymanager.samples.dynamicdep.api;
+
+import java.io.Serializable;
+
+public interface Storage {
+	Serializable get(String key);
+	void store(String key, Serializable data);
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/README?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/README (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/README Sat Feb 28 07:23:20 2015
@@ -0,0 +1,4 @@
+This sample provides an example with one service consumer and a service provider, both declared
+using DM Annotations. The ServiceConsumer is also depending on a configuration pid  (see
+org.apache.felix.dependencymanager.samples.conf.Configurator).
+

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceConsumer.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceConsumer.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceConsumer.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceConsumer.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,36 @@
+package org.apache.felix.dependencymanager.samples.hello.annot;
+
+import java.util.Dictionary;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.ConfigurationDependency;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.osgi.service.log.LogService;
+
+/**
+ * Our service consumer. We depend on a ServiceProvider, and on a configuration.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component
+public class ServiceConsumer {
+    @ServiceDependency
+    volatile ServiceProvider service;
+
+    @ServiceDependency
+    volatile LogService log;
+
+    Dictionary<?, ?> conf;
+
+    @ConfigurationDependency
+    protected void update(Dictionary<?, ?> conf) {
+        this.conf = conf;
+    }
+
+    @Start
+    public void start() {
+        log.log(LogService.LOG_INFO, "ServiceConsumer.start: calling service.hello() ...");
+        this.service.hello();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProvider.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProvider.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProvider.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,10 @@
+package org.apache.felix.dependencymanager.samples.hello.annot;
+
+/**
+ * The interface for our service provider.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface ServiceProvider {
+    public void hello();
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProviderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProviderImpl.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProviderImpl.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/annot/ServiceProviderImpl.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,21 @@
+package org.apache.felix.dependencymanager.samples.hello.annot;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.osgi.service.log.LogService;
+
+/**
+ * The implementation for our service provider.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component
+public class ServiceProviderImpl implements ServiceProvider {
+    @ServiceDependency
+    volatile LogService log;
+
+    @Override
+    public void hello() {
+        log.log(LogService.LOG_INFO, "ServiceProviderImpl.hello");
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/Activator.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/Activator.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/Activator.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,23 @@
+package org.apache.felix.dependencymanager.samples.hello.api;
+
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+public class Activator extends DependencyActivatorBase {
+    @Override
+    public void init(BundleContext ctx, DependencyManager dm) throws Exception {
+        dm.add(createComponent()
+            .setImplementation(ServiceProviderImpl.class)
+            .add(createServiceDependency().setService(LogService.class).setRequired(true))
+            .setInterface(ServiceProvider.class.getName(), null));
+        
+        dm.add(createComponent()
+            .setImplementation(ServiceConsumer.class)            
+            .add(createServiceDependency().setService(LogService.class).setRequired(true))
+            .add(createConfigurationDependency()
+                .setPid(ServiceConsumer.class.getName()).setCallback("updated"))
+            .add(createServiceDependency().setService(ServiceProvider.class).setRequired(true)));
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/README?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/README (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/README Sat Feb 28 07:23:20 2015
@@ -0,0 +1,4 @@
+This sample provides a DM Activator declaring one service consumer and a service provider. The
+ServiceConsumer is also depending on a configuration pid  (see
+org.apache.felix.dependencymanager.samples.conf.Configurator).
+

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceConsumer.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceConsumer.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceConsumer.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceConsumer.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,25 @@
+package org.apache.felix.dependencymanager.samples.hello.api;
+
+import java.util.Dictionary;
+
+import org.osgi.service.log.LogService;
+
+/**
+ * Our service consumer. We depend on a ServiceProvider, and on a configuration.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ServiceConsumer {
+    volatile ServiceProvider service;
+    volatile LogService log;
+    Dictionary<?, ?> conf;
+
+    protected void update(Dictionary<?, ?> conf) {
+        this.conf = conf;
+    }
+
+    public void start() {
+        log.log(LogService.LOG_INFO, "ServiceConsumer.start: calling service.hello()");
+        this.service.hello();
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProvider.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProvider.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProvider.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,10 @@
+package org.apache.felix.dependencymanager.samples.hello.api;
+
+/**
+ * The interface for our service provider.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface ServiceProvider {
+    public void hello();
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProviderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProviderImpl.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProviderImpl.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/hello/api/ServiceProviderImpl.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,17 @@
+package org.apache.felix.dependencymanager.samples.hello.api;
+
+import org.osgi.service.log.LogService;
+
+/**
+ * The implementation for our service provider.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ServiceProviderImpl implements ServiceProvider {
+    volatile LogService log;
+
+    @Override
+    public void hello() {
+        log.log(LogService.LOG_INFO, "ServiceProviderImpl.hello");
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/Activator.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/Activator.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/Activator.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,20 @@
+package org.apache.felix.dependencymanager.samples.tpool;
+
+import org.apache.felix.dm.ComponentExecutorFactory;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * See README file describing this Activator.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Activator extends DependencyActivatorBase {  
+    @Override
+    public void init(BundleContext context, DependencyManager mgr) throws Exception {
+        mgr.add(createComponent()
+            .setInterface(ComponentExecutorFactory.class.getName(), null)
+            .setImplementation(ComponentExecutorFactoryImpl.class));
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/ComponentExecutorFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/ComponentExecutorFactoryImpl.java?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/ComponentExecutorFactoryImpl.java (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/ComponentExecutorFactoryImpl.java Sat Feb 28 07:23:20 2015
@@ -0,0 +1,17 @@
+package org.apache.felix.dependencymanager.samples.tpool;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.ComponentExecutorFactory;
+
+public class ComponentExecutorFactoryImpl implements ComponentExecutorFactory {
+    final static int SIZE = Runtime.getRuntime().availableProcessors();
+    final static Executor m_threadPool = Executors.newFixedThreadPool(SIZE);
+
+    @Override
+    public Executor getExecutorFor(Component component) {
+        return m_threadPool;
+    }
+}

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/README
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/README?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/README (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/tpool/README Sat Feb 28 07:23:20 2015
@@ -0,0 +1,13 @@
+The Activator you will find in this bundle registers a ComponentExecutorFactory in the OSGi service
+registry to enable parallelism. DependencyManager core will use the Executor returned by the
+ComponentExecutorFactory in order to handle components dependencies/lifecycle callbacks
+concurrently.
+
+Important note: since we are using the DM API to declare our threadpool, we have to disable
+parallelism for our "org.apache.felix.dependencymanager.samples.tpool.ThreadPool" component. 
+To do so, we define the following OSGi service property (see the bnd.bnd configuration file):
+
+->
+
+org.apache.felix.dependencymanager.parallelism=!org.apache.felix.dependencymanager.samples.tpool,*
+

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/test/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/test/.gitignore?rev=1662903&view=auto
==============================================================================
    (empty)

Added: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/tpool.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/tpool.bnd?rev=1662903&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/tpool.bnd (added)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager.samples/tpool.bnd Sat Feb 28 07:23:20 2015
@@ -0,0 +1,3 @@
+Private-Package:  \
+	org.apache.felix.dependencymanager.samples.tpool
+Bundle-Activator: org.apache.felix.dependencymanager.samples.tpool.Activator
\ No newline at end of file

Modified: felix/sandbox/pderop/dependencymanager/release/README.release
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/release/README.release?rev=1662903&r1=1662902&r2=1662903&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/release/README.release (original)
+++ felix/sandbox/pderop/dependencymanager/release/README.release Sat Feb 28 07:23:20 2015
@@ -32,10 +32,12 @@ svn co https://svn.apache.org/repos/asf/
 The next step is to build/test the software and create the release/staging/ directory (where the source/jars will be packaged):
 (replace r<n> by the actual release number, like "r1")
 
+(use a Java7 JDK)
+
 $ cd org.apache.felix.dependencymanager-r<n>
 $ ./gradlew rat 
 $ ./gradlew org.apache.felix.dependencymanager.annotation:jar
-$ ./gradlew jar
+$ ./gradlew jar -x org.apache.felix.dependencymanager.benchmark:jar
 $ ./gradlew test
 $ ./gradlew check
 

Modified: felix/sandbox/pderop/dependencymanager/release/build.gradle
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/release/build.gradle?rev=1662903&r1=1662902&r2=1662903&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/release/build.gradle (original)
+++ felix/sandbox/pderop/dependencymanager/release/build.gradle Sat Feb 28 07:23:20 2015
@@ -75,7 +75,7 @@ Workspace workspace
 workspace = Workspace.getWorkspace(".")
 
 task makeStaging << {
-    description = 'Package the source and binary distributions.'
+    description = 'Packages the source and binary distributions.'
 
     // Package source and source bin dependencies distributions.
     logger.lifecycle("    Packaging source distributions.")
@@ -85,7 +85,7 @@ task makeStaging << {
 		zipfileset(dir: '..', prefix: topdir+"-src", includes: '*.gradle,*.properties')
 		zipfileset(dir: 'resources/src', prefix: topdir+"-src", includes: '*')
 		new File('.').eachFile { 
-	    	if(new File(it, 'bnd.bnd').exists()) {
+	    	if(new File(it, 'bnd.bnd').exists()) {	    		
     			def bndProject = workspace.getProject(it.name)
     			if (! bndProject.isNoBundles()) {
     		    	zipfileset(dir: "../${bndProject.name}", prefix: topdir+"-src/${bndProject.name}",
@@ -109,7 +109,8 @@ task makeStaging << {
     logger.lifecycle("    Packaging binary distribution.")    
     ant.zip(destfile: "staging/"+topdir+"-bin.zip") {
         ant.mappedresources() {
-        	ant.fileset(dir: '..', includes: '*/generated/*.jar', excludes: '*.itest/generated/*.jar')
+            // don't include itests, samples, and benchmark in the convenience binary release.
+        	ant.fileset(dir: '..', includes: '*/generated/*.jar', excludes: '*.itest/generated/*.jar,*.benchmark/generated/*.jar,*.samples/generated/*.jar')
             ant.chainedmapper() {
                 ant.flattenmapper()
                 ant.globmapper(from: '*', to: topdir+'-bin/*')
@@ -126,7 +127,8 @@ task makeStaging << {
 }
 
 // Sign staging directory 
-task signStaging << { 
+task signStaging << {
+    description = 'Signs the local staging distribution.'
     fileTree("staging").visit { FileVisitDetails details -> 
 		logger.lifecycle("    Signing " + details.file.path)
 		ant.exec(executable: 'gpg', dir: 'staging') { 
@@ -154,6 +156,7 @@ task signStaging << {
 
 // Moves the source and binary distributions to staging.
 task commitToStaging << {
+    description = 'Commits the local staging to the Apache svn staging repository.'
     getProject().exec { 
     	commandLine 'svn', 
 		'import', 'staging', svnStagingPath + "/org.apache.felix.dependencymanager-" + dmRelease + "/", 
@@ -162,7 +165,8 @@ task commitToStaging << {
 }
 
 // Promotes the staged distributions to release
-task promoteToRelease << { 
+task promoteToRelease << {
+    description = 'Moves the staging repository to the Apache release repository.'
     getProject().exec { 
     	commandLine 'svn',
 		'move', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease , svnReleasePath, 
@@ -171,7 +175,8 @@ task promoteToRelease << {
 }
 
 // Removes the staged distributions from staging
-task deleteFromStaging << { 
+task deleteFromStaging << {
+    description = 'Cancels the staged distribution from the Apache staging repository.'
     getProject().exec { 
     	commandLine 'svn',
 		'delete', svnStagingPath+"/org.apache.felix.dependencymanager-" + dmRelease + "/",
@@ -186,6 +191,7 @@ task clean(overwrite: true) << {
 }
 
 // Only clean the staging directory
-task cleanStaging << { 
+task cleanStaging << {
+    description = 'Clean the local staging directory.'
     new File("release/staging").deleteDir()
 }