You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2010/07/19 13:32:29 UTC
svn commit: r965433 - in /felix/trunk:
scr-annotations/src/main/java/org/apache/felix/scr/annotations/ scrplugin/
scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/
Author: cziegeler
Date: Mon Jul 19 11:32:29 2010
New Revision: 965433
URL: http://svn.apache.org/viewvc?rev=965433&view=rev
Log:
FELIX-2478 : Cardinality attribute for Property annotation should be of type string
Added:
felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java (with props)
Modified:
felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java
felix/trunk/scrplugin/pom.xml
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
Modified: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java?rev=965433&r1=965432&r2=965433&view=diff
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java (original)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Property.java Mon Jul 19 11:32:29 2010
@@ -128,18 +128,25 @@ public @interface Property {
* the Wrapper class), if the cardinality is positive, the property is
* stored in an array (primitve types are unboxed, that is Boolean type
* values are stored in boolean[]). The actual value defines the maximum
- * number of elements in the vector or array, where â2147483648
- * (Integer.MIN_INT) describes an unbounded Vector and 2147483647
- * (Integer.MAX_INT) describes an unbounded array. If the cardinality is
+ * number of elements in the vector or array. If the cardinality is
* zero, the property is a scalar value. If the defined value of the
- * property is set in the value attribute, the cardinality defaults to0
+ * property is set in the value attribute, the cardinality defaults to 0
* (zero for scalar value). If the property is defined in one or more
* properties starting with values, the cardinality defaults to
- * 2147483647 (Integer.MAX_INT), that is an unbounded array.
+ * an unbounded array.
*/
int cardinality() default 0;
/**
+ * This defines if the property is unbounded. The property can either be
+ * an unbounded array or vector. If this attribute is set to any other
+ * value than {@link PropertyUnbounded#DEFAULT},
+ * this overrides the {@link #cardinality()}.
+ * @since 1.4
+ */
+ PropertyUnbounded unbounded() default PropertyUnbounded.DEFAULT;
+
+ /**
* Boolean flag defining whether a metatype descriptor entry should be
* generated for this property or not. By default a metatype descriptor
* entry, i.e. an AD element, is generated except for the properties
Added: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java?rev=965433&view=auto
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java (added)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java Mon Jul 19 11:32:29 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.annotations;
+
+/**
+ * Options for {@link Property#unbounded()} property.
+ * @since 1.4
+ */
+public enum PropertyUnbounded {
+
+ /** Property is not unbounded. This is the default. */
+ DEFAULT,
+
+ /** Property is an unbounded array. */
+ ARRAY,
+
+ /** Property is an unbounded vector. */
+ VECTOR
+}
Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/PropertyUnbounded.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: felix/trunk/scrplugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/pom.xml?rev=965433&r1=965432&r2=965433&view=diff
==============================================================================
--- felix/trunk/scrplugin/pom.xml (original)
+++ felix/trunk/scrplugin/pom.xml Mon Jul 19 11:32:29 2010
@@ -67,7 +67,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
- <version>1.3.0</version>
+ <version>1.3.1-SNAPSHOT</version>
</dependency>
<!-- Sling Servlet SCR Annotation -->
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java?rev=965433&r1=965432&r2=965433&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java Mon Jul 19 11:32:29 2010
@@ -20,8 +20,7 @@ package org.apache.felix.scrplugin.tags.
import java.util.*;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyOption;
+import org.apache.felix.scr.annotations.*;
import org.apache.felix.scrplugin.Constants;
import org.apache.felix.scrplugin.tags.JavaClassDescription;
import org.apache.felix.scrplugin.tags.JavaField;
@@ -124,6 +123,10 @@ public class PropertyTag extends Abstrac
return Util.getShortValues(annotation, desc, "shortValue");
}
+ public PropertyUnbounded unbounded() {
+ return Util.getEnumValue(annotation, "unbounded", PropertyUnbounded.class, Property.class);
+ }
+
public Class<? extends java.lang.annotation.Annotation> annotationType() {
return null;
}
@@ -234,7 +237,15 @@ public class PropertyTag extends Abstrac
}
}
- if (this.annotation.cardinality() != 0) {
+ // cardinality handling
+ final PropertyUnbounded pu = this.annotation.unbounded();
+ if ( pu != PropertyUnbounded.DEFAULT ) {
+ if ( pu == PropertyUnbounded.ARRAY ) {
+ map.put(Constants.PROPERTY_CARDINALITY, "+");
+ } else {
+ map.put(Constants.PROPERTY_CARDINALITY, "-");
+ }
+ } else if (this.annotation.cardinality() != 0) {
map.put(Constants.PROPERTY_CARDINALITY, String.valueOf(this.annotation.cardinality()));
}