Mail Archive Home | fractal-commits List | April 2008 Index
| <-- Date Index --> | <-- Thread Index --> |
Adding support for introspection of third party libraries.
--- 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
--- 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;
--- 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
--- 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 --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.