OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | fractal-commits List | April 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[fractal-commits] [7559] trunk/fraclet/fraclet-java: Adding support for introspection of third party libraries.


Title: [7559] trunk/fraclet/fraclet-java: Adding support for introspection of third party libraries.
Revision
7559
Author
rouvoy
Date
2008-04-30 16:15:44 +0200 (Wed, 30 Apr 2008)

Log Message

Adding support for introspection of third party libraries.

Modified Paths

Diff

Modified: trunk/fraclet/fraclet-java/fraclet-examples/helloworld/src/main/java/org/objectweb/fractal/helloworld/AbstractClient.java (7558 => 7559)


--- trunk/fraclet/fraclet-java/fraclet-examples/helloworld/src/main/java/org/objectweb/fractal/helloworld/AbstractClient.java	2008-04-30 06:37:41 UTC (rev 7558)
+++ trunk/fraclet/fraclet-java/fraclet-examples/helloworld/src/main/java/org/objectweb/fractal/helloworld/AbstractClient.java	2008-04-30 14:15:44 UTC (rev 7559)
@@ -3,13 +3,17 @@
 import org.objectweb.fractal.fraclet.annotations.Attribute;
 import org.objectweb.fractal.fraclet.annotations.Component;
 import org.objectweb.fractal.fraclet.annotations.Definition;
+import org.objectweb.fractal.fraclet.annotations.Interface;
 
 /**
  * Partial implementation of a Helloworld client component.
+ * 
  * @author Romain Rouvoy (Initial Developer)
  * @version $Revision$
  */
-@Component(uses=@Definition(name="ClientSkeleton",arguments={"en","Empty definition"}))
+@Component(uses = @Definition(name = "ClientSkeleton", arguments = { "en","Empty definition" }),
+           provides = @Interface(name = "r", signature = Runnable.class))
 public abstract class AbstractClient implements Runnable {
-    protected @Attribute String message;
+    protected @Attribute
+    String message;
 }
\ No newline at end of file

Modified: trunk/fraclet/fraclet-java/fraclet-examples/helloworld/src/main/java/org/objectweb/fractal/helloworld/Client.java (7558 => 7559)


--- trunk/fraclet/fraclet-java/fraclet-examples/helloworld/src/main/java/org/objectweb/fractal/helloworld/Client.java	2008-04-30 06:37:41 UTC (rev 7558)
+++ trunk/fraclet/fraclet-java/fraclet-examples/helloworld/src/main/java/org/objectweb/fractal/helloworld/Client.java	2008-04-30 14:15:44 UTC (rev 7559)
@@ -28,7 +28,6 @@
 import org.objectweb.fractal.api.control.NameController;
 import org.objectweb.fractal.fraclet.annotations.Component;
 import org.objectweb.fractal.fraclet.annotations.Controller;
-import org.objectweb.fractal.fraclet.annotations.Interface;
 import org.objectweb.fractal.fraclet.annotations.Lifecycle;
 import org.objectweb.fractal.fraclet.annotations.Requires;
 
@@ -38,7 +37,7 @@
  * @author Romain Rouvoy (Initial Developer)
  * @version $Revision$
  */
-@Component(name = "helloworld.Client", provides = @Interface(name = "r", signature = Runnable.class))
+@Component(name = "helloworld.Client")
 public class Client extends AbstractClient {
     private final Logger log = getLogger("client");
     private @Requires(name = "s") Service service;

Modified: trunk/fraclet/fraclet-java/fractaladl-spoonlet/src/main/java/org/objectweb/fractal/adl/spoonlet/component/InheritedComponentProcessor.java (7558 => 7559)


--- trunk/fraclet/fraclet-java/fractaladl-spoonlet/src/main/java/org/objectweb/fractal/adl/spoonlet/component/InheritedComponentProcessor.java	2008-04-30 06:37:41 UTC (rev 7558)
+++ trunk/fraclet/fraclet-java/fractaladl-spoonlet/src/main/java/org/objectweb/fractal/adl/spoonlet/component/InheritedComponentProcessor.java	2008-04-30 14:15:44 UTC (rev 7559)
@@ -69,24 +69,25 @@
      * @see spoon.processing.AnnotationProcessor#process(java.lang.annotation.Annotation, spoon.reflect.declaration.CtElement)
      */
     public void process(Component ann, CtClass<?> cls) {
+        getEnvironment().debugMessage(
+                "[FractalADL] Inferring extended definitions for  "
+                        + cls.getQualifiedName() + "...");
         Element root = primitive().definition(cls);
         for (CtTypeReference<?> type = cls.getSuperclass(); type != null; type = type
-                .getSuperclass())
-            try { // Retrieves all the inherited attributes
-                Component a = type.getAnnotation(Component.class);
-                if (a != null) {
-                    Arguments arg = getArguments(type);
-                    if (arg.isEmpty())
-                        addDefinitionExtends(root, componentFullname(type, a));
-                    else {
-                        addDefinitionExtends(root, componentFullname(type, a)
-                                + "(" + arg.asParameters() + ")");
-                        addDefinitionArguments(root, arg);
-                    }
-                    break;
+                .getSuperclass()) {
+            Component a = type.getAnnotation(Component.class);
+            if (a != null) {
+                Arguments arg = getArguments(type);
+                if (arg.isEmpty())
+                    addDefinitionExtends(root, componentFullname(type, a));
+                else {
+                    addDefinitionExtends(root, componentFullname(type, a) + "("
+                            + arg.asParameters() + ")");
+                    addDefinitionArguments(root, arg);
                 }
-            } catch (Exception e) { // parent is not a component, continue
+                break;
             }
+        }
     }
 
     /**
@@ -103,8 +104,13 @@
                     (CtType<?>) type.getDeclaration()).getAttribute(
                     DEF_ARGUMENTS);
         Arguments args = new Arguments();
+
         for (CtFieldReference<?> fld : type.getAllFields())
-            args.put(attributeName(fld), attributeValue(fld));
+            try {
+                args.put(attributeName(fld), attributeValue(fld));
+            } catch (RuntimeException ex) {
+                // Ignore exception when trying to infer wrong Fractal elements.
+            }
         return args;
     }
 }
\ No newline at end of file

Modified: trunk/fraclet/fraclet-java/fractaladl-spoonlet/src/main/java/org/objectweb/fractal/adl/spoonlet/component/LegacyDefinitionProcessor.java (7558 => 7559)


--- trunk/fraclet/fraclet-java/fractaladl-spoonlet/src/main/java/org/objectweb/fractal/adl/spoonlet/component/LegacyDefinitionProcessor.java	2008-04-30 06:37:41 UTC (rev 7558)
+++ trunk/fraclet/fraclet-java/fractaladl-spoonlet/src/main/java/org/objectweb/fractal/adl/spoonlet/component/LegacyDefinitionProcessor.java	2008-04-30 14:15:44 UTC (rev 7559)
@@ -54,6 +54,14 @@
     }
 
     /* (non-Javadoc)
+     * @see spoon.processing.AbstractAnnotationProcessor#inferConsumedAnnotationType()
+     */
+    @Override
+    public boolean inferConsumedAnnotationType() {
+        return false;
+    }
+
+    /* (non-Javadoc)
      * @see spoon.processing.AnnotationProcessor#process(java.lang.annotation.Annotation, spoon.reflect.declaration.CtElement)
      */
     public void process(Definition ann, CtClass<?> cls) {


<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.