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 2011/06/07 12:48:57 UTC
svn commit: r1132949 - in /felix/trunk/scrplugin: annotations/
annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/
annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/
generator/ generator/src/main/ja...
Author: cziegeler
Date: Tue Jun 7 10:48:57 2011
New Revision: 1132949
URL: http://svn.apache.org/viewvc?rev=1132949&view=rev
Log:
FELIX-2908 - Use same mechanism to get single annotation values as for multiple annotation values
Modified:
felix/trunk/scrplugin/annotations/changelog.txt
felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
felix/trunk/scrplugin/generator/changelog.txt
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java
felix/trunk/scrplugin/maven-scr-plugin/changelog.txt
felix/trunk/scrplugin/scrtask/changelog.txt
Modified: felix/trunk/scrplugin/annotations/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/changelog.txt?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/changelog.txt (original)
+++ felix/trunk/scrplugin/annotations/changelog.txt Tue Jun 7 10:48:57 2011
@@ -7,6 +7,7 @@ Changes from 1.5.0 to 1.6.0
** Improvement
* [FELIX-2939] - Maven SCR Plugin is not (marked as) thread-safe for parallel builds
+ * [FELIX-2908] - Use same mechanism to get single annotation values as for multiple annotation values
Changes from 1.4.0 to 1.5.0
Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java (original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java Tue Jun 7 10:48:57 2011
@@ -46,11 +46,11 @@ public class ComponentTag extends Abstra
this.annotation = new Component() {
public boolean componentAbstract() {
- return Util.getBooleanValue(annotation, "componentAbstract", Component.class);
+ return Util.getBooleanValue(annotation, desc, "componentAbstract", Component.class);
}
public boolean createPid() {
- return Util.getBooleanValue(annotation, "createPid", Component.class);
+ return Util.getBooleanValue(annotation, desc, "createPid", Component.class);
}
public String description() {
@@ -58,7 +58,7 @@ public class ComponentTag extends Abstra
}
public boolean ds() {
- return Util.getBooleanValue(annotation, "ds", Component.class);
+ return Util.getBooleanValue(annotation, desc, "ds", Component.class);
}
public String specVersion() {
@@ -66,7 +66,7 @@ public class ComponentTag extends Abstra
}
public boolean enabled() {
- return Util.getBooleanValue(annotation, "enabled", Component.class);
+ return Util.getBooleanValue(annotation, desc, "enabled", Component.class);
}
public String factory() {
@@ -74,11 +74,11 @@ public class ComponentTag extends Abstra
}
public boolean immediate() {
- return Util.getBooleanValue(annotation, "immediate", Component.class);
+ return Util.getBooleanValue(annotation, desc, "immediate", Component.class);
}
public boolean inherit() {
- return Util.getBooleanValue(annotation, "inherit", Component.class);
+ return Util.getBooleanValue(annotation, desc, "inherit", Component.class);
}
public String label() {
@@ -86,7 +86,7 @@ public class ComponentTag extends Abstra
}
public boolean metatype() {
- return Util.getBooleanValue(annotation, "metatype", Component.class);
+ return Util.getBooleanValue(annotation, desc, "metatype", Component.class);
}
public String name() {
@@ -98,7 +98,7 @@ public class ComponentTag extends Abstra
}
public boolean getConfigurationFactory() {
- return Util.getBooleanValue(annotation, "getConfigurationFactory", Component.class);
+ return Util.getBooleanValue(annotation, desc, "getConfigurationFactory", Component.class);
}
public boolean configurationFactory() {
Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java (original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java Tue Jun 7 10:48:57 2011
@@ -44,7 +44,7 @@ public class PropertyTag extends Abstrac
this.annotation = new Property() {
public int cardinality() {
- return Util.getIntValue(annotation, "cardinality", Property.class);
+ return Util.getIntValue(annotation, desc, "cardinality", Property.class);
}
public String description() {
@@ -84,7 +84,7 @@ public class PropertyTag extends Abstrac
}
public boolean propertyPrivate() {
- return Util.getBooleanValue(annotation, "propertyPrivate", Property.class);
+ return Util.getBooleanValue(annotation, desc, "propertyPrivate", Property.class);
}
public String[] value() {
Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java (original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java Tue Jun 7 10:48:57 2011
@@ -73,7 +73,7 @@ public class ServiceTag extends Abstract
final Service tag = new Service() {
public boolean serviceFactory() {
- return Util.getBooleanValue(annotation, "serviceFactory", Service.class);
+ return Util.getBooleanValue(annotation, desc, "serviceFactory", Service.class);
}
public Class<?>[] value() {
Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java (original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java Tue Jun 7 10:48:57 2011
@@ -47,7 +47,7 @@ public class SlingAnnotationTagProvider
{
// generate @Component tag if required
- boolean generateComponent = Util.getBooleanValue(annotation, "generateComponent", SlingServlet.class);
+ boolean generateComponent = Util.getBooleanValue(annotation, description, "generateComponent", SlingServlet.class);
if (generateComponent)
{
String name = Util.getStringValue(annotation, description, "name", SlingServlet.class);
@@ -62,12 +62,12 @@ public class SlingAnnotationTagProvider
if ( desc != null && desc.trim().length() == 0 ) {
desc = null;
}
- final boolean createMetatype = Util.getBooleanValue(annotation, "metatype", SlingServlet.class);
+ final boolean createMetatype = Util.getBooleanValue(annotation, description, "metatype", SlingServlet.class);
tags.add(new SlingServletComponentTag(annotation, description, createMetatype, name, label, desc));
}
// generate @Service tag if required
- boolean generateService = Util.getBooleanValue(annotation, "generateService", SlingServlet.class);
+ boolean generateService = Util.getBooleanValue(annotation, description, "generateService", SlingServlet.class);
if (generateService)
{
tags.add(new SlingServletServiceTag(annotation, description));
@@ -114,7 +114,7 @@ public class SlingAnnotationTagProvider
else if ( annotationName.equals(SlingFilter.class.getName()) )
{
// generate @Component tag if required
- boolean generateComponent = Util.getBooleanValue(annotation, "generateComponent", SlingFilter.class);
+ boolean generateComponent = Util.getBooleanValue(annotation, description, "generateComponent", SlingFilter.class);
if (generateComponent)
{
String name = Util.getStringValue(annotation, description, "name", SlingFilter.class);
@@ -129,19 +129,19 @@ public class SlingAnnotationTagProvider
if ( desc != null && desc.trim().length() == 0 ) {
desc = null;
}
- final boolean createMetatype = Util.getBooleanValue(annotation, "metatype", SlingFilter.class);
+ final boolean createMetatype = Util.getBooleanValue(annotation, description, "metatype", SlingFilter.class);
tags.add(new SlingFilterComponentTag(annotation, description, createMetatype, name, label, desc));
}
// generate @Service tag if required
- boolean generateService = Util.getBooleanValue(annotation, "generateService", SlingFilter.class);
+ boolean generateService = Util.getBooleanValue(annotation, description, "generateService", SlingFilter.class);
if (generateService)
{
tags.add(new SlingFilterServiceTag(annotation, description));
}
// property order = service.ranking
- final int order = Util.getIntValue(annotation, "order", SlingFilter.class);
+ final int order = Util.getIntValue(annotation, description, "order", SlingFilter.class);
tags.add(new SlingServletPropertyTag(annotation, "service.ranking", String.valueOf(order), description, "Integer", true));
// property scope
Modified: felix/trunk/scrplugin/generator/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/changelog.txt?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/changelog.txt (original)
+++ felix/trunk/scrplugin/generator/changelog.txt Tue Jun 7 10:48:57 2011
@@ -12,6 +12,7 @@ Changes from 1.1.0 to 1.1.2
** Improvement
* [FELIX-2492] - scr plugin: using src annotations causes NoClassDefFoundError and other errors
* [FELIX-2939] - Maven SCR Plugin is not (marked as) thread-safe for parallel builds
+ * [FELIX-2908] - Use same mechanism to get single annotation values as for multiple annotation values
Changes from 1.0.0 to 1.1.0
Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java (original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/tags/annotation/Util.java Tue Jun 7 10:48:57 2011
@@ -40,36 +40,36 @@ public abstract class Util {
* @param clazz The annotation class.
* @return The boolean value.
*/
- public static boolean getBooleanValue(Annotation annotation, String name, final Class<?> clazz) {
- final Object obj = annotation.getNamedParameter(name);
- if ( obj != null ) {
- return Boolean.valueOf(obj.toString());
+ public static boolean getBooleanValue(final Annotation annotation, final JavaClassDescription desc, final String name, final Class<?> clazz) {
+ final String[] sValues = getAnnotationValues(annotation, name, desc);
+ if ( sValues != null )
+ {
+ return Boolean.valueOf(sValues[0]);
}
- try {
+ try
+ {
return (Boolean) clazz.getMethod(name).getDefaultValue();
- } catch( NoSuchMethodException mnfe) {
+ }
+ catch( final NoSuchMethodException mnfe)
+ {
// we ignore this
return true;
}
}
- public static int getIntValue(Annotation annotation, String name, final Class<?> clazz) {
- final Object obj = annotation.getNamedParameter(name);
- if ( obj != null ) {
- if ( obj instanceof Number ) {
- return ((Number)obj).intValue();
- }
- final String value = obj.toString();
- if ( value.equals("Integer.MAX_VALUE") ) {
- return Integer.MAX_VALUE;
- } else if ( value.equals("Integer.MIN_VALUE") ) {
- return Integer.MIN_VALUE;
- }
- return Integer.valueOf(value);
+ public static int getIntValue(final Annotation annotation, final JavaClassDescription desc, final String name, final Class<?> clazz) {
+ final String[] sValues = getAnnotationValues(annotation, name, desc);
+ if ( sValues != null )
+ {
+ return Integer.valueOf(sValues[0]);
+
}
- try {
+ try
+ {
return (Integer) clazz.getMethod(name).getDefaultValue();
- } catch( NoSuchMethodException mnfe) {
+ }
+ catch(final NoSuchMethodException mnfe)
+ {
// we ignore this
return 0;
}
@@ -382,11 +382,11 @@ public abstract class Util {
return getEnumValue(annotation, name, enumClass, clazz, true);
}
+ @SuppressWarnings("unchecked")
public static String[] getAnnotationValues(final Annotation annotation, final String name, final JavaClassDescription desc)
throws IllegalArgumentException
{
-
- EvaluatingVisitor evaluatingVisitor = new EvaluatingVisitor() {
+ final EvaluatingVisitor evaluatingVisitor = new EvaluatingVisitor() {
public Object visitAnnotationFieldRef( AnnotationFieldRef fieldRef ) {
// during prescan of AnnotationTagProviderManager#hasScrPluginAnnotation this method is called without desc attribute
@@ -438,9 +438,9 @@ public abstract class Util {
}
};
- @SuppressWarnings("unchecked")
final List<Object> valueList = evaluatingVisitor.getListValue(annotation, name);
- if (valueList==null) {
+ if (valueList == null || valueList.size() == 0)
+ {
return null;
}
String[] values = new String[valueList.size()];
Modified: felix/trunk/scrplugin/maven-scr-plugin/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/maven-scr-plugin/changelog.txt?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/maven-scr-plugin/changelog.txt (original)
+++ felix/trunk/scrplugin/maven-scr-plugin/changelog.txt Tue Jun 7 10:48:57 2011
@@ -11,6 +11,7 @@ Changes from 1.7.0 to 1.7.2
** Improvement
* [FELIX-2939] - Maven SCR Plugin is not (marked as) thread-safe for parallel builds
* [FELIX-2492] - scr plugin: using src annotations causes NoClassDefFoundError and other errors
+ * [FELIX-2908] - Use same mechanism to get single annotation values as for multiple annotation values
Changes from 1.6.0 to 1.7.0
Modified: felix/trunk/scrplugin/scrtask/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/scrtask/changelog.txt?rev=1132949&r1=1132948&r2=1132949&view=diff
==============================================================================
--- felix/trunk/scrplugin/scrtask/changelog.txt (original)
+++ felix/trunk/scrplugin/scrtask/changelog.txt Tue Jun 7 10:48:57 2011
@@ -9,6 +9,7 @@ Changes from 1.1.0 to 1.1.2
** Improvement
* [FELIX-2492] - scr plugin: using src annotations causes NoClassDefFoundError and other errors
+ * [FELIX-2908] - Use same mechanism to get single annotation values as for multiple annotation values
Changes from 1.0.0 to 1.1.0