[FELIX-3866] Added support for swap attribute in AspectService and AdpaterService annotations.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1437355 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
index b4ee040..b02bee0 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AdapterService.java
@@ -106,6 +106,11 @@
     String changed() default "";
 
     /**
+     * name of the callback method to invoke on swap.
+     */
+    String swap() default "";
+
+    /**
      * The callback method to invoke when the service is lost. When this attribute is used, then the added attribute 
      * must also be used.
      */
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AspectService.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AspectService.java
index add063e..600ba85 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AspectService.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/AspectService.java
@@ -107,6 +107,11 @@
     String removed() default "";
     
     /**
+     * name of the callback method to invoke on swap.
+     */
+    String swap() default "";
+
+    /**
      * Sets the static method used to create the AspectService implementation instance. The
      * default constructor of the annotated class is used. The factoryMethod can be used to provide a specific
      * aspect implements, like a DynamicProxy.
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
index 981c4ba..91867ea 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
@@ -595,9 +595,10 @@
         String added = annotation.get(EntryParam.added.toString());
         String changed = annotation.get(EntryParam.changed.toString());
         String removed = annotation.get(EntryParam.removed.toString());
+        String swap = annotation.get(EntryParam.swap.toString());
 
-        // "field" and "added/changed/removed" attributes can't be mixed
-        if (field != null && (added != null || changed != null || removed != null))
+        // "field" and "added/changed/removed/swap" attributes can't be mixed
+        if (field != null && (added != null || changed != null || removed != null || swap != null))
         {
             throw new IllegalStateException("Annotation " + annotation + "can't applied on " + m_className
                     + " can't mix \"field\" attribute with \"added/changed/removed\" attributes");
@@ -617,6 +618,7 @@
         writer.putString(annotation, EntryParam.added, null);
         writer.putString(annotation, EntryParam.changed, null);
         writer.putString(annotation, EntryParam.removed, null);
+        writer.putString(annotation, EntryParam.swap, null);
     }
 
     /**
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java
index 97a9ee9..6df8188 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/EntryParam.java
@@ -40,6 +40,7 @@
     added, 
     changed,
     removed,
+    swap,
     autoConfig, 
     pid, 
     factoryPid,
diff --git a/dependencymanager/runtime/pom.xml b/dependencymanager/runtime/pom.xml
index ffe4a27..af7d844 100644
--- a/dependencymanager/runtime/pom.xml
+++ b/dependencymanager/runtime/pom.xml
@@ -43,7 +43,7 @@
         <dependency>
             <groupId>${pom.groupId}</groupId>
             <artifactId>org.apache.felix.dependencymanager</artifactId>
-            <version>3.0.0</version>
+            <version>3.1.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.json</groupId>
diff --git a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Activator.java b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Activator.java
index 26fe7ef..b551302 100644
--- a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Activator.java
+++ b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Activator.java
@@ -28,8 +28,8 @@
 /*
  * This is the Activator for our DependencyManager Component Runtime.
  * Here, we'll track started/stopped bundles which have some DependencyManager
- * descriptors (META-INF/*.dm). Such descriptors are generated by the Bnd 
- * plugin which parses DependencyManager annotations at compile time.
+ * descriptors (META-INF/dependencymanager/*.dm). Such descriptors are generated 
+ * by the Bnd plugin which parses DependencyManager annotations at compile time.
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
@@ -54,8 +54,8 @@
      * "DependencyManager-Component" Manifest header.
      * If the "dm.runtime.log=true" parameter is configured in the Felix config.properties
      * then we'll use a required/temporal service dependency over the log service.
-     * This temporal dependency avoids us to be restarted if the log service is temporarily 
-     * unavailable (that is: when the log service is updating).
+     * This temporal dependency allows to not being restarted if the log service is temporarily 
+     * unavailable (that is: when the log service is updated).
      * if the "dm.runtime.log" is not configured or it it is set to false, then we'll use 
      * an optional dependency over the log service, in order to use a NullObject in case
      * the log service is not available.
diff --git a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AdapterServiceBuilder.java b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AdapterServiceBuilder.java
index 3b9f807..f825497 100644
--- a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AdapterServiceBuilder.java
+++ b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AdapterServiceBuilder.java
@@ -54,10 +54,11 @@
         String added = srvMeta.getString(Params.added, null);
         String changed = srvMeta.getString(Params.changed, null);
         String removed = srvMeta.getString(Params.removed, null);
-        
-        if (field != null && (added != null || changed != null || removed != null))
+        String swap = srvMeta.getString(Params.swap, null);
+
+        if (field != null && (added != null || changed != null || removed != null || swap != null))
         {
-            throw new IllegalArgumentException("autoconfig field " + field + " cant be defined with both added/changed/removed calllbacks");
+            throw new IllegalArgumentException("autoconfig field " + field + " cant be defined with both added/changed/removed/swap calllbacks");
         }
         if (field == null && added == null && (changed != null || removed != null))
         {
@@ -74,7 +75,7 @@
         {
             if (added != null)
             {
-                c = dm.createAdapterService(adapteeService, adapteeFilter, added, changed, removed);
+                c = dm.createAdapterService(adapteeService, adapteeFilter, added, changed, removed, swap);
 
             }
             else
diff --git a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AspectServiceBuilder.java b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AspectServiceBuilder.java
index de4520b..9aea02c 100644
--- a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AspectServiceBuilder.java
+++ b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/AspectServiceBuilder.java
@@ -59,10 +59,11 @@
         String added = srvMeta.getString(Params.added, null);
         String changed = srvMeta.getString(Params.changed, null);
         String removed = srvMeta.getString(Params.removed, null);
-        
-        if (field != null && (added != null || changed != null || removed != null))
+        String swap = srvMeta.getString(Params.swap, null);
+
+        if (field != null && (added != null || changed != null || removed != null || swap != null))
         {
-            throw new IllegalArgumentException("autoconfig field " + field + " cant be defined with both added/changed/removed calllbacks");
+            throw new IllegalArgumentException("autoconfig field " + field + " cant be defined with both added/changed/removed/swap calllbacks");
         }
         if (field == null && added == null && (changed != null || removed != null))
         {
@@ -79,7 +80,7 @@
         {
             if (added != null)
             {
-                c = dm.createAspectService(serviceInterface, serviceFilter, ranking, added, changed, removed)
+                c = dm.createAspectService(serviceInterface, serviceFilter, ranking, added, changed, removed, swap)
                       .setServiceProperties(aspectProperties);
             } 
             else
diff --git a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Params.java b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Params.java
index 7f0637f..7dbc25c 100644
--- a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Params.java
+++ b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/Params.java
@@ -41,6 +41,7 @@
     added,
     changed,
     removed,
+    swap,
     autoConfig,
     pid,
     propagate,