reworked property metadata annotations
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@907187 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/MetaType.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/MetaType.java
deleted file mode 100644
index 9db62a9..0000000
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/MetaType.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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;
-
-/**
- * Annotates a class for describing Properties MetaType informations.
- * The corresponding OSGI-INF/metatype/metatype.xml will be generated.
- */
-@Retention(RetentionPolicy.CLASS)
-@Target(ElementType.TYPE)
-public @interface MetaType
-{
- /**
- * Return the PIDs (for ManagedServices) for which this metatype is applying.
- * @return the PIDS for which this metatype is applying.
- */
- String[] pids() default {};
-
- /**
- * Points to the Properties file that can localize this MetaType informations.
- */
- String localization() default "";
-
- /**
- * Returns the id of this MetaType meta type.
- */
- String id() default "";
-
- /**
- * Return a description of this metatype. The description may be localized.
- * @return The description of this meta type.
- */
- String description() default "";
-
- /**
- * Return the name of this meta type. The name may be localized.
- * @return The name of this meta type
- */
- String name() default "";
-
- /**
- * Returns the attribute definitions for this meta type.
- */
- Attribute[] attributes();
-}
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/PropertiesInfo.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/PropertiesInfo.java
new file mode 100644
index 0000000..3c972e3
--- /dev/null
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/PropertiesInfo.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+/**
+ * Describes configuration properties MetaData informations. This annotation is used to generate
+ * a MetaType xml file under OSGI-INF/metatype/metatype.xml and is used to expose
+ * Service Component properties through web console.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.TYPE)
+public @interface PropertiesInfo
+{
+ /**
+ * Sets the PID that is associtated whith this annotation. By default, the PID is the full java class name.
+ * @return The PID that is associated with this annotation.
+ */
+ String pid() default "";
+
+ /**
+ * The label used to display the tab name (or section) where the properties are displayed. Example: "Printer Service".
+ * @return The label used to display the tab name where the properties are displayed.
+ */
+ String heading();
+
+ /**
+ * A human readable description of the PID this annotation is associated with. Example: "Configuration for the PrinterService bundle".
+ * @return A human readable description of the PID this annotation is associated with.
+ */
+ String description();
+
+ /**
+ * The list of properties types used to expose properties in web console.
+ * @return The list of properties types used to expose properties in web console.
+ */
+ PropertyInfo[] properties();
+
+ /**
+ * The path for the localization MetaType property files.
+ * @return The path for the localization MetaType property files
+ */
+ String localization() default "OSGI-INF/metatype/metatype";
+}
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
deleted file mode 100644
index d922785..0000000
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Property.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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/Attribute.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/PropertyInfo.java
similarity index 61%
rename from dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Attribute.java
rename to dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/PropertyInfo.java
index fd29e20..fc38bb3 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/Attribute.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/PropertyInfo.java
@@ -24,25 +24,26 @@
import java.lang.annotation.Target;
/**
- * Annotates a MetaType annotation for declaring the data type of a property/attribute.
+ * This annotation describes the data types of a configuration Property.
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.ANNOTATION_TYPE)
-public @interface Attribute
+public @interface PropertyInfo
{
/**
- * Unique identity for this attribute. Attributes share a global namespace in the registry. E.g. an attribute cn or commonName
- * must always be a String and the semantics are always a name of some object. They share this aspect with LDAP/X.500 attributes.
- * In these standards the OSI Object Identifier (OID) is used to uniquely identify an attribute. If such an OID exists, (which can
- * be requested at several standard organisations and many companies already have a node in the tree) it can be returned here. Otherwise,
- * a unique id should be returned which can be a Java class name (reverse domain name) or generated with a GUID algorithm.
- * Note that all LDAP defined attributes already have an OID. It is strongly advised to define the attributes from existing LDAP schemes
- * which will give the OID. Many such schemes exist ranging from postal addresses to DHCP parameters.
+ * The label used to display the property. Example: "Log Level".
+ * @return The label used to display the property
+ */
+ String heading();
+
+ /**
+ * The key of a ConfigurationAdmin property. Example: "printer.logLevel"
+ * @return The Configuration Admin property name
*/
String id();
/**
- * Return the type for this attribute. If must be either one of the following types:<p>
+ * Return the property primitive type. If must be either one of the following types:<p>
* <ul>
* <li>String.class</li>
* <li>Long.class</li>
@@ -57,7 +58,7 @@
Class<?> type() default String.class;
/**
- * Return a default for this attribute. The object must be of the appropriate type as defined by the cardinality and getType().
+ * Return a default for this property. The object must be of the appropriate type as defined by the cardinality and getType().
* The return type is a list of String objects that can be converted to the appropriate type. The cardinality of the return
* array must follow the absolute cardinality of this type. E.g. if the cardinality = 0, the array must contain 1 element.
* If the cardinality is 1, it must contain 0 or 1 elements. If it is -5, it must contain from 0 to max 5 elements. Note that
@@ -66,19 +67,14 @@
String[] defaults() default {};
/**
- * Returns the name of the attribute. This name may be localized.
- */
- String name();
-
- /**
- * Returns a description of this attribute. The description may be localized and must describe the semantics of this type and any
- * constraints.
+ * Returns the property description. The description may be localized and must describe the semantics of this type and any
+ * constraints. Example: "Select the log level for the Printer Service".
* @return The localized description of the definition.
*/
String description();
/**
- * Return the cardinality of this attribute. The OSGi environment handles multi valued attributes in arrays ([]) or in Vector objects.
+ * Return the cardinality of this property. The OSGi environment handles multi valued properties in arrays ([]) or in Vector objects.
* The return value is defined as follows:<p>
*
* <ul>
@@ -87,18 +83,20 @@
* <li> x > 0 x = max occurrences, store in array []</li>
* <li> x = Integer.MAX_VALUE no limit, but use array []</li>
* <li> x = 0 1 occurrence required</li>
+ * </ul>
*/
int cardinality() default 0;
/**
- * Tells if this attribute is required or not.
+ * Tells if this property is required or not.
*/
boolean required() default true;
/**
- * Return a list of option that this attribute can take.
- * The Options are defined using the <code>Property</code> annotation, where the name attributes is used to
+ * Return a list of valid options for this property.
+ * The Options are defined using the <code>Property</code> annotation, where the name is used to
* reference the option label, and the value attribute is used to reference the option value.
+ * @return the list of valid options for this property.
*/
- Property[] options() default {};
+ Param[] options() default {};
}
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 991f8c9..7036a0e 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
@@ -40,7 +40,7 @@
* Returns the list of provided service properties.
* @return The list of provided service properties.
*/
- Property[] properties() default {};
+ Param[] 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 cb08bdf..aebda9c 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,7 +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.Param;
import org.apache.felix.dm.annotation.api.Service;
import org.apache.felix.dm.annotation.api.ServiceDependency;
import org.apache.felix.dm.annotation.api.Start;
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 12bc99e..6163be2 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,13 +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.Param;
import org.apache.felix.dm.annotation.api.Service;
/**
* An English Dictionary Service. We'll be configured using OSGi Config Admin.
*/
-@Service(properties={@Property(name="language", value="en")})
+@Service(properties={@Param(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 be44d62..fec78ac 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,13 +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.Param;
import org.apache.felix.dm.annotation.api.Service;
/**
* A French Dictionary Service.
*/
-@Service(properties={@Property(name="language", value="fr")})
+@Service(properties={@Param(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 e4fe42b..62c74cd 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,7 +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.Param;
import org.apache.felix.dm.annotation.api.Service;
import org.apache.felix.dm.annotation.api.ServiceDependency;
import org.apache.felix.dm.annotation.api.Start;
@@ -68,7 +68,7 @@
}
}
- @Service(properties = {@Property(name="foo", value="bar") }, factory=Factory.class, factoryMethod="createServiceProvider")
+ @Service(properties = {@Param(name="foo", value="bar") }, factory=Factory.class, factoryMethod="createServiceProvider")
static class ServiceProvider implements ServiceInterface
{
@ServiceDependency(filter="(test=multiple)")