felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1341602 - in /felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin: SCRDescriptorGenerator.java description/ClassDescription.java
Date Tue, 22 May 2012 19:48:22 GMT
Author: cziegeler
Date: Tue May 22 19:48:22 2012
New Revision: 1341602

URL: http://svn.apache.org/viewvc?rev=1341602&view=rev
Log:
Add service information

Modified:
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
    felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?rev=1341602&r1=1341601&r2=1341602&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
(original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
Tue May 22 19:48:22 2012
@@ -24,6 +24,9 @@ import java.util.List;
 
 import org.apache.felix.scrplugin.description.ClassDescription;
 import org.apache.felix.scrplugin.description.ComponentDescription;
+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.description.SpecVersion;
 import org.apache.felix.scrplugin.helper.AnnotationProcessorManager;
 import org.apache.felix.scrplugin.helper.ClassScanner;
@@ -33,7 +36,9 @@ import org.apache.felix.scrplugin.om.Com
 import org.apache.felix.scrplugin.om.Components;
 import org.apache.felix.scrplugin.om.Context;
 import org.apache.felix.scrplugin.om.Implementation;
+import org.apache.felix.scrplugin.om.Interface;
 import org.apache.felix.scrplugin.om.Reference;
+import org.apache.felix.scrplugin.om.Service;
 import org.apache.felix.scrplugin.om.metatype.MetaData;
 import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
 import org.apache.felix.scrplugin.xml.MetaTypeIO;
@@ -123,8 +128,7 @@ public class SCRDescriptorGenerator {
 
     /**
      * Actually generates the Declarative Services and Metatype descriptors
-     * scanning the java sources provided by the {@link #setDescriptorManager(JavaClassDescriptorManager)
descriptor
-     * manager}.
+     * scanning the java sources provided by the {@link #setProject(Project)
      * 
      * @return <code>true</code> if descriptors have been generated.
      * 
@@ -271,7 +275,7 @@ public class SCRDescriptorGenerator {
         boolean addResources = false;
         // write meta type info if there is a file name
         if (!StringUtils.isEmpty(this.metaTypeName)) {
-            File mtFile = new File(this.outputDirectory, "OSGI-INF" + File.separator + "metatype"
+ File.separator
+            final File mtFile = new File(this.outputDirectory, "OSGI-INF" + File.separator
+ "metatype" + File.separator
                             + this.metaTypeName);
             final int size = metaData.getOCDs().size() + metaData.getDesignates().size();
             if (size > 0) {
@@ -319,9 +323,12 @@ public class SCRDescriptorGenerator {
         return addResources;
     }
 
+    /**
+     * Create the SCR objects based on the descriptions
+     */
     private Component createComponent(final ClassDescription desc, final MetaData metaData,
final IssueLog iLog)
                     throws SCRDescriptorException {
-        final ComponentDescription componentDesc = desc.getDescriptions(ComponentDescription.class).get(0);
+        final ComponentDescription componentDesc = desc.getDescription(ComponentDescription.class);
         final Component comp = new Component(desc, desc.getSource(), componentDesc.getAnnotation().getName());
 
         comp.setAbstract(componentDesc.isAbstract());
@@ -347,6 +354,45 @@ public class SCRDescriptorGenerator {
         final Implementation impl = new Implementation(desc.getDescribedClass().getName());
         comp.setImplementation(impl);
 
+        this.processServices(desc, comp);
+        this.processProperties(desc, comp);
+        this.processReferences(desc, comp);
+
         return comp;
     }
+
+    /**
+     * Process service directives
+     */
+    private void processServices(final ClassDescription desc, final Component component)
{
+        final ServiceDescription serviceDesc = desc.getDescription(ServiceDescription.class);
+        if ( serviceDesc != null ) {
+            final Service service = new Service();
+            service.setServiceFactory(serviceDesc.isServiceFactory());
+            for(final String className : serviceDesc.getInterfaces()) {
+                final Interface interf = new Interface();
+                interf.setInterfaceName(className);
+                service.addInterface(interf);
+            }
+            component.setService(service);
+        }
+    }
+
+    /**
+     * Process property directives
+     */
+    private void processProperties(final ClassDescription desc, final Component component)
{
+        for(final PropertyDescription pd : desc.getDescriptions(PropertyDescription.class))
{
+
+        }
+    }
+
+    /**
+     * Process reference directives
+     */
+    private void processReferences(final ClassDescription desc, final Component component)
{
+        for(final ReferenceDescription rd : desc.getDescriptions(ReferenceDescription.class))
{
+
+        }
+    }
 }

Modified: felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java?rev=1341602&r1=1341601&r2=1341602&view=diff
==============================================================================
--- felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java
(original)
+++ felix/sandbox/cziegeler/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/description/ClassDescription.java
Tue May 22 19:48:22 2012
@@ -60,10 +60,18 @@ public class ClassDescription {
         return result;
     }
 
+    public <T extends AbstractDescription> T getDescription(final Class<T> descType)
{
+        final List<T> result = this.getDescriptions(descType);
+        if ( result.size() > 0 ) {
+            return result.get(0);
+        }
+        return null;
+    }
+
     @Override
     public String toString() {
         return "ClassDescription [descriptions=" + descriptions
-                + ", describedClass=" + describedClass + ", source=" + source
-                + "]";
+                        + ", describedClass=" + describedClass + ", source=" + source
+                        + "]";
     }
 }
\ No newline at end of file



Mime
View raw message