You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2008/03/04 14:02:16 UTC

svn commit: r633462 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: ./ om/ tags/cl/ xml/

Author: cziegeler
Date: Tue Mar  4 05:02:15 2008
New Revision: 633462

URL: http://svn.apache.org/viewvc?rev=633462&view=rev
Log:
IN PROGRESS - issue FELIX-507: properties and service names of extended components not always included 
https://issues.apache.org/jira/browse/FELIX-507

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java?rev=633462&r1=633461&r2=633462&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java Tue Mar  4 05:02:15 2008
@@ -116,6 +116,14 @@
             || name.equals(ConfigurationAdmin.SERVICE_BUNDLELOCATION)
             || name.equals(ConfigurationAdmin.SERVICE_FACTORYPID);
 
+        // if this is an abstract component we store the extra info in the property
+        if ( component.isAbstract() ) {
+            prop.setPrivate(isPrivate);
+            prop.setLabel(tag.getNamedParameter(Constants.PROPERTY_LABEL));
+            prop.setDescription(tag.getNamedParameter(Constants.PROPERTY_DESCRIPTION));
+            prop.setCardinality(tag.getNamedParameter(Constants.PROPERTY_CARDINALITY));
+        }
+
         // if this is a public property and the component is generating metatype info
         // store the information!
         if ( !isPrivate && ocd != null ) {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java?rev=633462&r1=633461&r2=633462&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Component.java Tue Mar  4 05:02:15 2008
@@ -242,7 +242,7 @@
                             issues.add(this.getMessage("Service interface information is missing for @scr.service tag"));
                         }
                         this.getService().validate(issues, warnings);
-                        isServiceFactory = Boolean.valueOf(this.getService().getServicefactory()).booleanValue();
+                        isServiceFactory = this.getService().isServicefactory();
                     }
 
                     // serviceFactory must not be true for immediate of component factory

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java?rev=633462&r1=633461&r2=633462&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Property.java Tue Mar  4 05:02:15 2008
@@ -33,6 +33,11 @@
     protected String type;
     protected String[] multiValue;
 
+    protected boolean isPrivate;
+    protected String label;
+    protected String description;
+    protected String cardinality;
+
     /**
      * Default constructor.
      */
@@ -92,4 +97,37 @@
         }
         // might want to check type (and value)
     }
+
+    public boolean isPrivate() {
+        return isPrivate;
+    }
+
+    public void setPrivate(boolean isPrivate) {
+        this.isPrivate = isPrivate;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getCardinality() {
+        return cardinality;
+    }
+
+    public void setCardinality(String cardinality) {
+        this.cardinality = cardinality;
+    }
+
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java?rev=633462&r1=633461&r2=633462&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/Service.java Tue Mar  4 05:02:15 2008
@@ -28,7 +28,7 @@
  */
 public class Service {
 
-    protected String servicefactory;
+    protected boolean isServicefactory;
 
     /** The list of implemented interfaces. */
     protected final List interfaces = new ArrayList();
@@ -40,16 +40,18 @@
         // nothing to do
     }
 
-    public String getServicefactory() {
-        return this.servicefactory;
+    public boolean isServicefactory() {
+        return this.isServicefactory;
     }
 
     public void setServicefactory(String servicefactory) {
-        this.servicefactory = servicefactory;
+        if ( servicefactory != null ) {
+            this.isServicefactory = Boolean.valueOf(servicefactory).booleanValue();
+        }
     }
 
-    public void setServicefactory(boolean servicefactory) {
-        this.servicefactory = String.valueOf(servicefactory);
+    public void setServicefactory(boolean flag) {
+        this.isServicefactory = flag;
     }
 
     public List getInterfaces() {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java?rev=633462&r1=633461&r2=633462&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java Tue Mar  4 05:02:15 2008
@@ -22,8 +22,7 @@
 import java.util.*;
 
 import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.om.Component;
-import org.apache.felix.scrplugin.om.Reference;
+import org.apache.felix.scrplugin.om.*;
 import org.apache.felix.scrplugin.tags.*;
 import org.apache.maven.plugin.MojoExecutionException;
 
@@ -164,7 +163,8 @@
      * @see org.apache.felix.scrplugin.tags.JavaClassDescription#getTagByName(java.lang.String)
      */
     public JavaTag getTagByName(String name) {
-        // TODO Auto-generated method stub
+        // this is only used to retrieve the component tag, so we can ignore it
+        // for classes from other bundles and simply return null
         return null;
     }
 
@@ -176,9 +176,21 @@
         JavaTag[] javaTags = EMPTY_TAGS;
         if ( this.component != null ) {
             if ( Constants.SERVICE.equals(name) ) {
-
+                if ( this.component.getService() != null &&
+                     this.component.getService().getInterfaces().size() > 0 ) {
+                    javaTags = new JavaTag[this.component.getService().getInterfaces().size()];
+                    for(int i=0; i<this.component.getService().getInterfaces().size(); i++) {
+                        javaTags[i] = new ClassLoaderJavaTag(this, (Interface)this.component.getProperties().get(i),
+                                                             this.component.getService().isServicefactory());
+                    }
+                }
             } else if ( Constants.PROPERTY.equals(name) ) {
-
+                if ( this.component.getProperties().size() > 0 ) {
+                    javaTags = new JavaTag[this.component.getProperties().size()];
+                    for(int i=0; i<this.component.getProperties().size(); i++) {
+                        javaTags[i] = new ClassLoaderJavaTag(this, (Property)this.component.getProperties().get(i));
+                    }
+                }
             } else if ( Constants.REFERENCE.equals(name) ) {
                 if ( this.component.getReferences().size() > 0 ) {
                     javaTags = new JavaTag[this.component.getReferences().size()];

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java?rev=633462&r1=633461&r2=633462&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java Tue Mar  4 05:02:15 2008
@@ -22,10 +22,8 @@
 import java.util.Map;
 
 import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.om.Reference;
-import org.apache.felix.scrplugin.tags.JavaClassDescription;
-import org.apache.felix.scrplugin.tags.JavaField;
-import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.om.*;
+import org.apache.felix.scrplugin.tags.*;
 
 /**
  * <code>ClassLoaderJavaTag.java</code>...
@@ -35,10 +33,30 @@
 
     protected final JavaClassDescription description;
     protected final Reference reference;
+    protected final Property property;
+    protected final Interface interf;
+    protected boolean isServiceFactory;
 
     public ClassLoaderJavaTag(JavaClassDescription desc, Reference reference) {
+        this.description = desc;
         this.reference = reference;
+        this.interf = null;
+        this.property = null;
+    }
+
+    public ClassLoaderJavaTag(JavaClassDescription desc, Property property) {
+        this.description = desc;
+        this.property = property;
+        this.reference = null;
+        this.interf = null;
+    }
+
+    public ClassLoaderJavaTag(JavaClassDescription desc, Interface i, boolean isSF) {
+        this.interf = i;
         this.description = desc;
+        this.property = null;
+        this.reference = null;
+        this.isServiceFactory = isSF;
     }
 
     /**
@@ -62,6 +80,10 @@
     public String getName() {
         if ( this.reference != null ) {
             return Constants.REFERENCE;
+        } else if ( this.property != null ) {
+            return Constants.PROPERTY;
+        } else if ( this.interf != null ) {
+            return Constants.SERVICE;
         }
         return null;
     }
@@ -90,6 +112,36 @@
             map.put(Constants.REFERENCE_POLICY, this.reference.getPolicy());
             map.put(Constants.REFERENCE_TARGET, this.reference.getTarget());
             map.put(Constants.REFERENCE_UNDBIND, this.reference.getUnbind());
+            return map;
+        } else if ( this.property != null ) {
+            final Map map = new HashMap();
+            map.put(Constants.PROPERTY_TYPE, this.property.getType());
+            map.put(Constants.PROPERTY_NAME, this.property.getName());
+            final String[] values = this.property.getMultiValue();
+            if ( values != null ) {
+                for(int i=0; i<values.length;i++) {
+                    map.put(Constants.PROPERTY_MULTIVALUE_PREFIX + '.' + i, values[i]);
+                }
+            } else {
+                map.put(Constants.PROPERTY_VALUE, this.property.getValue());
+            }
+            map.put(Constants.PROPERTY_PRIVATE, String.valueOf(property.isPrivate()));
+            if ( this.property.getLabel() != null ) {
+                map.put(Constants.PROPERTY_LABEL, this.property.getLabel());
+            }
+            if ( this.property.getDescription() != null ) {
+                map.put(Constants.PROPERTY_DESCRIPTION, this.property.getDescription());
+            }
+            if ( this.property.getCardinality() != null ) {
+                map.put(Constants.PROPERTY_CARDINALITY, this.property.getCardinality());
+            }
+            return map;
+        } else if ( this.interf != null ) {
+            final Map map = new HashMap();
+            map.put(Constants.SERVICE_INTERFACE, this.interf.getInterfacename());
+            if ( this.isServiceFactory ) {
+                map.put(Constants.SERVICE_FACTORY, "true");
+            }
             return map;
         }
         return null;

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=633462&r1=633461&r2=633462&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java Tue Mar  4 05:02:15 2008
@@ -25,17 +25,9 @@
 
 import javax.xml.transform.TransformerException;
 
-import org.apache.felix.scrplugin.om.Component;
-import org.apache.felix.scrplugin.om.Components;
-import org.apache.felix.scrplugin.om.Implementation;
-import org.apache.felix.scrplugin.om.Interface;
-import org.apache.felix.scrplugin.om.Property;
-import org.apache.felix.scrplugin.om.Reference;
-import org.apache.felix.scrplugin.om.Service;
+import org.apache.felix.scrplugin.om.*;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
 import org.xml.sax.helpers.AttributesImpl;
 import org.xml.sax.helpers.DefaultHandler;
 
@@ -158,7 +150,7 @@
             final Iterator i = component.getProperties().iterator();
             while ( i.hasNext() ) {
                 final Property property = (Property)i.next();
-                generateXML(property, contentHandler);
+                generateXML(property, contentHandler, component.isAbstract());
             }
         }
         if ( component.getReferences() != null ) {
@@ -194,7 +186,7 @@
     protected static void generateXML(Service service, ContentHandler contentHandler)
     throws SAXException {
         final AttributesImpl ai = new AttributesImpl();
-        IOUtils.addAttribute(ai, "servicefactory", service.getServicefactory());
+        IOUtils.addAttribute(ai, "servicefactory", String.valueOf(service.isServicefactory()));
         contentHandler.startElement(NAMESPACE_URI, ComponentDescriptorIO.SERVICE, ComponentDescriptorIO.SERVICE_QNAME, ai);
         if ( service.getInterfaces() != null ) {
             final Iterator i = service.getInterfaces().iterator();
@@ -226,12 +218,25 @@
      * @param contentHandler
      * @throws SAXException
      */
-    protected static void generateXML(Property property, ContentHandler contentHandler)
+    protected static void generateXML(Property property, ContentHandler contentHandler, boolean isAbstract)
     throws SAXException {
         final AttributesImpl ai = new AttributesImpl();
         IOUtils.addAttribute(ai, "name", property.getName());
         IOUtils.addAttribute(ai, "type", property.getType());
         IOUtils.addAttribute(ai, "value", property.getValue());
+        // we have to write more information if the component is abstract
+        if ( isAbstract ) {
+            IOUtils.addAttribute(ai, "private", String.valueOf(property.isPrivate()));
+            if ( property.getLabel() != null ) {
+                IOUtils.addAttribute(ai, "label", String.valueOf(property.getLabel()));
+            }
+            if ( property.getDescription() != null ) {
+                IOUtils.addAttribute(ai, "description", String.valueOf(property.getDescription()));
+            }
+            if ( property.getCardinality() != null ) {
+                IOUtils.addAttribute(ai, "cardinality", String.valueOf(property.getCardinality()));
+            }
+        }
         contentHandler.startElement(NAMESPACE_URI, ComponentDescriptorIO.PROPERTY, ComponentDescriptorIO.PROPERTY_QNAME, ai);
         if ( property.getMultiValue() != null && property.getMultiValue().length > 0 ) {
             // generate a new line first
@@ -342,6 +347,14 @@
                     } else {
                         // hold the property pending as we have a multi value
                         this.pendingProperty = prop;
+                    }
+                    // check for abstract properties
+                    prop.setLabel(attributes.getValue("label"));
+                    prop.setDescription(attributes.getValue("description"));
+                    prop.setCardinality(attributes.getValue("cardinality"));
+                    final String pValue = attributes.getValue("private");
+                    if ( pValue != null ) {
+                        prop.setPrivate(Boolean.valueOf(pValue).booleanValue());
                     }
 
                 } else if (localName.equals("properties")) {