Use the Property annotation for declaring service properties

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@906276 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Property.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Property.java
new file mode 100644
index 0000000..d922785
--- /dev/null
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Property.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.annotation.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to describe a key-value pair.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Target( { ElementType.ANNOTATION_TYPE })
+public @interface Property
+{
+    /**
+     * Returns the property name.
+     * @return this property name
+     */
+    String name();
+
+    /**
+     * Returns the property value
+     * @return this property value
+     */
+    String value();
+}
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Service.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Service.java
index bd37cbc..991f8c9 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Service.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Service.java
@@ -37,10 +37,10 @@
     Class<?>[] provide() default Object.class;
 
     /**
-     * Returns the list of provided service properties. Each string must be separated by "=" char.
+     * Returns the list of provided service properties.
      * @return The list of provided service properties.
      */
-    String[] properties() default "";
+    Property[] properties() default {};
     
     /**
      * Returns the Class of the class which acts as a factory for this Service. The default method
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 7827c57..cb08bdf 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
@@ -33,6 +33,7 @@
 import org.apache.felix.dm.annotation.api.ConfigurationDependency;
 import org.apache.felix.dm.annotation.api.Destroy;
 import org.apache.felix.dm.annotation.api.Init;
+import org.apache.felix.dm.annotation.api.Property;
 import org.apache.felix.dm.annotation.api.Service;
 import org.apache.felix.dm.annotation.api.ServiceDependency;
 import org.apache.felix.dm.annotation.api.Start;
@@ -383,9 +384,10 @@
         Object[] properties = annotation.get(Params.properties.toString());
         if (properties != null)
         {
-            for (Object property : properties)
+            for (Object p : properties)
             {
-                String prop = property.toString().replace("=", ":");
+                Annotation a = (Annotation) p; 
+                String prop = a.get("name") + ":" + a.get("value");
                 info.addParam(Params.properties, prop);
             }
         }
diff --git a/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/EnglishDictionary.java b/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/EnglishDictionary.java
index d7b1509..12bc99e 100644
--- a/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/EnglishDictionary.java
+++ b/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/EnglishDictionary.java
@@ -23,12 +23,13 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.felix.dm.annotation.api.ConfigurationDependency;
+import org.apache.felix.dm.annotation.api.Property;
 import org.apache.felix.dm.annotation.api.Service;
 
 /**
  * An English Dictionary Service. We'll be configured using OSGi Config Admin.
  */
-@Service(properties={"language=en"})
+@Service(properties={@Property(name="language", value="en")})
 public class EnglishDictionary implements DictionaryService
 {
     private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>();
diff --git a/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/FrenchDictionary.java b/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/FrenchDictionary.java
index ffb2a24..be44d62 100644
--- a/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/FrenchDictionary.java
+++ b/dependencymanager/samples/annotation/src/main/java/org/apache/felix/dm/samples/annotation/FrenchDictionary.java
@@ -21,12 +21,13 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.felix.dm.annotation.api.Property;
 import org.apache.felix.dm.annotation.api.Service;
 
 /**
  * A French Dictionary Service.
  */
-@Service(properties={"language=fr"})
+@Service(properties={@Property(name="language", value="fr")})
 public class FrenchDictionary implements DictionaryService
 {
     private List<String> m_words = Arrays.asList("bonjour", "salut");
diff --git a/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/MultipleAnnotationTest.java b/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/MultipleAnnotationTest.java
index 50078cc..e4fe42b 100644
--- a/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/MultipleAnnotationTest.java
+++ b/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/MultipleAnnotationTest.java
@@ -19,6 +19,7 @@
 package org.apache.felix.dm.test.annotation;
 
 import org.apache.felix.dm.annotation.api.Composition;
+import org.apache.felix.dm.annotation.api.Property;
 import org.apache.felix.dm.annotation.api.Service;
 import org.apache.felix.dm.annotation.api.ServiceDependency;
 import org.apache.felix.dm.annotation.api.Start;
@@ -67,7 +68,7 @@
         }
     }
 
-    @Service(properties = { "foo=bar" }, factory=Factory.class, factoryMethod="createServiceProvider")
+    @Service(properties = {@Property(name="foo", value="bar") }, factory=Factory.class, factoryMethod="createServiceProvider")
     static class ServiceProvider implements ServiceInterface
     {
         @ServiceDependency(filter="(test=multiple)")