felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r798540 - in /felix/trunk: scr-annotations/src/main/java/org/apache/felix/scr/annotations/ scrplugin/src/main/java/org/apache/felix/scrplugin/ scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/
Date Tue, 28 Jul 2009 14:42:21 GMT
Author: cziegeler
Date: Tue Jul 28 14:42:21 2009
New Revision: 798540

URL: http://svn.apache.org/viewvc?rev=798540&view=rev
Log:
FELIX-1225 : factoryPid attribute of Designate elements for metatype data is not set

Modified:
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java

Modified: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Component.java?rev=798540&r1=798539&r2=798540&view=diff
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
(original)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
Tue Jul 28 14:42:21 2009
@@ -108,6 +108,12 @@
     boolean createPid() default true;
 
     /**
+     * Set the metatype factory pid property (only for non factory components).
+     * @since 1.0
+     */
+    boolean getMetatypeFactoryPid() default false;
+
+    /**
      * The configuration policy
      * @since 1.0
      */

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java?rev=798540&r1=798539&r2=798540&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java Tue Jul
28 14:42:21 2009
@@ -56,6 +56,8 @@
 
     public static final String COMPONENT_CREATE_PID = "create-pid";
 
+    public static final String COMPONENT_SET_METATYPE_FACTORY_PID = "set-metatype-factory-pid";
+
     // The component configuration policy (V1.1)
     public static final String COMPONENT_CONFIG_POLICY = "policy";
     public static final String COMPONENT_CONFIG_POLICY_OPTIONAL = "optional";

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java?rev=798540&r1=798539&r2=798540&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
Tue Jul 28 14:42:21 2009
@@ -367,7 +367,7 @@
         // set implementation
         component.setImplementation(new Implementation(description.getName()));
 
-        final OCD ocd = this.doComponent(componentTag, component, metaData);
+        final OCD ocd = this.doComponent(componentTag, component, metaData, iLog);
 
         boolean inherited = getBoolean(componentTag, Constants.COMPONENT_INHERIT, true);
         this.doServices(description.getTagsByName(Constants.SERVICE, inherited), component,
description);
@@ -443,7 +443,8 @@
      * @param tag
      * @param component
      */
-    protected OCD doComponent(JavaTag tag, Component component, MetaData metaData) {
+    protected OCD doComponent(JavaTag tag, Component component, MetaData metaData,
+            final IssueLog iLog) {
 
         // check if this is an abstract definition
         final String abstractType = tag.getNamedParameter(Constants.COMPONENT_ABSTRACT);
@@ -513,8 +514,17 @@
             final Designate designate = new Designate();
             metaData.addDesignate(designate);
             designate.setPid(component.getName());
-            if (component.getFactory() != null) {
-                designate.setFactoryPid( component.getFactory() );
+
+            // factory pid
+            final String setFactoryPidValue = tag.getNamedParameter(Constants.COMPONENT_SET_METATYPE_FACTORY_PID);
+            final boolean setFactoryPid = setFactoryPidValue != null &&
+                ("yes".equalsIgnoreCase(setFactoryPidValue) || "true".equalsIgnoreCase(setFactoryPidValue));
+            if ( setFactoryPid ) {
+                if ( component.getFactory() == null ) {
+                    designate.setFactoryPid( component.getName() );
+                } else {
+                    iLog.addWarning("Component factory " + component.getName() + " should
not set metatype factory pid.");
+                }
             }
             // designate.object
             final MTObject mtobject = new MTObject();

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java?rev=798540&r1=798539&r2=798540&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
Tue Jul 28 14:42:21 2009
@@ -94,6 +94,10 @@
                 return Util.getEnumValue(annotation, "policy", ConfigurationPolicy.class,
Component.class, false);
             }
 
+            public boolean getMetatypeFactoryPid() {
+                return Util.getBooleanValue(annotation, "getMetatypeFactoryPid", Component.class);
+            }
+
             public Class<? extends java.lang.annotation.Annotation> annotationType()
{
                 return null;
             }
@@ -114,6 +118,8 @@
         map.put(Constants.COMPONENT_DESCRIPTION, emptyToNull(this.annotation.description()));
         map.put(Constants.COMPONENT_ENABLED, String.valueOf(this.annotation.enabled()));
         map.put(Constants.COMPONENT_FACTORY, emptyToNull(this.annotation.factory()));
+        map.put(Constants.COMPONENT_SET_METATYPE_FACTORY_PID, String.valueOf(this.annotation.getMetatypeFactoryPid()));
+
         // FELIX-593: immediate attribute does not default to true all the
         // times hence we only set it if declared in the tag
         if ( this.sourceAnnotation.getNamedParameter("immediate") != null) {



Mime
View raw message