FELIX-1229 : Fix some bugs introduced with implemented the new features.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@784704 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
index cf019df..ebd5f99 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
@@ -94,7 +94,7 @@
     public static final String PROPERTY_TYPE_DOUBLE = "Double";
     public static final String PROPERTY_TYPE_FLOAT = "Float";
     public static final String PROPERTY_TYPE_INTEGER = "Integer";
-    public static final String PROPERTY_TYPE_BYTE = "Bye";
+    public static final String PROPERTY_TYPE_BYTE = "Byte";
     public static final String PROPERTY_TYPE_CHAR = "Char";
     public static final String PROPERTY_TYPE_CHAR_1_1 = "Character";
     public static final String PROPERTY_TYPE_BOOLEAN = "Boolean";
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
index 6322565..523d884 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -223,11 +223,11 @@
                             boolean createBind = false;
                             boolean createUnbind = false;
                             // Only create method if no bind name has been specified
-                            if ( bindValue == null && ref.findMethod(specVersion, ref.getBind()) == null ) {
+                            if ( bindValue == null && ref.findMethod(specVersion, "bind") == null ) {
                                 // create bind method
                                 createBind = true;
                             }
-                            if ( unbindValue == null && ref.findMethod(specVersion, ref.getUnbind()) == null ) {
+                            if ( unbindValue == null && ref.findMethod(specVersion, "unbind") == null ) {
                                 // create unbind method
                                 createUnbind = true;
                             }
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
index cc8d538..261a53f 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Reference.java
@@ -60,9 +60,6 @@
     public Reference(JavaTag t, JavaClassDescription desc) {
         super(t);
         this.javaClassDescription = desc;
-        // set default values
-        this.setBind("bind");
-        this.setUnbind("unbind");
     }
 
     public String getName() {
@@ -194,6 +191,13 @@
 
         // validate bind and unbind methods
         if (!isLookupStrategy()) {
+            // set default values
+            if ( this.bind == null ) {
+                this.setBind("bind");
+            }
+            if ( this.unbind == null ) {
+                this.setUnbind("unbind");
+            }
             final String oldBind = this.bind;
             final String oldUnbind = this.unbind;
             this.bind = this.validateMethod(specVersion, this.bind, componentIsAbstract, iLog);
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
index 055a793..e31cd37 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
@@ -91,7 +91,7 @@
             }
 
             public ConfigurationPolicy policy() {
-                return Util.getEnumValue(annotation, "policy", ConfigurationPolicy.class, Component.class);
+                return Util.getEnumValue(annotation, "policy", ConfigurationPolicy.class, Component.class, false);
             }
 
             public Class<? extends java.lang.annotation.Annotation> annotationType() {
@@ -126,7 +126,9 @@
         map.put(Constants.COMPONENT_CREATE_PID, String.valueOf(this.annotation.createPid()));
 
         // version 1.1
-        map.put(Constants.COMPONENT_CONFIG_POLICY, this.annotation.policy().getPolicyString());
+        if ( this.annotation.policy() != null ) {
+            map.put(Constants.COMPONENT_CONFIG_POLICY, this.annotation.policy().getPolicyString());
+        }
         final JavaMethod[] jms = this.sourceAnnotation.getContext().getParent().getParentSource().getClasses()[0].getMethods();
         for(final JavaMethod jm : jms) {
             final Annotation[] annotations = jm.getAnnotations();
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java
index ddef1f5..bf48560 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/Util.java
@@ -303,13 +303,19 @@
         }
     }
 
-    public static <T extends Enum> T getEnumValue(Annotation annotation, String name, final Class<T> enumClass, final Class<?> clazz) {
+    public static <T extends Enum> T getEnumValue(Annotation annotation,
+                                                  String name,
+                                                  final Class<T> enumClass,
+                                                  final Class<?> clazz,
+                                                  final boolean returnDefault) {
         Object obj = annotation.getNamedParameter(name);
         if (obj == null) {
-            try {
-                obj = clazz.getMethod(name).getDefaultValue();
-            } catch( NoSuchMethodException mnfe) {
-                // we ignore this
+            if ( returnDefault ) {
+                try {
+                    obj = clazz.getMethod(name).getDefaultValue();
+                } catch( NoSuchMethodException mnfe) {
+                    // we ignore this
+                }
             }
         }
         if ( obj != null ) {
@@ -329,6 +335,13 @@
         return null;
     }
 
+    public static <T extends Enum> T getEnumValue(Annotation annotation,
+            String name,
+            final Class<T> enumClass,
+            final Class<?> clazz) {
+        return getEnumValue(annotation, name, enumClass, clazz, true);
+    }
+
     private static String getAnnotationValue(final AnnotationValue av, final JavaClassDescription desc)
     throws IllegalArgumentException
     {