FELIX-378 servicefactory attribute of @scr.service tag not handled correctly

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@578316 13f79535-47bb-0310-9956-ffa450edef68
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 d02dfed..52068d5 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -233,8 +233,7 @@
         final OCD ocd = this.doComponent(componentTag, component, metaData);
 
         boolean inherited = this.getBoolean(componentTag, Constants.COMPONENT_INHERIT, false);
-        boolean serviceFactory = this.doServices(description.getTagsByName(Constants.SERVICE, inherited), component, description);
-        component.setServiceFactory(serviceFactory);
+        this.doServices(description.getTagsByName(Constants.SERVICE, inherited), component, description);
 
         // properties
         final JavaTag[] properties = description.getTagsByName(Constants.PROPERTY, inherited);
@@ -372,11 +371,11 @@
      * @return
      * @throws MojoExecutionException
      */
-    protected boolean doServices(JavaTag[] services, Component component, JavaClassDescription description)
+    protected void doServices(JavaTag[] services, Component component, JavaClassDescription description)
     throws MojoExecutionException {
         // no services, hence certainly no service factory
         if (services == null || services.length == 0) {
-            return false;
+            return;
         }
 
         final Service service = new Service();
@@ -406,7 +405,7 @@
             serviceFactory |= this.getBoolean(services[i], Constants.SERVICE_FACTORY, false);
         }
 
-        return serviceFactory;
+        service.setServicefactory(serviceFactory);
     }
 
     /**
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
index 50d9d9c..654e04e 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
@@ -62,8 +62,6 @@
     /** Is this an abstract description? */
     protected boolean isAbstract;
 
-    protected boolean serviceFactory;
-
     /**
      * Default constructor.
      */
@@ -171,14 +169,6 @@
         this.isAbstract = isAbstract;
     }
 
-    public boolean isServiceFactory() {
-        return this.serviceFactory;
-    }
-
-    public void setServiceFactory(boolean serviceFactory) {
-        this.serviceFactory = serviceFactory;
-    }
-
     /**
      * Validate the component description.
      * If errors occur a message is added to the issues list,
@@ -234,12 +224,14 @@
                     }
 
                     // verify service
+                    boolean isServiceFactory = false;
                     if (this.getService() != null) {
                         this.getService().validate(issues, warnings);
+                        isServiceFactory = Boolean.valueOf(this.getService().getServicefactory()).booleanValue();
                     }
 
                     // serviceFactory must not be true for immediate of component factory
-                    if (this.isServiceFactory() && this.isImmediate() != null && this.isImmediate().booleanValue() && this.getFactory() != null) {
+                    if (isServiceFactory && this.isImmediate() != null && this.isImmediate().booleanValue() && this.getFactory() != null) {
                         issues.add(this.getMessage("Component must not be a ServiceFactory, if immediate and/or component factory: " + javaClass.getName()));
                     }
 
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
index 5167265..12fcf83 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
@@ -48,6 +48,10 @@
     public void setServicefactory(String servicefactory) {
         this.servicefactory = servicefactory;
     }
+    
+    public void setServicefactory(boolean servicefactory) {
+        this.servicefactory = String.valueOf(servicefactory);
+    }
 
     public List getInterfaces() {
         return this.interfaces;