felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1379338 - in /felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin: ./ helper/ om/metatype/ xml/
Date Fri, 31 Aug 2012 07:47:58 GMT
Author: cziegeler
Date: Fri Aug 31 07:47:57 2012
New Revision: 1379338

URL: http://svn.apache.org/viewvc?rev=1379338&view=rev
Log:
FELIX-3641 :  Option to generate separate descriptor files 

Added:
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeAttributeDefinition.java
      - copied, changed from r1372268, felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeContainer.java
      - copied, changed from r1372268, felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java
Removed:
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/Designate.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java
Modified:
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ComponentContainer.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java

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=1379338&r1=1379337&r2=1379338&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
Fri Aug 31 07:47:57 2012
@@ -42,11 +42,10 @@ import org.apache.felix.scrplugin.helper
 import org.apache.felix.scrplugin.helper.ComponentContainer;
 import org.apache.felix.scrplugin.helper.DescriptionContainer;
 import org.apache.felix.scrplugin.helper.IssueLog;
+import org.apache.felix.scrplugin.helper.MetatypeAttributeDefinition;
+import org.apache.felix.scrplugin.helper.MetatypeContainer;
 import org.apache.felix.scrplugin.helper.StringUtils;
 import org.apache.felix.scrplugin.helper.Validator;
-import org.apache.felix.scrplugin.om.metatype.AttributeDefinition;
-import org.apache.felix.scrplugin.om.metatype.Designate;
-import org.apache.felix.scrplugin.om.metatype.OCD;
 import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
 import org.apache.felix.scrplugin.xml.MetaTypeIO;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -289,11 +288,11 @@ public class SCRDescriptorGenerator {
         final ComponentContainer container = new ComponentContainer(desc, componentDesc);
 
         // Create metatype (if required)
-        final OCD ocd;
+        final MetatypeContainer ocd;
         if ( !componentDesc.isAbstract() && componentDesc.isCreateMetatype() ) {
             // OCD
-            ocd = new OCD();
-            container.setOCD( ocd );
+            ocd = new MetatypeContainer();
+            container.setMetatypeContainer( ocd );
             ocd.setId( componentDesc.getName() );
             if ( componentDesc.getLabel() != null ) {
                 ocd.setName( componentDesc.getLabel() );
@@ -306,15 +305,10 @@ public class SCRDescriptorGenerator {
                 ocd.setDescription( "%" + componentDesc.getName() + ".description");
             }
 
-            // Designate
-            final Designate designate = new Designate();
-            container.setDesignate( designate );
-            designate.setPid( componentDesc.getName() );
-
             // Factory pid
             if ( componentDesc.isSetMetatypeFactoryPid() ) {
                 if ( componentDesc.getFactory() == null ) {
-                    designate.setFactoryPid( componentDesc.getName() );
+                    ocd.setFactoryPid( componentDesc.getName() );
                 } else {
                     iLog.addWarning( "Component factory " + componentDesc.getName()
                         + " should not set metatype factory pid.", desc.getSource() );
@@ -424,7 +418,7 @@ public class SCRDescriptorGenerator {
     private void processProperties(
                     final ClassDescription current,
                     final ComponentContainer component,
-                    final OCD ocd) {
+                    final MetatypeContainer ocd) {
         for(final PropertyDescription pd : current.getDescriptions(PropertyDescription.class))
{
 
             if ( this.testProperty(current, component.getProperties(), pd, current == component.getClassDescription())
&& ocd != null) {
@@ -448,7 +442,7 @@ public class SCRDescriptorGenerator {
                     }
                 }
                 if ( !isPrivate ) {
-                    final AttributeDefinition ad = new AttributeDefinition();
+                    final MetatypeAttributeDefinition ad = new MetatypeAttributeDefinition();
                     ocd.getProperties().add(ad);
                     ad.setId(pd.getName());
                     ad.setType(pd.getType().name());

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ComponentContainer.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ComponentContainer.java?rev=1379338&r1=1379337&r2=1379338&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ComponentContainer.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ComponentContainer.java
Fri Aug 31 07:47:57 2012
@@ -26,8 +26,6 @@ import org.apache.felix.scrplugin.descri
 import org.apache.felix.scrplugin.description.PropertyDescription;
 import org.apache.felix.scrplugin.description.ReferenceDescription;
 import org.apache.felix.scrplugin.description.ServiceDescription;
-import org.apache.felix.scrplugin.om.metatype.Designate;
-import org.apache.felix.scrplugin.om.metatype.OCD;
 
 
 /**
@@ -56,11 +54,8 @@ public class ComponentContainer {
     /** All properties. */
     private final Map<String, PropertyDescription> allProperties = new LinkedHashMap<String,
PropertyDescription>();
 
-    /** Metatype: OCD. */
-    private OCD ocd;
-
-    /** Metatype: Designate. */
-    private Designate designate;
+    /** Metatype container. */
+    private MetatypeContainer metatype;
 
     /**
      * Create a new component container
@@ -132,19 +127,11 @@ public class ComponentContainer {
                         + allProperties + "]";
     }
 
-    public OCD getOCD() {
-        return ocd;
-    }
-
-    public void setOCD(final OCD ocd) {
-        this.ocd = ocd;
-    }
-
-    public Designate getDesignate() {
-        return designate;
+    public MetatypeContainer getMetatypeContainer() {
+        return this.metatype;
     }
 
-    public void setDesignate(final Designate designate) {
-        this.designate = designate;
+    public void setMetatypeContainer(final MetatypeContainer ocd) {
+        this.metatype = ocd;
     }
 }

Copied: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeAttributeDefinition.java
(from r1372268, felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java)
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeAttributeDefinition.java?p2=felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeAttributeDefinition.java&p1=felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java&r1=1372268&r2=1379338&rev=1379338&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeAttributeDefinition.java
Fri Aug 31 07:47:57 2012
@@ -16,29 +16,29 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scrplugin.om.metatype;
+package org.apache.felix.scrplugin.helper;
 
 import java.util.Map;
 
-public class AttributeDefinition {
+public class MetatypeAttributeDefinition {
 
-    public static final String DEFAULT_TYPE = "String";
+    private static final String DEFAULT_TYPE = "String";
 
-    protected String id;
+    private String id;
 
-    protected String type = DEFAULT_TYPE;
+    private String type = DEFAULT_TYPE;
 
-    protected String defaultValue;
+    private String defaultValue;
 
-    protected String name;
+    private String name;
 
-    protected String[] defaultMultiValue;
+    private String[] defaultMultiValue;
 
-    protected String description;
+    private String description;
 
-    protected Integer cardinality;
+    private Integer cardinality;
 
-    protected Map<String, String> options;
+    private Map<String, String> options;
 
     public String getId() {
         return this.id;

Copied: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeContainer.java
(from r1372268, felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java)
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeContainer.java?p2=felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeContainer.java&p1=felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java&r1=1372268&r2=1379338&rev=1379338&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/MetatypeContainer.java
Fri Aug 31 07:47:57 2012
@@ -16,20 +16,22 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scrplugin.om.metatype;
+package org.apache.felix.scrplugin.helper;
 
 import java.util.ArrayList;
 import java.util.List;
 
-public class OCD {
+public class MetatypeContainer {
 
-    protected String id;
+    private String id;
 
-    protected String name;
+    private String name;
 
-    protected String description;
+    private String description;
 
-    protected List<AttributeDefinition> properties = new ArrayList<AttributeDefinition>();
+    private String factoryPid;
+
+    private final List<MetatypeAttributeDefinition> properties = new ArrayList<MetatypeAttributeDefinition>();
 
     public String getId() {
         return this.id;
@@ -55,11 +57,15 @@ public class OCD {
         this.description = description;
     }
 
-    public List<AttributeDefinition> getProperties() {
+    public List<MetatypeAttributeDefinition> getProperties() {
         return this.properties;
     }
 
-    public void setProperties(List<AttributeDefinition> properties) {
-        this.properties = properties;
+    public String getFactoryPid() {
+        return this.factoryPid;
+    }
+
+    public void setFactoryPid(String pid) {
+        this.factoryPid = pid;
     }
 }

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java?rev=1379338&r1=1379337&r2=1379338&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
Fri Aug 31 07:47:57 2012
@@ -29,10 +29,9 @@ import org.apache.felix.scrplugin.Option
 import org.apache.felix.scrplugin.SCRDescriptorException;
 import org.apache.felix.scrplugin.helper.ComponentContainer;
 import org.apache.felix.scrplugin.helper.DescriptionContainer;
+import org.apache.felix.scrplugin.helper.MetatypeAttributeDefinition;
+import org.apache.felix.scrplugin.helper.MetatypeContainer;
 import org.apache.felix.scrplugin.helper.StringUtils;
-import org.apache.felix.scrplugin.om.metatype.AttributeDefinition;
-import org.apache.felix.scrplugin.om.metatype.Designate;
-import org.apache.felix.scrplugin.om.metatype.OCD;
 import org.osgi.service.metatype.MetaTypeService;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -77,7 +76,7 @@ public class MetaTypeIO {
     throws SCRDescriptorException {
         int metatypeCount = 0;
         for(final ComponentContainer component : module.getComponents()) {
-            if ( component.getOCD() != null ) {
+            if ( component.getMetatypeContainer() != null ) {
                 metatypeCount++;
             }
         }
@@ -134,9 +133,9 @@ public class MetaTypeIO {
         IOUtils.newline(contentHandler);
 
         for(final ComponentContainer comp : metaData.getComponents()) {
-            if ( comp.getOCD() != null ) {
-                generateXML(comp.getOCD(), contentHandler);
-                generateXML(comp.getDesignate(), contentHandler);
+            if ( comp.getMetatypeContainer() != null ) {
+                generateOCDXML(comp.getMetatypeContainer(), contentHandler);
+                generateDesignateXML(comp.getMetatypeContainer(), contentHandler);
             }
         }
 
@@ -147,7 +146,7 @@ public class MetaTypeIO {
         contentHandler.endDocument();
     }
 
-    private static void generateXML(OCD ocd, ContentHandler contentHandler)
+    private static void generateOCDXML(final MetatypeContainer ocd, final ContentHandler
contentHandler)
     throws SAXException {
         final AttributesImpl ai = new AttributesImpl();
         IOUtils.addAttribute(ai, "id", ocd.getId());
@@ -158,10 +157,10 @@ public class MetaTypeIO {
 
         if ( ocd.getProperties().size() > 0 ) {
             IOUtils.newline(contentHandler);
-            final Iterator<AttributeDefinition> i = ocd.getProperties().iterator();
+            final Iterator<MetatypeAttributeDefinition> i = ocd.getProperties().iterator();
             while ( i.hasNext() ) {
-                final AttributeDefinition ad = i.next();
-                generateXML(ad, contentHandler);
+                final MetatypeAttributeDefinition ad = i.next();
+                generateAttributeXML(ad, contentHandler);
             }
             IOUtils.indent(contentHandler, 1);
         }
@@ -170,7 +169,7 @@ public class MetaTypeIO {
         IOUtils.newline(contentHandler);
     }
 
-    private static void generateXML(AttributeDefinition ad, ContentHandler contentHandler)
+    private static void generateAttributeXML(final MetatypeAttributeDefinition ad, final
ContentHandler contentHandler)
     throws SAXException {
         final AttributesImpl ai = new AttributesImpl();
         IOUtils.addAttribute(ai, "id", ad.getId());
@@ -212,10 +211,10 @@ public class MetaTypeIO {
         IOUtils.newline(contentHandler);
     }
 
-    private static void generateXML(final Designate designate, final ContentHandler contentHandler)
+    private static void generateDesignateXML(final MetatypeContainer designate, final ContentHandler
contentHandler)
     throws SAXException {
         final AttributesImpl ai = new AttributesImpl();
-        IOUtils.addAttribute(ai, "pid", designate.getPid());
+        IOUtils.addAttribute(ai, "pid", designate.getId());
         IOUtils.addAttribute(ai, "factoryPid", designate.getFactoryPid());
         IOUtils.indent(contentHandler, 1);
         contentHandler.startElement(INNER_NAMESPACE_URI, DESIGNATE_ELEMENT, DESIGNATE_ELEMENT_QNAME,
ai);
@@ -228,10 +227,10 @@ public class MetaTypeIO {
         IOUtils.newline(contentHandler);
     }
 
-    private static void generateObjectXML(final Designate obj, final ContentHandler contentHandler)
+    private static void generateObjectXML(final MetatypeContainer obj, final ContentHandler
contentHandler)
     throws SAXException {
         final AttributesImpl ai = new AttributesImpl();
-        IOUtils.addAttribute(ai, "ocdref", obj.getPid());
+        IOUtils.addAttribute(ai, "ocdref", obj.getId());
         IOUtils.indent(contentHandler, 2);
         contentHandler.startElement(INNER_NAMESPACE_URI, OBJECT_ELEMENT, OBJECT_ELEMENT_QNAME,
ai);
         contentHandler.endElement(INNER_NAMESPACE_URI, OBJECT_ELEMENT, OBJECT_ELEMENT_QNAME);



Mime
View raw message