felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1350302 - in /felix/trunk/scrplugin: annotations/src/main/java/org/apache/felix/scr/annotations/ annotations/src/main/java/org/apache/felix/scrplugin/processing/ ds-annotations/src/main/java/org/apache/felix/scrplugin/ds/ generator/src/mai...
Date Thu, 14 Jun 2012 15:48:33 GMT
Author: cziegeler
Date: Thu Jun 14 15:48:32 2012
New Revision: 1350302

URL: http://svn.apache.org/viewvc?rev=1350302&view=rev
Log:
FELIX-3552 : Implement new features of DS 1.2

Modified:
    felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
    felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
    felix/trunk/scrplugin/ds-annotations/src/main/java/org/apache/felix/scrplugin/ds/DSAnnotationProcessor.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ComponentDescription.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java

Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java?rev=1350302&r1=1350301&r2=1350302&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
(original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scr/annotations/Component.java
Thu Jun 14 15:48:32 2012
@@ -136,4 +136,11 @@ public @interface Component {
      * @since 1.0
      */
     ConfigurationPolicy policy() default ConfigurationPolicy.OPTIONAL;
+
+    /**
+     * The configuration pid.
+     * The default value for this is the name of the component.
+     * @since 1.7
+     */
+    String configurationPid();
 }

Modified: felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java?rev=1350302&r1=1350301&r2=1350302&view=diff
==============================================================================
--- felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
(original)
+++ felix/trunk/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
Thu Jun 14 15:48:32 2012
@@ -206,6 +206,9 @@ public class SCRAnnotationProcessor impl
                         ComponentConfigurationPolicy.OPTIONAL.name())));
         component.setSetMetatypeFactoryPid(cad.getBooleanValue("configurationFactory", false));
 
+        // Version 1.2
+        component.setConfigurationPid(cad.getStringValue("configurationPid", null));
+
         return component;
     }
 

Modified: felix/trunk/scrplugin/ds-annotations/src/main/java/org/apache/felix/scrplugin/ds/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/ds-annotations/src/main/java/org/apache/felix/scrplugin/ds/DSAnnotationProcessor.java?rev=1350302&r1=1350301&r2=1350302&view=diff
==============================================================================
--- felix/trunk/scrplugin/ds-annotations/src/main/java/org/apache/felix/scrplugin/ds/DSAnnotationProcessor.java
(original)
+++ felix/trunk/scrplugin/ds-annotations/src/main/java/org/apache/felix/scrplugin/ds/DSAnnotationProcessor.java
Thu Jun 14 15:48:32 2012
@@ -198,7 +198,8 @@ public class DSAnnotationProcessor imple
         component.setConfigurationPolicy(ComponentConfigurationPolicy.valueOf(cad.getEnumValue("policy",
                         ComponentConfigurationPolicy.OPTIONAL.name())));
 
-        // configuration pid (TODO)
+        // configuration pid
+        component.setConfigurationPid(cad.getStringValue("configurationPid", null));
         component.setCreatePid(cad.getBooleanValue("createPid", true));
 
         // no inheritance

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?rev=1350302&r1=1350301&r2=1350302&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
Thu Jun 14 15:48:32 2012
@@ -371,6 +371,12 @@ public class SCRDescriptorGenerator {
         comp.setFactory(componentDesc.getFactory());
         comp.setSpecVersion(componentDesc.getSpecVersion());
 
+        // configuration pid in 1.2
+        if ( componentDesc.getConfigurationPid() != null && !componentDesc.getConfigurationPid().equals(componentDesc.getName()))
{
+            comp.setConfigurationPid(componentDesc.getConfigurationPid());
+            comp.setSpecVersion(SpecVersion.VERSION_1_2);
+        }
+
         // Create metatype (if required)
         final OCD ocd;
         if ( !componentDesc.isAbstract() && componentDesc.isCreateMetatype() ) {

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ComponentDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ComponentDescription.java?rev=1350302&r1=1350301&r2=1350302&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ComponentDescription.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ComponentDescription.java
Thu Jun 14 15:48:32 2012
@@ -48,6 +48,7 @@ import org.apache.felix.scrplugin.annota
  * <li>deactivate : null</li>
  * <li>modified : null</li>
  * <li>specVersion : null</li>
+ * <li>configuraionPid : null</li>
  * </ul>
  *
  */
@@ -104,6 +105,9 @@ public class ComponentDescription extend
     /** The spec version. */
     private SpecVersion specVersion;
 
+    /** Configuration PID (V1.2) */
+    private String configurationPid;
+
     public ComponentDescription(final ScannedAnnotation annotation) {
         super(annotation);
     }
@@ -246,16 +250,20 @@ public class ComponentDescription extend
 
     @Override
     public String toString() {
-        return "ComponentDescription [name=" + name + ", label=" + label
-                + ", description=" + description + ", enabled=" + enabled
-                + ", immediate=" + immediate + ", factory=" + factory
-                + ", isSetMetatypeFactoryPid=" + isSetMetatypeFactoryPid
-                + ", isAbstract=" + isAbstract + ", isInherit=" + isInherit
-                + ", createDs=" + createDs + ", createPid=" + createPid
-                + ", createMetatype=" + createMetatype
-                + ", configurationPolicy=" + configurationPolicy
-                + ", activate=" + activate + ", deactivate=" + deactivate
-                + ", modified=" + modified + ", specVersion=" + specVersion
-                + ", annotation=" + annotation + "]";
+        return "ComponentDescription [name=" + name + ", label=" + label + ", description="
+ description
+                        + ", configurationPolicy=" + configurationPolicy + ", isAbstract="
+ isAbstract + ", isInherit="
+                        + isInherit + ", createDs=" + createDs + ", createPid=" + createPid
+ ", createMetatype="
+                        + createMetatype + ", enabled=" + enabled + ", immediate=" + immediate
+ ", factory=" + factory
+                        + ", isSetMetatypeFactoryPid=" + isSetMetatypeFactoryPid + ", activate="
+ activate + ", deactivate="
+                        + deactivate + ", modified=" + modified + ", specVersion=" + specVersion
+ ", configurationPid="
+                        + configurationPid + "]";
+    }
+
+    public String getConfigurationPid() {
+        return configurationPid;
+    }
+
+    public void setConfigurationPid(String configurationPid) {
+        this.configurationPid = configurationPid;
     }
 }
\ No newline at end of file

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java?rev=1350302&r1=1350301&r2=1350302&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/Component.java
Thu Jun 14 15:48:32 2012
@@ -81,6 +81,9 @@ public class Component extends AbstractO
     /** The class description. */
     private final ClassDescription classDescription;
 
+    /** Configuration PID (V1.2) */
+    private String configurationPid;
+
     /**
      * Constructor from java source.
      */
@@ -249,6 +252,12 @@ public class Component extends AbstractO
 
         // if the service is abstract, we do not validate everything
         if (!this.isAbstract) {
+            // if configuration pid is set and different from name, we need 1.2
+            if ( this.configurationPid != null && !this.configurationPid.equals(this.name)
+                 && context.getSpecVersion().ordinal() < SpecVersion.VERSION_1_2.ordinal()
) {
+                this.logError(context.getIssueLog(), "Different configuration pid requires
"
+                                + SpecVersion.VERSION_1_2.getName() + " or higher.");
+            }
             // ensure non-abstract, public class
             if (!Modifier.isPublic(context.getClassDescription().getDescribedClass().getModifiers()))
{
                 this.logError(context.getIssueLog(), "Class must be public: "
@@ -503,14 +512,18 @@ public class Component extends AbstractO
 
     @Override
     public String toString() {
-        return "Component " + this.name + " (" + "enabled=" + (enabled == null ? "<notset>"
: enabled) + ", immediate="
-                        + (immediate == null ? "<notset>" : immediate) + ", abstract="
+ isAbstract + ", isDS=" + isDs
-                        + (factory != null ? ", factory=" + factory : "")
-                        + (configurationPolicy != null ? ", configurationPolicy=" + configurationPolicy
: "")
-                        + (activate != null ? ", activate=" + activate : "")
-                        + (deactivate != null ? ", deactivate=" + deactivate : "")
-                        + (modified != null ? ", modified=" + modified : "") + ", specVersion="
+ specVersion
-                        + ", service=" + service + ", properties=" + properties
-                        + ", references=" + references + ")";
+        return "Component [name=" + name + ", enabled=" + enabled + ", immediate=" + immediate
+ ", factory=" + factory
+                        + ", properties=" + properties + ", service=" + service + ", references="
+ references + ", isAbstract="
+                        + isAbstract + ", isDs=" + isDs + ", configurationPolicy=" + configurationPolicy
+ ", activate="
+                        + activate + ", deactivate=" + deactivate + ", modified=" + modified
+ ", specVersion=" + specVersion
+                        + ", classDescription=" + classDescription + ", configurationPid="
+ configurationPid + "]";
+    }
+
+    public String getConfigurationPid() {
+        return configurationPid;
+    }
+
+    public void setConfigurationPid(String configurationPid) {
+        this.configurationPid = configurationPid;
     }
 }
\ No newline at end of file

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=1350302&r1=1350301&r2=1350302&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
Thu Jun 14 15:48:32 2012
@@ -101,6 +101,9 @@ public class ComponentDescriptorIO {
     /** Component: The modified attribute. */
     private static final String COMPONENT_ATTR_MODIFIED = "modified";
 
+    /** Component: The configuration pid attribute. */
+    private static final String COMPONENT_ATTR_CONFIGURATION_PID = "configuration-pid";
+
     private static final String IMPLEMENTATION = "implementation";
 
     private static final String IMPLEMENTATION_QNAME = IMPLEMENTATION;
@@ -160,7 +163,8 @@ public class ComponentDescriptorIO {
      * @param contentHandler
      * @throws SAXException
      */
-    protected static void generateXML(Components components, ContentHandler contentHandler)
throws SAXException {
+    protected static void generateXML(final Components components,
+                    final ContentHandler contentHandler) throws SAXException {
         // detect namespace to use
         final String namespace = components.getSpecVersion().getNamespaceUrl();
 
@@ -173,7 +177,10 @@ public class ComponentDescriptorIO {
 
         for (final Component component : components.getComponents()) {
             if (component.isDs()) {
+                final SpecVersion oldVersion = component.getSpecVersion();
+                component.setSpecVersion(components.getSpecVersion());
                 generateXML(namespace, component, contentHandler);
+                component.setSpecVersion(oldVersion);
             }
         }
         // end wrapper element
@@ -207,7 +214,12 @@ public class ComponentDescriptorIO {
             IOUtils.addAttribute(ai, COMPONENT_ATTR_DEACTIVATE, component.getDeactivate());
             IOUtils.addAttribute(ai, COMPONENT_ATTR_MODIFIED, component.getModified());
         }
-
+        // attributes new in 1.2
+        if ( component.getSpecVersion().ordinal() >= SpecVersion.VERSION_1_2.ordinal()
) {
+            if ( component.getConfigurationPid() != null && !component.getConfigurationPid().equals(component.getName()))
{
+                IOUtils.addAttribute(ai, COMPONENT_ATTR_CONFIGURATION_PID, component.getConfigurationPid());
+            }
+        }
         IOUtils.indent(contentHandler, 1);
         contentHandler.startElement(namespace, ComponentDescriptorIO.COMPONENT, ComponentDescriptorIO.COMPONENT_QNAME,
ai);
         IOUtils.newline(contentHandler);



Mime
View raw message