Author: pderop
Date: Thu Nov 20 00:10:25 2014
New Revision: 1640646

URL: http://svn.apache.org/r1640646
Log:
leaned AbstractDependency and the 
org/apache/felix/dependencymanager/samples/customdep sample.
Added javadoc in ComponentContext and DependencyContext.
Removed the generic parameter in the Event class.
Code cleanup.


Added:
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependencyImpl.java
      - copied, changed from r1640254, 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java
Modified:
    felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml
    felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml.sha
    felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml
    
felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml.sha
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/ToggleServiceDependency.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/Activator.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathTracker.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ComponentDependencyDeclaration.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/DependencyManager.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/ComponentContext.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/Event.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleEventImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationEventImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceEventImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceEventImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/test/test/EventImpl.java
    
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/test/test/SimpleServiceDependency.java

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml.sha
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml.sha?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml.sha 
(original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml.sha 
Thu Nov 20 00:10:25 2014
@@ -1 +1 @@
-973f1093334009c3fc722c4c0db968b3b511dbac67d41f5fa6a088af0fdb2f1e
\ No newline at end of file
+c86ef139973958be47edbdb34306a593d72d94af2501e019cba340f7231a1acd
\ No newline at end of file

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml.sha
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml.sha?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml.sha 
(original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml.sha 
Thu Nov 20 00:10:25 2014
@@ -1 +1 @@
-3c825b75114963f936e97dd7d3a3c8b7321ec481e8125607402aaea25abbe88c
\ No newline at end of file
+4180f5ad6088518f5550ad49107569399ccf033d55c5e1eb6a710e5389018339
\ No newline at end of file

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/ToggleServiceDependency.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/ToggleServiceDependency.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/ToggleServiceDependency.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/ToggleServiceDependency.java
 Thu Nov 20 00:10:25 2014
@@ -55,7 +55,7 @@ public class ToggleServiceDependency ext
     }
 
     @Override
-    public String getName() {
+    public String getSimpleName() {
         return "" + isAvailable();
     }
 
@@ -63,4 +63,9 @@ public class ToggleServiceDependency ext
     public String getType() {
         return "toggle";
     }
+
+    @Override
+    public Class<?> getAutoConfigType() {
+        return null; // we don't support auto config mode.
+    }
 }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/Activator.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/Activator.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/Activator.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/Activator.java
 Thu Nov 20 00:10:25 2014
@@ -5,12 +5,16 @@ import org.apache.felix.dm.DependencyMan
 import org.osgi.framework.BundleContext;
 import org.osgi.service.log.LogService;
 
-public class Activator extends DependencyActivatorBase {
+public class Activator extends DependencyActivatorBase {    
+    PathDependency createPathDependency(String path) {
+        return new PathDependencyImpl(path);
+    }
+    
     @Override
     public void init(BundleContext context, DependencyManager m) throws 
Exception {
         m.add(createComponent()
             .setImplementation(PathTracker.class)
             
.add(createServiceDependency().setService(LogService.class).setRequired(true))
-            .add(new PathDependency("/tmp").setCallbacks("add", "remove")));
+            .add(createPathDependency("/tmp").setCallbacks("add", "change", 
"remove").setRequired(true)));
     }
 }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java
 Thu Nov 20 00:10:25 2014
@@ -1,110 +1,13 @@
 package org.apache.felix.dependencymanager.samples.customdep;
 
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardWatchEventKinds;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchEvent.Kind;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.List;
+import org.apache.felix.dm.Dependency;
 
-import org.apache.felix.dm.context.AbstractDependency;
-import org.apache.felix.dm.context.DependencyContext;
-import org.apache.felix.dm.context.Event;
-
-public class PathDependency extends AbstractDependency<PathDependency> 
implements Runnable {
-    private final String m_path;
-    private volatile Thread m_thread;
-
-    public PathDependency(String path) {
-        super.setRequired(true);
-        m_path = path;
-    }
-
-    public PathDependency(PathDependency prototype) {
-        super(prototype);
-        m_path = prototype.m_path;
-    }
-
-    @Override
-    public DependencyContext createCopy() {
-        return new PathDependency(this);
-    }
-
-    @Override
-    public String getName() {
-        return m_path;
-    }
-
-    @Override
-    public String getType() {
-        return "path";
-    }
-
-    @Override
-    public void start() {
-        m_thread = new Thread(this);
-        m_thread.start();
-        super.start();
-    }
-
-    @Override   
-    public void stop() {
-        m_thread.interrupt();
-        super.stop();
-    }
-    
-    @Override   
-    public void invokeAdd(Event e) {
-        if (m_add != null) {
-            invoke(m_add, e, getInstances());
-        }
-    }
-    
-    @Override   
-    public void invokeRemove(Event e) {
-        if (m_remove != null) {
-            invoke(m_remove, e, getInstances());
-        }
-    }
-    
-    private void invoke(String method, Event e, Object[] instances) {
-        // specific for this type of dependency
-        m_component.invokeCallbackMethod(instances, method, 
-            new Class[][] { {String.class}, 
-                            {}}, 
-            new Object[][] { { e.getEvent() }, 
-                            {}});
-    }
-
-    public void run() {
-        Path myDir = Paths.get(m_path);
-
-        try {
-            WatchService watcher = myDir.getFileSystem().newWatchService();
-            myDir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, 
StandardWatchEventKinds.ENTRY_DELETE);
-            while (! Thread.currentThread().isInterrupted()) {
-                               WatchKey watckKey = watcher.take();
-
-                               List<WatchEvent<?>> events = 
watckKey.pollEvents();
-
-                               for (WatchEvent event : events) {
-                                       final Kind<?> kind = event.kind();
-                                       if (StandardWatchEventKinds.OVERFLOW == 
kind) {
-                                               continue;
-                                       }
-                                       if 
(StandardWatchEventKinds.ENTRY_CREATE == kind) {
-                                       m_component.handleAdded(this, new 
Event(event.context().toString()));
-                                       } else if 
(StandardWatchEventKinds.ENTRY_DELETE == kind) {
-                                           m_component.handleRemoved(this, new 
Event(event.context().toString()));
-                                       }
-                               }
-                               
-                               watckKey.reset();
-            }
-        } catch (Throwable e) {
-            e.printStackTrace();
-        }
-    }
-}
\ No newline at end of file
+/**
+ * A custom Dependency Manager Path Dependency that can track a path directory.
+ * When a file is added or removed from the path dir, then the component is 
called
+ * in the corresponding add/remove callback.
+ */
+public interface PathDependency extends Dependency {
+    PathDependency setRequired(boolean required);
+    PathDependency setCallbacks(String add, String change, String remove);
+}

Copied: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependencyImpl.java
 (from r1640254, 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java)
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependencyImpl.java?p2=felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependencyImpl.java&p1=felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java&r1=1640254&r2=1640646&rev=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependency.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathDependencyImpl.java
 Thu Nov 20 00:10:25 2014
@@ -13,33 +13,44 @@ import org.apache.felix.dm.context.Abstr
 import org.apache.felix.dm.context.DependencyContext;
 import org.apache.felix.dm.context.Event;
 
-public class PathDependency extends AbstractDependency<PathDependency> 
implements Runnable {
+/**
+ * This is our own "path" Dependency Manager Dependency, which can track the 
presence of files in a given path dir.
+ * Every DM custom dependency must implement the DependencyContext interface, 
but we extends the AbstractDependency 
+ * which already implements most of the DependencyContext methods.
+ * 
+ */
+public class PathDependencyImpl extends AbstractDependency<PathDependencyImpl> 
implements PathDependency, Runnable {
     private final String m_path;
     private volatile Thread m_thread;
 
-    public PathDependency(String path) {
+    /**
+     * Creates a new custom DM "path" dependency.
+     * @param path the directory to watch for
+     */
+    public PathDependencyImpl(String path) {
         super.setRequired(true);
         m_path = path;
     }
-
-    public PathDependency(PathDependency prototype) {
+    
+    /**
+     * Create a new PathDependency from an existing prototype.
+     * @param prototype the existing PathDependency.
+     */
+    public PathDependencyImpl(PathDependencyImpl prototype) {
         super(prototype);
         m_path = prototype.m_path;
     }
 
-    @Override
-    public DependencyContext createCopy() {
-        return new PathDependency(this);
-    }
+    // ---------- DependencyContext interface ----------
 
     @Override
-    public String getName() {
-        return m_path;
+    public DependencyContext createCopy() {
+        return new PathDependencyImpl(this);
     }
-
+    
     @Override
-    public String getType() {
-        return "path";
+    public Class<?> getAutoConfigType() {
+        return null; // we don't support auto config mode
     }
 
     @Override
@@ -63,27 +74,48 @@ public class PathDependency extends Abst
     }
     
     @Override   
+    public void invokeChange(Event e) {
+        if (m_change != null) {
+            invoke(m_change, e, getInstances());
+        }
+    }
+    
+    @Override   
     public void invokeRemove(Event e) {
         if (m_remove != null) {
             invoke(m_remove, e, getInstances());
         }
     }
     
-    private void invoke(String method, Event e, Object[] instances) {
-        // specific for this type of dependency
-        m_component.invokeCallbackMethod(instances, method, 
-            new Class[][] { {String.class}, 
-                            {}}, 
-            new Object[][] { { e.getEvent() }, 
-                            {}});
+    // ---------- ComponentDependencyDeclaration interface -----------
+    
+    /**
+     * Returns the name of this dependency (a generic name with optional info 
separated by spaces).
+     * The DM Shell will use this method when displaying the dependency
+     **/
+    @Override
+    public String getSimpleName() {
+        return m_path;
+    }
+
+    /**
+     * Returns the name of the type of this dependency. Used by the DM shell 
when displaying the dependency.
+     **/
+    @Override
+    public String getType() {
+        return "path";
     }
 
+    /**
+     * Our start method fires a thread and this is our run method, which is 
watching for a given directory path
+     */    
     public void run() {
         Path myDir = Paths.get(m_path);
 
         try {
             WatchService watcher = myDir.getFileSystem().newWatchService();
-            myDir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, 
StandardWatchEventKinds.ENTRY_DELETE);
+            myDir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE, 
StandardWatchEventKinds.ENTRY_MODIFY,
+                StandardWatchEventKinds.ENTRY_DELETE);
             while (! Thread.currentThread().isInterrupted()) {
                                WatchKey watckKey = watcher.take();
 
@@ -95,8 +127,17 @@ public class PathDependency extends Abst
                                                continue;
                                        }
                                        if 
(StandardWatchEventKinds.ENTRY_CREATE == kind) {
+                                           // Notify the component 
implementation context that a file has been created.
+                                           // Later, the component will call 
our invokeAdd method in order to inject the file
+                                           // in the component instance
                                        m_component.handleAdded(this, new 
Event(event.context().toString()));
-                                       } else if 
(StandardWatchEventKinds.ENTRY_DELETE == kind) {
+                                       } else if 
(StandardWatchEventKinds.ENTRY_MODIFY == kind) {
+                                           // Notify the component 
implementation context that a file has changed.
+                        // Later, the component will call our invokeChange 
method in order to call our component "change" callback
+                        m_component.handleChanged(this, new 
Event(event.context().toString()));
+                    } else if (StandardWatchEventKinds.ENTRY_DELETE == kind) {
+                                           // Notify the component 
implementation context that a file has been removed.
+                                           // Later, the component will call 
our invokeRemove method in order to call our component "remove" callback
                                            m_component.handleRemoved(this, new 
Event(event.context().toString()));
                                        }
                                }
@@ -107,4 +148,16 @@ public class PathDependency extends Abst
             e.printStackTrace();
         }
     }
+
+    /**
+     * Invoke either the "add" or "remove" callback of the component 
instance(s).
+     */
+    private void invoke(String method, Event e, Object[] instances) {
+        // specific for this type of dependency
+        m_component.invokeCallbackMethod(instances, method, 
+            new Class[][] { {String.class}, 
+                            {}}, 
+            new Object[][] { { e.getEvent() }, 
+                            {}});
+    }
 }
\ No newline at end of file

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathTracker.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathTracker.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathTracker.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/customdep/PathTracker.java
 Thu Nov 20 00:10:25 2014
@@ -4,11 +4,23 @@ import org.osgi.service.log.LogService;
 
 public class PathTracker {
     volatile LogService logService;
+    
+    void start() {
+        logService.log(LogService.LOG_INFO, "PathTracker.start");
+    }
+    
+    void stop() {
+        logService.log(LogService.LOG_INFO, "PathTracker.stop");
+    }
 
     void add(String path) {
         logService.log(LogService.LOG_INFO, "PathTracker.add: " + path);
     }
     
+    void change(String path) {
+        logService.log(LogService.LOG_INFO, "PathTracker.change: " + path);
+    }
+
     void remove(String path) {
         logService.log(LogService.LOG_INFO, "PathTracker.remove: " + path);
     }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ComponentDependencyDeclaration.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ComponentDependencyDeclaration.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ComponentDependencyDeclaration.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ComponentDependencyDeclaration.java
 Thu Nov 20 00:10:25 2014
@@ -48,7 +48,7 @@ public interface ComponentDependencyDecl
     public static final int STATE_OPTIONAL = 4;
     /** State constant for a required dependency that has not been started 
yet. */
     public static final int STATE_REQUIRED = 5;
-    /** Returns the name of this dependency (a generic name with optional info 
seprated by spaces)*/
+    /** Returns the name of this dependency (a generic name with optional info 
separated by spaces)*/
     public String getName();
     /** Returns the simple dependency name (service classname for example) */
     public String getSimpleName();

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/DependencyManager.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/DependencyManager.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/DependencyManager.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/DependencyManager.java
 Thu Nov 20 00:10:25 2014
@@ -202,7 +202,7 @@ public class DependencyManager {    
      * @return the service dependency
      */
     public ServiceDependency createServiceDependency() {
-        return new ServiceDependencyImpl(m_context);
+        return new ServiceDependencyImpl();
     }
 
     /**
@@ -220,7 +220,7 @@ public class DependencyManager {    
      * @return a new BundleDependency instance.
      */
     public BundleDependency createBundleDependency() {
-        return new BundleDependencyImpl(m_context);
+        return new BundleDependencyImpl();
     }
 
     /**
@@ -229,7 +229,7 @@ public class DependencyManager {    
      * @return the resource dependency
      */
     public ResourceDependency createResourceDependency() {
-        return new ResourceDependencyImpl(m_context);
+        return new ResourceDependencyImpl();
     }
 
     /**

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
 Thu Nov 20 00:10:25 2014
@@ -26,45 +26,116 @@ import java.util.Set;
 
 import org.apache.felix.dm.ComponentDependencyDeclaration;
 import org.apache.felix.dm.Dependency;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
+import org.apache.felix.dm.ServiceDependency;
 
 /**
- * Abstract class for implementing Dependencies
+ * Abstract class for implementing Dependencies.
+ * You can extends this class in order to supply your own custom dependencies 
to any Dependency Manager Component.
  *
  * @param <T> The type of the interface representing a Dependency Manager 
Dependency (must extends the Dependency interface).
  */
-public abstract class AbstractDependency<T extends Dependency> implements 
Dependency, DependencyContext, ComponentDependencyDeclaration
-{
-    protected volatile ComponentContext m_component;
-    protected volatile boolean m_available; // volatile because accessed by 
getState method
+@SuppressWarnings("rawtypes")
+public abstract class AbstractDependency<T extends Dependency> implements
+    Dependency, DependencyContext, ComponentDependencyDeclaration {
+
+    /**
+     * The Component implementation is exposed to Dependencies through this 
interface.
+     */
+    protected ComponentContext m_component;
+
+    /**
+     * Is this Dependency available ? Volatile because the getState method 
(part of the 
+     * {@link ComponentDependencyDeclaration} interface) may be called by any 
thread, at any time.
+     */
+    protected volatile boolean m_available;
+
+    /**
+     * Is this Dependency "instance bound" ? A dependency is "instance bound" 
if it is defined within the component's 
+     * init method, meaning that it won't deactivate the component if it is 
not currently available when being added
+     * from the component's init method.
+     */
     protected boolean m_instanceBound;
-    protected volatile boolean m_required; // volatile because accessed by 
getState method
+
+    /**
+     * Is this dependency required (false by default) ?
+     */
+    protected volatile boolean m_required;
+
+    /**
+     * Component callback used to inject an added dependency.
+     */
     protected String m_add;
+
+    /**
+     * Component callback invoked when the dependency has changed.
+     */
     protected String m_change;
+
+    /**
+     * Component callback invoked when the dependency becomes unavailable.
+     */
     protected String m_remove;
-    protected boolean m_autoConfig;
+
+    /**
+     * Can this Dependency be auto configured in the component instance fields 
?
+     */
+    protected boolean m_autoConfig = true;
+
+    /**
+     * The Component field name where the Dependency can be injected (null 
means any field with a compatible type
+     * will be injected).
+     */
     protected String m_autoConfigInstance;
+
+    /**
+     * Indicates if the setAutoConfig method has been invoked. This flag is 
used to force autoconfig to "false" 
+     * when the setCallbacks method is invoked, unless the setAutoConfig 
method has been called.
+     */
     protected boolean m_autoConfigInvoked;
-    protected volatile boolean m_isStarted; // volatile because accessed by 
getState method
+
+    /**
+     * Has this Dependency been started by the Component implementation ? 
Volatile because the getState method 
+     * (part of the {@link ComponentDependencyDeclaration} interface) may be 
called by any thread, at any time.
+     */
+    protected volatile boolean m_isStarted;
+
+    /**
+     * The object instance on which the dependency callbacks are invoked on. 
Null means the dependency will be
+     * injected to the Component implementation instance(s).
+     */
     protected Object m_callbackInstance;
-    protected volatile boolean m_propagate;
-    protected volatile Object m_propagateCallbackInstance;
+
+    /**
+     * Tells if the dependency service properties have to be propagated to the 
Component service properties.
+     */
+    protected boolean m_propagate;
+
+    /**
+     * The propagate callback instance that is invoked in order to supply 
dynamically some dependency service properties.
+     */
+    protected Object m_propagateCallbackInstance;
+
+    /**
+     * The propagate callback method that is invoked in order to supply 
dynamically some dependency service properties.
+     * @see {@link #m_propagateCallbackInstance}
+     */
     protected volatile String m_propagateCallbackMethod;
-    protected final BundleContext m_context;
-    protected final Bundle m_bundle;
+
+    /**
+     * Default empty dependency properties.
+     */
     protected final static Dictionary<String, Object> EMPTY_PROPERTIES = new 
Hashtable<>(0);
-    
+
+    /**
+     * Creates a new Dependency. By default, the dependency is optional and 
autoconfig.
+     */
     public AbstractDependency() {
-        this(true, null);
-    }
-    
-    public AbstractDependency(boolean autoConfig, BundleContext bc) {
-        m_autoConfig = autoConfig;
-        m_context = bc;
-        m_bundle = m_context != null ? m_context.getBundle() : null;
     }
 
+    /**
+     * Create a clone of a given Dependency.
+     * @param prototype all the fields of the prototype will be copied to this 
dependency.
+     */
     public AbstractDependency(AbstractDependency<T> prototype) {
         m_component = prototype.m_component;
         m_instanceBound = prototype.m_instanceBound;
@@ -79,103 +150,167 @@ public abstract class AbstractDependency
         m_propagate = prototype.m_propagate;
         m_propagateCallbackInstance = prototype.m_propagateCallbackInstance;
         m_propagateCallbackMethod = prototype.m_propagateCallbackMethod;
-        m_context = prototype.m_context;
-        m_bundle = prototype.m_bundle;
     }
 
     // ----------------------- Dependency interface 
-----------------------------
 
+    /**
+     * Is this Dependency required (false by default) ?
+     */
     @Override
     public boolean isRequired() {
         return m_required;
     }
 
+    /**
+     * Is this Dependency satisfied and available ?
+     */
     @Override
     public boolean isAvailable() {
         return m_available;
     }
 
+    /**
+     * Can this dependency be injected in a component class field (by 
reflexion, true by default) ?
+     */
     @Override
     public boolean isAutoConfig() {
         return m_autoConfig;
     }
 
+    /**
+     * Returns the field name when the dependency can be injected to.
+     */
     @Override
     public String getAutoConfigName() {
         return m_autoConfigInstance;
     }
 
+    /**
+     * Returns the propagate callback method that is invoked in order to 
supply dynamically some dependency service properties.
+     * @see {@link #m_propagateCallbackInstance}
+     */
     @Override
     public boolean isPropagated() {
         return m_propagate;
     }
 
+    /**
+     * Returns the dependency service properties (empty by default).
+     */
     @Override
     public Dictionary<String, Object> getProperties() {
         return EMPTY_PROPERTIES;
     }
 
-    // -------------- DependencyContext 
-----------------------------------------------
+    // -------------- DependencyContext interface 
-----------------------------------------------
 
+    /**
+     * Called by the Component implementation before the Dependency can be 
started.
+     */
     @Override
-    public void invokeAdd(Event e) {        
+    public void setComponentContext(ComponentContext component) {
+        m_component = component;
     }
 
+    /**
+     * The Component "add" callback must be invoked with the added dependency 
event.
+     * @param Event the added dependency service event
+     */
     @Override
-    public void invokeChange(Event e) {        
+    public void invokeAdd(Event e) {
     }
 
+    /**
+     * The Component "change" callback must be invoked with the changed 
dependency event.
+     * @param Event the changed dependency service event
+     */
     @Override
-    public void invokeRemove(Event e) {        
+    public void invokeChange(Event e) {
     }
 
+    /**
+     * The Component "remove" callback must be invoked with the removed 
dependency event.
+     * @param Event the removed dependency service event
+     */
     @Override
-    public void invokeSwap(Event event, Event newEvent) {        
+    public void invokeRemove(Event e) {
     }
 
+    /**
+     * If the Dependency supports "swap" callback, then invoke the swap 
callback on the component instance
+     * @param event the previous dependency event that was injected in the 
component instance
+     * @param newEvent the new dependency event that has to replace the old one
+     */
     @Override
-    public void setComponentContext(ComponentContext component) {
-        m_component = component;
+    public void invokeSwap(Event event, Event newEvent) {
     }
 
+    /**
+     * Starts this dependency. Subclasses can override this method but must 
then call super.start().
+     */
     @Override
     public void start() {
         m_isStarted = true;
     }
 
+    /**
+     * Starts this dependency. Subclasses can override this method but must 
then call super.stop().
+     */
     @Override
     public void stop() {
         m_isStarted = false;
     }
 
+    /**
+     * Indicates if this dependency has been started by the Component 
implementation.
+     */
     @Override
     public boolean isStarted() {
         return m_isStarted;
     }
 
+    /**
+     * Called by the Component implementation when the dependency is 
considered to be available.
+     */
     @Override
     public void setAvailable(boolean available) {
         m_available = available;
     }
 
+    /**
+     * Is this Dependency "instance bound" (has been defined within the 
component's init method) ?
+     */
     public boolean isInstanceBound() {
         return m_instanceBound;
     }
 
+    /**
+     * Called by the Component implementation when the dependency is declared 
within the Component's init method.
+     */
     public void setInstanceBound(boolean instanceBound) {
         m_instanceBound = instanceBound;
     }
 
+    /**
+     * Tells if the Component must be first instantiated before starting this 
dependency (false by default).
+     */
     @Override
     public boolean needsInstance() {
         return false;
     }
 
-    @Override
-    public Class<?> getAutoConfigType() {
-        return null; // must be implemented by subclasses if autoconfig mode 
is enabled
-    }
-
+    /**
+     * Returns the type of the field where this dependency can be injected 
(auto config), or return null
+     * if autoconfig is not supported.
+     */
+    @Override
+    public abstract Class<?> getAutoConfigType();
+
+    /**
+     * TODO move this method elsewhere, to DependencyBase for example.
+     */
+    @SuppressWarnings("unchecked")
     @Override
     public Event getService() {
         Event event = m_component.getDependencyEvent(this);
@@ -188,6 +323,9 @@ public abstract class AbstractDependency
         return event;
     }
 
+    /**
+     * Copy all dependency service instances to the given collection.
+     */
     @Override
     public void copyToCollection(Collection<Object> services) {
         Set<Event> events = m_component.getDependencyEvents(this);
@@ -203,6 +341,10 @@ public abstract class AbstractDependency
         }
     }
 
+    /**
+     * Copy all dependency service instances to the given map (key = 
dependency service, value = dependency service properties.
+     */
+    @SuppressWarnings("unchecked")
     @Override
     public void copyToMap(Map<Object, Dictionary<String, ?>> map) {
         Set<Event> events = m_component.getDependencyEvents(this);
@@ -218,27 +360,45 @@ public abstract class AbstractDependency
         }
     }
 
+    /**
+     * Creates a copy of this Dependency.
+     */
     @Override
     public abstract DependencyContext createCopy();
 
     // -------------- ComponentDependencyDeclaration 
-----------------------------------------------
 
+    /**
+     * Returns a description of this dependency (like the dependency service 
class name with associated filters)
+     */
     @Override
-    public abstract String getName();
+    public String getName() {
+        return getSimpleName();
+    }
 
+    /**
+     * Returns a simple name for this dependency (like the dependency service 
class name).
+     */
     @Override
-    public abstract String getType();
-    
+    public abstract String getSimpleName();
+
+    /**
+     * Returns the dependency symbolic type.
+     */
     @Override
-    public String getSimpleName() {
-        return getName();
-    }
-    
+    public abstract String getType();
+
+    /**
+     * Returns the dependency filter, if any.
+     */
     @Override
     public String getFilter() {
         return null;
     }
 
+    /**
+     * Returns this dependency state.
+     */
     @Override
     public int getState() { // Can be called from any threads, but our class 
attributes are volatile
         if (m_isStarted) {
@@ -248,9 +408,17 @@ public abstract class AbstractDependency
                 : ComponentDependencyDeclaration.STATE_OPTIONAL;
         }
     }
-    
+
     // -------------- Methods common to sub interfaces of Dependendency
-    
+
+    /**
+     * Activates Dependency service properties propagation (to the service 
properties of the component to which this
+     * dependency is added).
+     * 
+     * @param propagate true if the dependency service properties must be 
propagated to the service properties of 
+     * the component to which this dependency is added. 
+     * @return this dependency instance
+     */
     @SuppressWarnings("unchecked")
     public T setPropagate(boolean propagate) {
         ensureNotActive();
@@ -258,6 +426,14 @@ public abstract class AbstractDependency
         return (T) this;
     }
 
+    /**
+     * Sets a callback instance which can ba invoked with the given method in 
order to dynamically retrieve the 
+     * dependency service properties. 
+     * 
+     * @param instance the callback instance
+     * @param method the method to invoke on the callback instance
+     * @return this dependency instance
+     */
     @SuppressWarnings("unchecked")
     public T setPropagate(Object instance, String method) {
         setPropagate(instance != null && method != null);
@@ -265,19 +441,55 @@ public abstract class AbstractDependency
         m_propagateCallbackMethod = method;
         return (T) this;
     }
-    
+
+    /**
+     * Sets the add/remove callbacks.
+     * @param add the callback to invoke when a dependency is added
+     * @param remove the callback to invoke when a dependency is removed
+     * @return this dependency instance
+     */
     public T setCallbacks(String add, String remove) {
         return setCallbacks(add, null, remove);
     }
 
+    /**
+     * Sets the add/change/remove callbacks.
+     * @param add the callback to invoke when a dependency is added
+     * @param change the callback to invoke when a dependency has changed
+     * @param remove the callback to invoke when a dependency is removed
+     * @return this dependency instance
+     */
     public T setCallbacks(String add, String change, String remove) {
         return setCallbacks(null, add, change, remove);
     }
 
+    /**
+     * Sets the callbacks for this service. These callbacks can be used as 
hooks whenever a
+     * dependency is added or removed. They are called on the instance you 
provide. When you
+     * specify callbacks, the auto configuration feature is automatically 
turned off, because
+     * we're assuming you don't need it in this case.
+     * 
+     * @param instance the instance to call the callbacks on
+     * @param add the method to call when a service was added
+     * @param remove the method to call when a service was removed
+     * @return this service dependency
+     */
     public T setCallbacks(Object instance, String add, String remove) {
         return setCallbacks(instance, add, null, remove);
     }
 
+    /**
+     * Sets the callbacks for this service. These callbacks can be used as 
hooks whenever a
+     * dependency is added, changed or removed. They are called on the 
instance you provide. When you
+     * specify callbacks, the auto configuration feature is automatically 
turned off, because
+     * we're assuming you don't need it in this case.
+     * 
+     * @param instance the instance to call the callbacks on
+     * @param add the method to call when a service was added
+     * @param change the method to call when a service was changed
+     * @param remove the method to call when a service was removed
+     * @return this service dependency
+     */
     @SuppressWarnings("unchecked")
     public T setCallbacks(Object instance, String add, String change, String 
remove) {
         if ((add != null || change != null || remove != null) && 
!m_autoConfigInvoked) {
@@ -290,6 +502,10 @@ public abstract class AbstractDependency
         return (T) this;
     }
 
+    /**
+     * Returns the dependency callback instances
+     * @return the dependency callback instances
+     */
     public Object[] getInstances() {
         if (m_callbackInstance == null) {
             return m_component.getInstances();
@@ -298,35 +514,62 @@ public abstract class AbstractDependency
         }
     }
 
+    /**
+     * @see {@link ServiceDependency#setRequired(boolean)}
+     */
     @SuppressWarnings("unchecked")
     public T setRequired(boolean required) {
         m_required = required;
         return (T) this;
     }
 
+    /**
+     * @see {@link ServiceDependency#setAutoConfig(boolean)}
+     */
     @SuppressWarnings("unchecked")
     public T setAutoConfig(boolean autoConfig) {
+        if (autoConfig && getAutoConfigType() == null) {
+            throw new IllegalStateException("Dependency does not support auto 
config mode");
+        }
         m_autoConfig = autoConfig;
         m_autoConfigInvoked = true;
         return (T) this;
     }
 
+    /**
+     * @see {@link ServiceDependency#setAutoConfig(String instanceName)}
+     */
     @SuppressWarnings("unchecked")
     public T setAutoConfig(String instanceName) {
+        if (instanceName != null && getAutoConfigType() == null) {
+            throw new IllegalStateException("Dependency does not support auto 
config mode");
+        }
         m_autoConfig = (instanceName != null);
         m_autoConfigInstance = instanceName;
         m_autoConfigInvoked = true;
         return (T) this;
     }
 
-    public ComponentContext getComponentContext() {
+    /**
+     * Returns the component implementation context
+     * @return the component implementation context
+     */
+    protected ComponentContext getComponentContext() {
         return m_component;
     }
 
+    /**
+     * Returns the default service, or null.
+     * @param nullObject if true, a null object may be returned.
+     * @return the default service
+     */
     protected Object getDefaultService(boolean nullObject) {
         return null;
     }
 
+    /**
+     * Checks if the component dependency is not started.
+     */
     protected void ensureNotActive() {
         if (isStarted()) {
             throw new IllegalStateException("Cannot modify state while 
active.");

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/ComponentContext.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/ComponentContext.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/ComponentContext.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/ComponentContext.java
 Thu Nov 20 00:10:25 2014
@@ -23,24 +23,140 @@ import java.util.Set;
 import java.util.concurrent.Executor;
 
 import org.apache.felix.dm.Component;
-import org.osgi.service.log.LogService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
+/**
+ * This interface is the entry point to the Component implementation context.
+ * It is used by all DependencyManager Dependency implementations.
+ * 
+ * @see DependencyContext interface
+ */
 public interface ComponentContext extends Component {
+    /**
+     * Logs a message using the internal component logger
+     * @param level the LogService log level
+     * @param msg the msg to log
+     * @param err an exception, or null
+     */
     public void log(int level, String msg, Throwable err);
-    public Component setThreadPool(Executor threadPool);
+    
+    /**
+     * Returns the Component's bundle context
+     * @return the Component's bundle context
+     */
+    public BundleContext getBundleContext();
+    
+    /**
+     * Returns the Compoent's bundle.
+     * @return the Compoent's bundle.
+     */
+    public Bundle getBundle();
+    
+    /**
+     * Sets a threadpool that the component will use when handling external 
events
+     * @param threadPool a threadpool used to handle component events and 
invoke the component's lifecycle callbacks
+     */
+    public void setThreadPool(Executor threadPool);
+    
+    /**
+     * Starts the component. All initial dependencies previously added to the 
component will be started.
+     */
     public void start();
+    
+    /**
+     * Stops the component.
+     */
     public void stop();
+    
+    /**
+     * Is this component already started ?
+     * @return true if this component has been started
+     */
     public boolean isActive();
+    
+    /**
+     * Is this component available (all required dependencies are available) ?
+     * @return true if this component is available (all dependencies are 
available), or false
+     */
     public boolean isAvailable();
+    
+    /**
+     * Notifies the Component about a new available dependency service. 
+     * @param dc the dependency
+     * @param e the availabe dependency service event
+     */
     public void handleAdded(DependencyContext dc, Event e);
+ 
+    /**
+     * Notifies the Component about a dependency change event 
+     * @param dc the dependency
+     * @param e the dependency change event
+     */
     public void handleChanged(DependencyContext dc, Event e);
+ 
+    /**
+     * Notifies the Component that a dependency service instance becomes 
unavailable.
+     * @param dc the dependency
+     * @param e the dependency service that becomes unavailable
+     */
     public void handleRemoved(DependencyContext dc, Event e);
+ 
+    /**
+     * Notifies the Component that a dependency service instance has been 
swapped by another one.
+     * @param dc the dependency
+     * @param event the dependency service to replace with the new event
+     * @param newEvent the new dependency service that is replacing the old one
+     */
     public void handleSwapped(DependencyContext dc, Event event, Event 
newEvent);
-    public List<DependencyContext> getDependencies(); // for testing only...
+  
+    /**
+     * Returns the list of dependencies that has been registered on this 
component
+     * @return the list of dependencies that has been registered on this 
component
+     */
+    public List<DependencyContext> getDependencies();
+    
+    /**
+     * Invoke a component callback method with a given dependency service 
instance
+     * @param instances the component instances
+     * @param methodName the method name
+     * @param signatures the method signatures (types)
+     * @param parameters the method parameters
+     */
     public void invokeCallbackMethod(Object[] instances, String methodName, 
Class<?>[][] signatures, Object[][] parameters);
+    
+    /**
+     * Returns the component instances
+     * @return the component instances
+     */
     public Object[] getInstances();
+    
+    /**
+     * Returns the component instance field that is assignable to a given 
class type
+     * @param clazz the type of an object that has to be injected in the 
component instance field
+     * @return the name of the component instance field that can be assigned 
to an object having the same type as 
+     * the "clazz" parameter
+     */
     public String getAutoConfigInstance(Class<?> clazz);
+    
+    /**
+     * Indicates if an object of the given class can be injected in one field 
of the component
+     * @param clazz the class of an object that has to be injected in one of 
the component fields
+     * @return true if the component can be injected with an object having the 
specified "clazz" type.
+     */
     public boolean getAutoConfig(Class<?> clazz);
+    
+    /**
+     * Returns the highest ranked dependency service instance for a given 
dependency
+     * @param dc the dependency 
+     * @return the highest ranked dependency service instance for a given 
dependency
+     */
     public Event getDependencyEvent(DependencyContext dc);
+    
+    /**
+     * Returns all the available dependency services for a given dependency
+     * @param dc the dependency 
+     * @return all the available dependency services for a given dependency
+     */
     public Set<Event> getDependencyEvents(DependencyContext dc);
 }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
 Thu Nov 20 00:10:25 2014
@@ -24,29 +24,120 @@ import java.util.Map;
 
 import org.apache.felix.dm.Dependency;
 
+/**
+ * Every DependencyManager Dependency implementations must implement this 
interface.
+ * 
+ * @see {@link AbstractDependency} which already implements most of the 
methods from this interface.
+ */
 public interface DependencyContext extends Dependency {
+    /**
+     * Store the Component implementation context in the Dependency 
Implementation. This object is the entry point to
+     * the Component implementation.
+     * @param component the Component implementation context
+     */
+    public void setComponentContext(ComponentContext component);
+    
+    /**
+     * The Component implementation ask this dependency to invoke the 
component "add" callback for the given dependency service event.
+     * @param e the dependency service event, that has previously been 
submitted to the component implementation using
+     * the ComponentContext.handleAdded method.
+     * @see ComponentContext#handleAdded(DependencyContext, Event)
+     */
        public void invokeAdd(Event e);
+       
+    /**
+     * The Component implementation ask this dependency to invoke the 
component "change" callback for the given dependency service event.
+     * @param e the dependency service event, that has previously been 
submitted to in the component implementation using
+     * the ComponentContext.handleChanged method.
+     * @see ComponentContext#handleChanged(DependencyContext, Event)
+     */
        public void invokeChange(Event e);
+       
+    /**
+     * The Component implementation ask this dependency to invoke the 
component "remove" callback for the given dependency service event.
+     * @param e the dependency service event, that has previously been 
submitted to in the component implementation using
+     * the ComponentContext.handleRemoved method.
+     * @see ComponentContext#handleRemoved(DependencyContext, Event)
+     */
        public void invokeRemove(Event e);
+       
+    /**
+     * The Component implementation ask this dependency to invoke the 
component "swap" callback for the given dependency service event.
+     * @param e the dependency service event, that has previously been 
submitted to in the component implementation using
+     * the ComponentContext.handleSwapped method.
+     * @see ComponentContext#handleSwapped(DependencyContext, Event, Event)
+     */
        public void invokeSwap(Event event, Event newEvent);
-       public void setComponentContext(ComponentContext component);
-       /** Invoked by the component when the dependency should start working. 
*/
+       
+       /**
+        *  Invoked by the component when the dependency should start working. 
+        **/
        public void start();
-       /** Invoked by the component when the dependency should stop working. */
+       
+       /** 
+        * Invoked by the component when the dependency should stop working.
+        **/
        public void stop();
        
+       /**
+        * Returns true if the dependency has been started, false if not
+        * @return true if the dependency has been started, false if not
+        */
        public boolean isStarted();
+       
+       /**
+        * Sets this dependency as available, meaning that at least one 
dependency service is available.
+        * @param available true to mark this dependency as available, false to 
mark it as unavailable
+        */
        public void setAvailable(boolean available);
                
-       public boolean isInstanceBound();
+       /**
+     * Sets this dependency as "instance bound". A dependency is "instance 
bound" if it is defined from the 
+     * component's init method. 
+     * @param true if the dependency has to be marked as "intance bound", 
false if not.
+     */
        public void setInstanceBound(boolean instanceBound);
        
-       /** Does this dependency need the component instances to determine if 
the dependency is available or not */
+       /**
+        * Is this dependency instance bound ?
+        * @return true if this dependency is instance bound, false if not
+        */
+       public boolean isInstanceBound();
+
+       /** 
+        * Does this dependency need the component instances to determine if 
the dependency is available or not.
+        * @return true if the dependency need the component instances before 
it can be started, false if not.
+        **/
        public boolean needsInstance();
        
+       /**
+        * Return the type of the field which can be injected with the 
dependency service.
+        * @return the type of the field which can be injected with the 
dependency service, or null if the dependency does not 
+        * support auto config mode.
+        */
     public Class<?> getAutoConfigType();
+    
+    /**
+     * Returns the highest ranked available dependency service instance, or 
null if the dependency is unavailable. 
+     * @return the highest ranked available dependency service instance, or 
null
+     */
     public Event getService();
+    
+    /**
+     * Copy all the dependency service instances to the given collection.
+     * @param coll the collection where the dependency service instances will 
be copied
+     */
     public void copyToCollection(Collection<Object> coll);
+    
+    /**
+     * Copy all the dependency service instances to the given map (key = 
dependency service, value = dependency servie properties).
+     * @param map the map where the dependency service instances (with the 
corresponding service properties)
+     */
     public void copyToMap(Map<Object, Dictionary<String, ?>> map);
+    
+    /**
+     * Creates a clone of this dependency.
+     * @return a clone of this dependency.
+     */
     public DependencyContext createCopy();
 }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/Event.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/Event.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/Event.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/Event.java
 Thu Nov 20 00:10:25 2014
@@ -25,11 +25,11 @@ import java.util.Hashtable;
  * An event holds all data that belongs to some external event as it comes in 
via
  * the 'changed' callback of a dependency.
  */
-public class Event<T> implements Comparable<Event<T>> {
+public class Event implements Comparable<Event> {
     protected final static Dictionary<String, Object> EMPTY_PROPERTIES = new 
Hashtable<>();
-    private final T m_event;    // the actual event object (a Service, a 
Bundle, a Configuration, etc ...)
+    private final Object m_event;    // the actual event object (a Service, a 
Bundle, a Configuration, etc ...)
     
-    public Event(T event) {
+    public Event(Object event) {
         m_event = event;
     }
 
@@ -38,19 +38,18 @@ public class Event<T> implements Compara
         return m_event.hashCode();
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public boolean equals(Object obj) {
         // an instanceof check here is not "strong" enough with subclasses 
overriding the
         // equals: we need to be sure that a.equals(b) == b.equals(a) at all 
times
         if (obj != null && obj.getClass().equals(Event.class)) {
-            return (((Event<T>) obj).m_event).equals(m_event);
+            return (((Event) obj).m_event).equals(m_event);
         }
         return false;
     }
     
     @Override
-    public int compareTo(Event<T> o) {
+    public int compareTo(Event o) {
         return 0;
     }
     
@@ -63,8 +62,9 @@ public class Event<T> implements Compara
     /**
      * Returns the actual event object wrapped by this event (a Service 
Dependency, a Bundle for Bundle Dependency, etc...).
      */
-    public T getEvent() {
-        return m_event;
+    @SuppressWarnings("unchecked")
+    public <T> T getEvent() {
+        return (T) m_event;
     }
     
     /**

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
 Thu Nov 20 00:10:25 2014
@@ -30,9 +30,9 @@ import org.apache.felix.dm.context.Event
 import org.apache.felix.dm.tracker.BundleTracker;
 import org.apache.felix.dm.tracker.BundleTrackerCustomizer;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.log.LogService;
 
@@ -50,8 +50,7 @@ public class BundleDependencyImpl extend
     private Object m_propagateCallbackInstance;
     private String m_propagateCallbackMethod;
 
-    public BundleDependencyImpl(BundleContext context) {
-        super(true /* autoconfig */, context);
+    public BundleDependencyImpl() {
     }
     
     public BundleDependencyImpl(BundleDependencyImpl prototype) {
@@ -73,7 +72,7 @@ public class BundleDependencyImpl extend
     
     @Override
     public void start() {
-        m_tracker = new BundleTracker(m_context, m_stateMask, this);
+        m_tracker = new BundleTracker(m_component.getBundleContext(), 
m_stateMask, this);
         m_tracker.open();
         super.start();
     }
@@ -169,6 +168,7 @@ public class BundleDependencyImpl extend
         m_component.handleRemoved(this, new BundleEventImpl(bundle, event));
     }
     
+    @SuppressWarnings("rawtypes")
     @Override
     public void invokeAdd(Event e) {
         if (m_add != null) {
@@ -176,6 +176,7 @@ public class BundleDependencyImpl extend
         }
     }
     
+    @SuppressWarnings("rawtypes")
     @Override
     public void invokeChange(Event e) {
         if (m_change != null) {
@@ -183,6 +184,7 @@ public class BundleDependencyImpl extend
         }
     }
 
+    @SuppressWarnings("rawtypes")
     @Override
     public void invokeRemove(Event e) {
         if (m_remove != null) {
@@ -190,6 +192,7 @@ public class BundleDependencyImpl extend
         }
     }
         
+    @SuppressWarnings("rawtypes")
     private void invoke(String method, Event e) {
         BundleEventImpl be = (BundleEventImpl) e;
         m_component.invokeCallbackMethod(getInstances(), method,
@@ -205,7 +208,7 @@ public class BundleDependencyImpl extend
     public BundleDependency setFilter(String filter) throws 
IllegalArgumentException {
         if (filter != null) {
             try {
-                m_filter = m_context.createFilter(filter);
+                m_filter = FrameworkUtil.createFilter(filter);
             } 
             catch (InvalidSyntaxException e) {
                 throw new IllegalArgumentException(e.getMessage());
@@ -224,7 +227,7 @@ public class BundleDependencyImpl extend
         return Bundle.class;
     }
         
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
     public Dictionary<String, Object> getProperties() {
         Event event = getService();
@@ -256,7 +259,7 @@ public class BundleDependencyImpl extend
         Object service = null;
         if (isAutoConfig()) {
             // TODO does it make sense to add support for custom bundle impls?
-//            service = getDefaultImplementation();
+            // service = getDefaultImplementation();
             if (service == null && nullObject) {
                 service = getNullObject();
             }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleEventImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleEventImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleEventImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleEventImpl.java
 Thu Nov 20 00:10:25 2014
@@ -24,7 +24,7 @@ import org.apache.felix.dm.context.Event
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
 
-public class BundleEventImpl extends Event<Bundle> {
+public class BundleEventImpl extends Event {
     final BundleEvent m_event;
     
     public BundleEventImpl(Bundle bundle, BundleEvent event) {
@@ -59,7 +59,6 @@ public class BundleEventImpl extends Eve
         return getBundle().hashCode();
     }
 
-    @SuppressWarnings("rawtypes")
     @Override
     public int compareTo(Event b) {
         return Long.compare(getBundle().getBundleId(), ((BundleEventImpl) 
b).getBundle().getBundleId());

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
 Thu Nov 20 00:10:25 2014
@@ -1272,10 +1272,16 @@ public class ComponentImpl implements Co
         }
     }
     
+    @Override
     public BundleContext getBundleContext() {
         return m_context;
     }
     
+    @Override
+    public Bundle getBundle() {
+        return m_bundle;
+    }
+
     public long getId() {
         return m_id;
     }
@@ -1336,10 +1342,9 @@ public class ComponentImpl implements Co
     }
     
     @Override
-    public Component setThreadPool(Executor threadPool) {
+    public void setThreadPool(Executor threadPool) {
         ensureNotActive();
         m_executor = new DispatchExecutor(threadPool, m_logger);
-        return this;
     }
     
     public Logger getLogger() {

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
 Thu Nov 20 00:10:25 2014
@@ -19,6 +19,7 @@
 package org.apache.felix.dm.impl;
 
 import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
 import java.util.Dictionary;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -42,13 +43,14 @@ public class ConfigurationDependencyImpl
     private MetaTypeProviderImpl m_metaType;
        private final AtomicBoolean m_updateInvokedCache = new AtomicBoolean();
        private final Logger m_logger;
+       private final BundleContext m_context;
 
     public ConfigurationDependencyImpl() {
         this(null, null);
     }
        
     public ConfigurationDependencyImpl(BundleContext context, Logger logger) {
-       super(false /* not autoconfig */, context);
+        m_context = context;
        m_logger = logger;
         setRequired(true);
         setCallback("updated");
@@ -56,11 +58,17 @@ public class ConfigurationDependencyImpl
     
        public ConfigurationDependencyImpl(ConfigurationDependencyImpl 
prototype) {
            super(prototype);
+           m_context = prototype.m_context;
            m_pid = prototype.m_pid;
            m_logger = prototype.m_logger;
         m_metaType = prototype.m_metaType != null ? new 
MetaTypeProviderImpl(prototype.m_metaType, this, null) : null;
        }
        
+    @Override
+    public Class<?> getAutoConfigType() {
+        return null; // we don't support auto config mode.
+    }
+
        @Override
        public DependencyContext createCopy() {
            return new ConfigurationDependencyImpl(this);
@@ -83,14 +91,15 @@ public class ConfigurationDependencyImpl
 
     @Override
     public void start() {
-        if (m_context != null) { // If null, we are in a test environment
+        BundleContext context = m_component.getBundleContext();
+        if (context != null) { // If null, we are in a test environment
                Properties props = new Properties();
                props.put(Constants.SERVICE_PID, m_pid);
                ManagedService ms = this;
                if (m_metaType != null) {
                    ms = m_metaType;
                }
-               m_registration = 
m_context.registerService(ManagedService.class.getName(), ms, props);
+               m_registration = 
context.registerService(ManagedService.class.getName(), ms, props);
         }
         super.start();
     }
@@ -117,7 +126,7 @@ public class ConfigurationDependencyImpl
     }
     
     @Override
-    public String getName() {
+    public String getSimpleName() {
         return m_pid;
     }
     
@@ -288,7 +297,7 @@ public class ConfigurationDependencyImpl
     
     private synchronized void createMetaTypeImpl() {
         if (m_metaType == null) {
-            m_metaType = new MetaTypeProviderImpl(getName(), m_context, 
m_logger, this, null);
+            m_metaType = new MetaTypeProviderImpl(m_pid, m_context, m_logger, 
this, null);
         }
     }
     

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationEventImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationEventImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationEventImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationEventImpl.java
 Thu Nov 20 00:10:25 2014
@@ -4,7 +4,7 @@ import java.util.Dictionary;
 
 import org.apache.felix.dm.context.Event;
 
-public class ConfigurationEventImpl extends Event<Dictionary<String, Object>> {
+public class ConfigurationEventImpl extends Event {
     private final String m_pid;
     
     public ConfigurationEventImpl(String pid, Dictionary<String, Object> conf) 
{
@@ -16,7 +16,6 @@ public class ConfigurationEventImpl exte
         return m_pid;
     }
         
-    @SuppressWarnings("rawtypes")
     @Override
     public int compareTo(Event other) {
         return m_pid.compareTo(((ConfigurationEventImpl) other).m_pid);

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
 Thu Nov 20 00:10:25 2014
@@ -34,6 +34,7 @@ import org.apache.felix.dm.DependencyMan
 import org.apache.felix.dm.context.ComponentContext;
 import org.apache.felix.dm.context.DependencyContext;
 import org.apache.felix.dm.context.Event;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
@@ -338,9 +339,8 @@ public class FilterComponent implements 
        }
        
     @Override
-    public Component setThreadPool(Executor threadPool) {
+    public void setThreadPool(Executor threadPool) {
         m_component.setThreadPool(threadPool);
-        return this;
     }
 
     @Override
@@ -352,4 +352,9 @@ public class FilterComponent implements 
     public void log(int level, String msg, Throwable err) {
         m_component.log(level, msg, err);
     }
+
+    @Override
+    public Bundle getBundle() {
+        return m_component.getBundle();
+    }
 }
\ No newline at end of file

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
 Thu Nov 20 00:10:25 2014
@@ -31,7 +31,6 @@ import org.apache.felix.dm.ResourceHandl
 import org.apache.felix.dm.context.AbstractDependency;
 import org.apache.felix.dm.context.DependencyContext;
 import org.apache.felix.dm.context.Event;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.log.LogService;
 
@@ -43,8 +42,7 @@ public class ResourceDependencyImpl exte
     private volatile String m_resourceFilter;
     private volatile URL m_trackedResource;
 
-    public ResourceDependencyImpl(BundleContext context) {
-        super(true /* autoconfig */, context);
+    public ResourceDependencyImpl() {
     }
     
     public ResourceDependencyImpl(ResourceDependencyImpl prototype) {
@@ -70,7 +68,7 @@ public class ResourceDependencyImpl exte
                 props.put(ResourceHandler.FILTER, m_resourceFilter);
             }
         }
-        m_registration = 
m_context.registerService(ResourceHandler.class.getName(), this, props);
+        m_registration = 
m_component.getBundleContext().registerService(ResourceHandler.class.getName(), 
this, props);
         super.start();
     }
 

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceEventImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceEventImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceEventImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceEventImpl.java
 Thu Nov 20 00:10:25 2014
@@ -23,7 +23,7 @@ import java.util.Dictionary;
 
 import org.apache.felix.dm.context.Event;
 
-public class ResourceEventImpl extends Event<URL> {
+public class ResourceEventImpl extends Event {
     final Dictionary<String, Object> m_resourceProperties;
     
     @SuppressWarnings("unchecked")
@@ -71,7 +71,6 @@ public class ResourceEventImpl extends E
         return result;
     }
 
-    @SuppressWarnings("rawtypes")
     @Override
     public int compareTo(Event that) {
         if (this.equals(that)) {

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
 Thu Nov 20 00:10:25 2014
@@ -32,10 +32,12 @@ import org.apache.felix.dm.Component;
 import org.apache.felix.dm.ComponentDeclaration;
 import org.apache.felix.dm.ServiceDependency;
 import org.apache.felix.dm.context.AbstractDependency;
+import org.apache.felix.dm.context.ComponentContext;
 import org.apache.felix.dm.context.DependencyContext;
 import org.apache.felix.dm.context.Event;
 import org.apache.felix.dm.tracker.ServiceTracker;
 import org.apache.felix.dm.tracker.ServiceTrackerCustomizer;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
@@ -138,8 +140,7 @@ public class ServiceDependencyImpl exten
         }
     }
     
-       public ServiceDependencyImpl(BundleContext ctx) {
-               super(true /* autoconfig */, ctx);
+       public ServiceDependencyImpl() {
        }
        
        public ServiceDependencyImpl(ServiceDependencyImpl prototype) {
@@ -202,17 +203,18 @@ public class ServiceDependencyImpl exten
        @Override
        public void start() {
         if (m_trackedServiceName != null) {
+            BundleContext ctx = m_component.getBundleContext();
             if (m_trackedServiceFilter != null) {
                 try {
-                    m_tracker = new ServiceTracker(m_context, 
m_context.createFilter(m_trackedServiceFilter), this);
+                    m_tracker = new ServiceTracker(ctx, 
ctx.createFilter(m_trackedServiceFilter), this);
                 } catch (InvalidSyntaxException e) {
                     throw new IllegalStateException("Invalid filter definition 
for dependency: "
                         + m_trackedServiceFilter);
                 }
             } else if (m_trackedServiceReference != null) {
-                m_tracker = new ServiceTracker(m_context, 
m_trackedServiceReference, this);
+                m_tracker = new ServiceTracker(ctx, m_trackedServiceReference, 
this);
             } else {
-                m_tracker = new ServiceTracker(m_context, 
m_trackedServiceName.getName(), this);
+                m_tracker = new ServiceTracker(ctx, 
m_trackedServiceName.getName(), this);
             }
         } else {
             throw new IllegalStateException("Could not create tracker for 
dependency, no service name specified.");
@@ -234,7 +236,7 @@ public class ServiceDependencyImpl exten
        @Override
        public Object addingService(ServiceReference reference) {
                try {
-                   return getBundleContext().getService(reference);
+                   return m_component.getBundleContext().getService(reference);
                } catch (IllegalStateException e) {
                    // most likely our bundle is being stopped. Only log an 
exception if our component is enabled.
                    if (m_component.isActive()) {
@@ -250,17 +252,19 @@ public class ServiceDependencyImpl exten
                if (debug) {
                        System.out.println(debugKey + " addedService: ref=" + 
reference + ", service=" + service);
                }
-               m_component.handleAdded(this, new ServiceEventImpl(m_bundle, 
m_context, reference, service));
+               m_component.handleAdded(this, new 
ServiceEventImpl(m_component.getBundle(), m_component.getBundleContext(), 
+                   reference, service));
        }
 
        @Override
        public void modifiedService(ServiceReference reference, Object service) 
{
-           m_component.handleChanged(this, new ServiceEventImpl(m_bundle, 
m_context, reference, service));
+           m_component.handleChanged(this, new 
ServiceEventImpl(m_component.getBundle(), m_component.getBundleContext(), 
+               reference, service));
        }
 
        @Override
        public void removedService(ServiceReference reference, Object service) {
-           m_component.handleRemoved(this, new ServiceEventImpl(m_bundle, 
m_context, reference, service));
+           m_component.handleRemoved(this, new 
ServiceEventImpl(m_component.getBundle(), m_component.getBundleContext(), 
reference, service));
        }
        
        @SuppressWarnings("rawtypes")
@@ -383,11 +387,7 @@ public class ServiceDependencyImpl exten
             throw new IllegalStateException("cannot find service reference");
         }
     }  
-
-    private BundleContext getBundleContext() {
-        return m_context;
-    }
-    
+        
     /** Internal method to set the name, service reference and/or filter. */
     private void setService(Class<?> serviceName, ServiceReference 
serviceReference, String serviceFilter) {
         ensureNotActive();
@@ -554,10 +554,15 @@ public class ServiceDependencyImpl exten
                        // getting out of order.                                
    
                    // We delegate the swap handling to the ComponentImpl, 
which is the class responsible for state management.
                    // The ComponentImpl will first check if the component is 
in the proper state so the swap method can be invoked.                
-                   m_component.handleSwapped(this, new 
ServiceEventImpl(m_bundle, m_context, reference, service), new 
ServiceEventImpl(m_bundle, m_context, newReference, newService));
+                   m_component.handleSwapped(this, new 
ServiceEventImpl(m_component.getBundle(), m_component.getBundleContext(), 
reference, service), 
+                       new ServiceEventImpl(m_component.getBundle(), 
m_component.getBundleContext(), newReference, newService));
                } else {
                        addedService(newReference, newService);
                        removedService(reference, service);
                }
        }       
+       
+    public ComponentContext getComponentContext() {
+        return m_component;
+    }
 }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceEventImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceEventImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceEventImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceEventImpl.java
 Thu Nov 20 00:10:25 2014
@@ -25,7 +25,7 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
-public class ServiceEventImpl extends Event<Object> {
+public class ServiceEventImpl extends Event {
     /**
      * The service reference on which a service dependency depends on
      */
@@ -94,7 +94,6 @@ public class ServiceEventImpl extends Ev
                return getReference().hashCode();
        }
 
-    @SuppressWarnings("rawtypes")
     @Override
     public int compareTo(Event b) {
        return getReference().compareTo(((ServiceEventImpl) b).getReference());

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
 Thu Nov 20 00:10:25 2014
@@ -53,7 +53,6 @@ public class TemporalServiceDependencyIm
      * @see DependencyActivatorBase#createTemporalServiceDependency()
      */
     public TemporalServiceDependencyImpl(BundleContext context, long timeout) {
-        super(context);
         super.setRequired(true);
         if (timeout < 0) {
             throw new IllegalArgumentException("Invalid timeout value: " + 
timeout);
@@ -95,7 +94,7 @@ public class TemporalServiceDependencyIm
             }
         }
         if (makeAvailable) {
-            getComponentContext().handleAdded(this, new 
ServiceEventImpl(m_bundle, m_context, ref, m_serviceInstance));
+            getComponentContext().handleAdded(this, new 
ServiceEventImpl(m_component.getBundle(), m_component.getBundleContext(), ref, 
m_serviceInstance));
         } else {
             // This added will possibly unblock our invoke() method (if it's 
blocked in m_tracker.waitForService method).
         }
@@ -130,11 +129,13 @@ public class TemporalServiceDependencyIm
                 }
             }
             if (makeUnavailable) {
-                m_component.handleRemoved(this, new ServiceEventImpl(m_bundle, 
m_context, ref, m_serviceInstance)); // will unget the service ref
+                // the event.close method will unget the service.
+                m_component.handleRemoved(this, 
+                    new ServiceEventImpl(m_component.getBundle(), 
m_component.getBundleContext(), ref, m_serviceInstance)); 
             }
         } else {
             // Unget what we got in addingService (see ServiceTracker 701.4.1)
-            m_context.ungetService(ref);
+            m_component.getBundleContext().ungetService(ref);
             // if there is no available services, the next call to invoke() 
method will block until another service
             // becomes available. Else the next call to invoke() will return 
that highest ranked available service.
         }

Modified: 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/test/test/EventImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/test/test/EventImpl.java?rev=1640646&r1=1640645&r2=1640646&view=diff
==============================================================================
--- 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/test/test/EventImpl.java
 (original)
+++ 
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager/test/test/EventImpl.java
 Thu Nov 20 00:10:25 2014
@@ -23,7 +23,7 @@ import org.apache.felix.dm.context.Event
 /* in real life, this event might contain a service reference and service 
instance
  * or something similar
  */
-public class EventImpl extends Event<Object> { // the actual event object (a 
Service, a Bundle, a Configuration, etc ...)
+public class EventImpl extends Event { // the actual event object (a Service, 
a Bundle, a Configuration, etc ...)
        private final int m_id;
 
        public EventImpl() {
@@ -55,7 +55,6 @@ public class EventImpl extends Event<Obj
                return false;
        }
        
-    @SuppressWarnings("rawtypes")
     @Override
     public int compareTo(Event o) {
         EventImpl a = this, b = (EventImpl) o;


Reply via email to