Mail Archive Home | fractal-commits List | May 2006 Index
| <-- Date Index --> | <-- Thread Index --> |
Date: Friday, May 26, 2006 @ 15:34:17
Author: pessemier
Path: /cvsroot/fractal/fraclet/fraclet-annotation
Added: src/org/objectweb/fractal/fraclet/annotation/Attribute.java
src/org/objectweb/fractal/fraclet/annotation/ComponentDesc.java
src/org/objectweb/fractal/fraclet/annotation/DisableADL.java
src/org/objectweb/fractal/fraclet/annotation/Interface.java
src/org/objectweb/fractal/fraclet/annotation/LifeCycle.java
src/org/objectweb/fractal/fraclet/annotation/LifeCycleType.java
src/org/objectweb/fractal/fraclet/annotation/Provides.java
src/org/objectweb/fractal/fraclet/annotation/Requires.java
src/org/objectweb/fractal/fraclet/annotation/Service.java
src/org/objectweb/fractal/fraclet/annotation/generator/ADLGenerator.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/AttributeTemplate.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/RequiresTemplate.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/ServiceTemplate.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/package.html
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/NonTypedFractalAttributeException.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/None.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/_R_.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/_T_.java
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/package.html
src/org/objectweb/fractal/fraclet/annotation/processor/ADLProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/AttributeProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/InterfaceProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/RequiresProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/ServiceProcessor.java
Modified: build.xml examples/comanche/src/comanche/BasicLogger.java
examples/comanche/src/comanche/ErrorRequestHandler.java
examples/comanche/src/comanche/FileRequestHandler.java
examples/comanche/src/comanche/Logger.java
examples/comanche/src/comanche/MultiThreadScheduler.java
examples/comanche/src/comanche/RequestAnalyzer.java
examples/comanche/src/comanche/RequestDispatcher.java
examples/comanche/src/comanche/RequestHandler.java
examples/comanche/src/comanche/RequestReceiver.java
examples/comanche/src/comanche/Scheduler.java
examples/comanche/src/comanche/SequentialScheduler.java
examples/primitive/src/primitive/Client.java
examples/primitive/src/primitive/ServerA.java
examples/primitive/src/primitive/ServerB.java
examples/primitive/src/primitive/Service.java
src/org/objectweb/fractal/fraclet/annotation/ant/FracletAnnotation.java
src/org/objectweb/fractal/fraclet/annotation/processor/FractalAnnotationProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/util/ADLFileFactory.java
Removed: src/org/objectweb/fractal/fraclet/annotation/FractalAC.java
src/org/objectweb/fractal/fraclet/annotation/FractalBC.java
src/org/objectweb/fractal/fraclet/annotation/FractalComponent.java
src/org/objectweb/fractal/fraclet/annotation/FractalImportedInterface.java
src/org/objectweb/fractal/fraclet/annotation/FractalItf.java
src/org/objectweb/fractal/fraclet/annotation/FractalRC.java
src/org/objectweb/fractal/fraclet/annotation/processor/FractalACProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/FractalBCProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/FractalComponentProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/FractalItfProcessor.java
src/org/objectweb/fractal/fraclet/annotation/processor/FractalRCProcessor.java
src/org/objectweb/fractal/fraclet/annotation/template/AcTemplate.java
src/org/objectweb/fractal/fraclet/annotation/template/BcTemplate.java
src/org/objectweb/fractal/fraclet/annotation/template/RcTemplate.java
src/org/objectweb/fractal/fraclet/annotation/template/package.html
src/org/objectweb/fractal/fraclet/annotation/template/util/NonTypedFractalAttributeException.java
src/org/objectweb/fractal/fraclet/annotation/template/util/None.java
src/org/objectweb/fractal/fraclet/annotation/template/util/_R_.java
src/org/objectweb/fractal/fraclet/annotation/template/util/_T_.java
src/org/objectweb/fractal/fraclet/annotation/template/util/package.html
Fraclet v2.0
New set of annotations
{Provides,Requires,Attribute,LifeCycle,Service,ComponentDesc,DisableADL}.
Most of them are those from the previous version which have been renamed.
-------------------------------------------------------------------------------------------------------------+
build.xml
| 6
examples/comanche/src/comanche/BasicLogger.java
| 4
examples/comanche/src/comanche/ErrorRequestHandler.java
| 4
examples/comanche/src/comanche/FileRequestHandler.java
| 4
examples/comanche/src/comanche/Logger.java
| 4
examples/comanche/src/comanche/MultiThreadScheduler.java
| 4
examples/comanche/src/comanche/RequestAnalyzer.java
| 10
examples/comanche/src/comanche/RequestDispatcher.java
| 8
examples/comanche/src/comanche/RequestHandler.java
| 4
examples/comanche/src/comanche/RequestReceiver.java
| 16
examples/comanche/src/comanche/Scheduler.java
| 4
examples/comanche/src/comanche/SequentialScheduler.java
| 4
examples/primitive/src/primitive/Client.java
| 24
examples/primitive/src/primitive/ServerA.java
| 16
examples/primitive/src/primitive/ServerB.java
| 10
examples/primitive/src/primitive/Service.java
| 4
src/org/objectweb/fractal/fraclet/annotation/Attribute.java
| 52
src/org/objectweb/fractal/fraclet/annotation/ComponentDesc.java
| 37
src/org/objectweb/fractal/fraclet/annotation/DisableADL.java
| 15
src/org/objectweb/fractal/fraclet/annotation/FractalAC.java
| 52
src/org/objectweb/fractal/fraclet/annotation/FractalBC.java
| 69
src/org/objectweb/fractal/fraclet/annotation/FractalComponent.java
| 37
src/org/objectweb/fractal/fraclet/annotation/FractalImportedInterface.java
| 57
src/org/objectweb/fractal/fraclet/annotation/FractalItf.java
| 61
src/org/objectweb/fractal/fraclet/annotation/FractalRC.java
| 33
src/org/objectweb/fractal/fraclet/annotation/Interface.java
| 56
src/org/objectweb/fractal/fraclet/annotation/LifeCycle.java
| 13
src/org/objectweb/fractal/fraclet/annotation/LifeCycleType.java
| 11
src/org/objectweb/fractal/fraclet/annotation/Provides.java
| 57
src/org/objectweb/fractal/fraclet/annotation/Requires.java
| 69
src/org/objectweb/fractal/fraclet/annotation/Service.java
| 36
src/org/objectweb/fractal/fraclet/annotation/ant/FracletAnnotation.java
| 28
src/org/objectweb/fractal/fraclet/annotation/generator/ADLGenerator.java
| 200 ++
src/org/objectweb/fractal/fraclet/annotation/generator/template/AttributeTemplate.java
| 154 +
src/org/objectweb/fractal/fraclet/annotation/generator/template/RequiresTemplate.java
| 786 ++++++++++
src/org/objectweb/fractal/fraclet/annotation/generator/template/ServiceTemplate.java
| 91 +
src/org/objectweb/fractal/fraclet/annotation/generator/template/package.html
| 32
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/NonTypedFractalAttributeException.java
| 39
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/None.java
| 5
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/_R_.java
| 31
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/_T_.java
| 32
src/org/objectweb/fractal/fraclet/annotation/generator/template/util/package.html
| 33
src/org/objectweb/fractal/fraclet/annotation/processor/ADLProcessor.java
| 56
src/org/objectweb/fractal/fraclet/annotation/processor/AttributeProcessor.java
| 51
src/org/objectweb/fractal/fraclet/annotation/processor/FractalACProcessor.java
| 51
src/org/objectweb/fractal/fraclet/annotation/processor/FractalAnnotationProcessor.java
| 8
src/org/objectweb/fractal/fraclet/annotation/processor/FractalBCProcessor.java
| 71
src/org/objectweb/fractal/fraclet/annotation/processor/FractalComponentProcessor.java
| 234 --
src/org/objectweb/fractal/fraclet/annotation/processor/FractalItfProcessor.java
| 107 -
src/org/objectweb/fractal/fraclet/annotation/processor/FractalRCProcessor.java
| 58
src/org/objectweb/fractal/fraclet/annotation/processor/InterfaceProcessor.java
| 107 +
src/org/objectweb/fractal/fraclet/annotation/processor/RequiresProcessor.java
| 71
src/org/objectweb/fractal/fraclet/annotation/processor/ServiceProcessor.java
| 58
src/org/objectweb/fractal/fraclet/annotation/processor/util/ADLFileFactory.java
| 2
src/org/objectweb/fractal/fraclet/annotation/template/AcTemplate.java
| 154 -
src/org/objectweb/fractal/fraclet/annotation/template/BcTemplate.java
| 775 ---------
src/org/objectweb/fractal/fraclet/annotation/template/RcTemplate.java
| 91 -
src/org/objectweb/fractal/fraclet/annotation/template/package.html
| 32
src/org/objectweb/fractal/fraclet/annotation/template/util/NonTypedFractalAttributeException.java
| 39
src/org/objectweb/fractal/fraclet/annotation/template/util/None.java
| 5
src/org/objectweb/fractal/fraclet/annotation/template/util/_R_.java
| 31
src/org/objectweb/fractal/fraclet/annotation/template/util/_T_.java
| 32
src/org/objectweb/fractal/fraclet/annotation/template/util/package.html
| 33
63 files changed, 2174 insertions(+), 2104 deletions(-)
Index: fraclet/fraclet-annotation/build.xml
diff -u fraclet/fraclet-annotation/build.xml:1.5
fraclet/fraclet-annotation/build.xml:1.6
--- fraclet/fraclet-annotation/build.xml:1.5 Fri Apr 21 15:34:05 2006
+++ fraclet/fraclet-annotation/build.xml Fri May 26 15:34:17 2006
@@ -24,7 +24,7 @@
<property file="build.properties" />
<property name="src" value="${basedir}/src" />
- <property name="src.templates"
value="${src}/org/objectweb/fractal/fraclet/annotation/template" />
+ <property name="src.templates"
value="${src}/org/objectweb/fractal/fraclet/annotation/generator/template" />
<property name="src.annotations"
value="${src}/org/objectweb/fractal/fraclet/annotation/" />
<property name="doc" value="${basedir}/doc" />
@@ -161,8 +161,8 @@
<package
name="org.objectweb.fractal.fraclet.annotation" />
<package
name="org.objectweb.fractal.fraclet.annotation.ant" />
<package
name="org.objectweb.fractal.fraclet.annotation.processor" />
- <package
name="org.objectweb.fractal.fraclet.annotation.template" />
- <package
name="org.objectweb.fractal.fraclet.annotation.template.util" />
+ <package
name="org.objectweb.fractal.fraclet.annotation.generator.template" />
+ <package
name="org.objectweb.fractal.fraclet.annotation.generator.template.util" />
<link href="${fractal.url}" offline="true"
packagelistLoc="${jdoc}/fractal-list" />
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/BasicLogger.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/BasicLogger.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/BasicLogger.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/BasicLogger.java:1.4
Tue Apr 4 10:21:20 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/BasicLogger.java
Fri May 26 15:34:16 2006
@@ -18,9 +18,9 @@
==============================================================================*/
package comanche;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
-@FractalComponent
+@ComponentDesc
public class BasicLogger implements Logger {
public void log (String msg) { System.out.println(msg); }
}
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/ErrorRequestHandler.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/ErrorRequestHandler.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/ErrorRequestHandler.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/ErrorRequestHandler.java:1.4
Mon Mar 6 17:54:02 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/ErrorRequestHandler.java
Fri May 26 15:34:16 2006
@@ -19,9 +19,9 @@
package comanche;
import java.io.IOException;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
-@FractalComponent
+@ComponentDesc
public class ErrorRequestHandler implements RequestHandler {
public void handleRequest (Request r) throws IOException {
r.out.print("HTTP/1.0 404 Not Found\n\n");
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/FileRequestHandler.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/FileRequestHandler.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/FileRequestHandler.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/FileRequestHandler.java:1.4
Tue Apr 4 10:21:20 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/FileRequestHandler.java
Fri May 26 15:34:16 2006
@@ -22,9 +22,9 @@
import java.io.IOException;
import java.io.InputStream;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
-@FractalComponent
+@ComponentDesc
public class FileRequestHandler implements RequestHandler {
public void handleRequest (Request r) throws IOException {
File f = new File(r.url);
Index: fraclet/fraclet-annotation/examples/comanche/src/comanche/Logger.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/Logger.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/Logger.java:1.5
--- fraclet/fraclet-annotation/examples/comanche/src/comanche/Logger.java:1.4
Mon Mar 6 17:54:02 2006
+++ fraclet/fraclet-annotation/examples/comanche/src/comanche/Logger.java
Fri May 26 15:34:16 2006
@@ -18,9 +18,9 @@
==============================================================================*/
package comanche;
-import org.objectweb.fractal.fraclet.annotation.FractalItf;
+import org.objectweb.fractal.fraclet.annotation.Interface;
-@FractalItf(name="l")
+@Interface(name="l")
public interface Logger {
void log (String msg);
}
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/MultiThreadScheduler.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/MultiThreadScheduler.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/MultiThreadScheduler.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/MultiThreadScheduler.java:1.4
Mon Mar 6 17:54:02 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/MultiThreadScheduler.java
Fri May 26 15:34:16 2006
@@ -18,9 +18,9 @@
==============================================================================*/
package comanche;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
-@FractalComponent
+@ComponentDesc
public class MultiThreadScheduler implements Scheduler {
public void schedule (Runnable task) { new Thread(task).start(); }
}
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestAnalyzer.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestAnalyzer.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestAnalyzer.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestAnalyzer.java:1.4
Mon Mar 6 17:54:02 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestAnalyzer.java
Fri May 26 15:34:16 2006
@@ -23,16 +23,16 @@
import java.io.LineNumberReader;
import java.io.PrintStream;
-import org.objectweb.fractal.fraclet.annotation.FractalBC;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.Requires;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
-@FractalComponent
+@ComponentDesc
public class RequestAnalyzer implements RequestHandler {
- @FractalBC(name="a")
+ @Requires(name="a")
private RequestHandler rh;
- @FractalBC(name="l")
+ @Requires(name="l")
private Logger l;
// // configuration aspect
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestDispatcher.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestDispatcher.java:1.5
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestDispatcher.java:1.6
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestDispatcher.java:1.5
Mon Mar 6 17:54:02 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestDispatcher.java
Fri May 26 15:34:16 2006
@@ -22,13 +22,13 @@
import java.util.Map;
import java.util.TreeMap;
-import org.objectweb.fractal.fraclet.annotation.FractalBC;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.Requires;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
-@FractalComponent
+@ComponentDesc
public class RequestDispatcher implements RequestHandler {
- @FractalBC(name="h",cardinality="collection")
+ @Requires(name="h",cardinality="collection")
private Map<String, RequestHandler> handlers = new TreeMap<String,
RequestHandler>();
// configuration aspect
// public String[] listFc () {
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestHandler.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestHandler.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestHandler.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestHandler.java:1.4
Tue Apr 4 10:21:20 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestHandler.java
Fri May 26 15:34:16 2006
@@ -18,9 +18,9 @@
==============================================================================*/
package comanche;
-import org.objectweb.fractal.fraclet.annotation.FractalItf;
+import org.objectweb.fractal.fraclet.annotation.Interface;
-@FractalItf(name="rh")
+@Interface(name="rh")
public interface RequestHandler {
void handleRequest (Request r) throws java.io.IOException;
}
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestReceiver.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestReceiver.java:1.6
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestReceiver.java:1.7
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestReceiver.java:1.6
Fri Mar 31 13:41:43 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/RequestReceiver.java
Fri May 26 15:34:16 2006
@@ -22,19 +22,19 @@
import java.net.ServerSocket;
import java.net.Socket;
-import org.objectweb.fractal.fraclet.annotation.FractalBC;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
-import org.objectweb.fractal.fraclet.annotation.FractalImportedInterface;
-import org.objectweb.fractal.fraclet.annotation.FractalItf;
+import org.objectweb.fractal.fraclet.annotation.Requires;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
+import org.objectweb.fractal.fraclet.annotation.Provides;
+import org.objectweb.fractal.fraclet.annotation.Interface;
-@FractalComponent
-@FractalImportedInterface(interfaces=@FractalItf(name="r",signature=Runnable.class))
+@ComponentDesc
+@Provides(interfaces=@Interface(name="r",signature=Runnable.class))
public class RequestReceiver implements Runnable {
- @FractalBC(name = "s")
+ @Requires(name = "s")
private Scheduler s;
- @FractalBC(name = "rh")
+ @Requires(name = "rh")
private RequestHandler rh;
// configuration aspect
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/Scheduler.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/Scheduler.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/Scheduler.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/Scheduler.java:1.4
Tue Apr 4 10:21:20 2006
+++ fraclet/fraclet-annotation/examples/comanche/src/comanche/Scheduler.java
Fri May 26 15:34:16 2006
@@ -18,9 +18,9 @@
==============================================================================*/
package comanche;
-import org.objectweb.fractal.fraclet.annotation.FractalItf;
+import org.objectweb.fractal.fraclet.annotation.Interface;
-@FractalItf(name="s")
+@Interface(name="s")
public interface Scheduler {
void schedule (Runnable task);
}
Index:
fraclet/fraclet-annotation/examples/comanche/src/comanche/SequentialScheduler.java
diff -u
fraclet/fraclet-annotation/examples/comanche/src/comanche/SequentialScheduler.java:1.4
fraclet/fraclet-annotation/examples/comanche/src/comanche/SequentialScheduler.java:1.5
---
fraclet/fraclet-annotation/examples/comanche/src/comanche/SequentialScheduler.java:1.4
Mon Mar 6 17:54:02 2006
+++
fraclet/fraclet-annotation/examples/comanche/src/comanche/SequentialScheduler.java
Fri May 26 15:34:16 2006
@@ -18,9 +18,9 @@
==============================================================================*/
package comanche;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
-@FractalComponent
+@ComponentDesc
public class SequentialScheduler implements Scheduler {
public void schedule (Runnable task) { task.run(); }
}
Index: fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java
diff -u
fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java:1.9
fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java:1.10
---
fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java:1.9
Tue Apr 4 10:21:20 2006
+++ fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java
Fri May 26 15:34:17 2006
@@ -26,11 +26,11 @@
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.NameController;
-import org.objectweb.fractal.fraclet.annotation.FractalBC;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
-import org.objectweb.fractal.fraclet.annotation.FractalImportedInterface;
-import org.objectweb.fractal.fraclet.annotation.FractalItf;
-import org.objectweb.fractal.fraclet.annotation.FractalRC;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
+import org.objectweb.fractal.fraclet.annotation.Interface;
+import org.objectweb.fractal.fraclet.annotation.Provides;
+import org.objectweb.fractal.fraclet.annotation.Requires;
+
/**
* A Fractal component client
@@ -38,20 +38,20 @@
* @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
*
*/
-@FractalComponent
-@FractalImportedInterface(interfaces=@FractalItf(name="r",signature=Runnable.class))
+@ComponentDesc
+@Provides(interfaces=@Interface(name="r",signature=Runnable.class))
public class Client implements Runnable {
- @FractalBC(name = "default")
- private Service defaut;
+ @Requires(name = "default")
+ private primitive.Service defaut;
- @FractalRC
+ @org.objectweb.fractal.fraclet.annotation.Service
private Component ref;
/**
* Reference to the service bound."
*/
- @FractalBC(name = "service", cardinality = "collection")
+ @Requires(name = "service", cardinality = "collection")
private Map<String,Service> services = new HashMap<String,Service>();
/*
@@ -71,7 +71,7 @@
for (Iterator i = services.entrySet().iterator();
i.hasNext();) {
Entry service = (Entry) i.next();
System.out.println(componentName+" Calling " +
service.getKey() + "...");
- ((Service) service.getValue()).print();
+ ((primitive.Service) service.getValue()).print();
}
System.out.println("Default service says: ");
this.defaut.print();
Index:
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerA.java
diff -u
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerA.java:1.4
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerA.java:1.5
---
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerA.java:1.4
Tue Apr 4 10:21:20 2006
+++ fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerA.java
Fri May 26 15:34:17 2006
@@ -21,9 +21,9 @@
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.NameController;
-import org.objectweb.fractal.fraclet.annotation.FractalAC;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
-import org.objectweb.fractal.fraclet.annotation.FractalRC;
+import org.objectweb.fractal.fraclet.annotation.Attribute;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
+import org.objectweb.fractal.fraclet.annotation.Service;
/**
@@ -31,16 +31,16 @@
* @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
*
*/
-@FractalComponent
-public class ServerA implements Service {
+@ComponentDesc
+public class ServerA implements primitive.Service {
- @FractalAC(value=">>")
+ @Attribute(value=">>")
private String header ;
- @FractalRC
+ @Service
private Component ref;
- @FractalAC(argument="msg")
+ @Attribute(argument="msg")
private String message ;
/* (non-Javadoc)
Index:
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerB.java
diff -u
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerB.java:1.4
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerB.java:1.5
---
fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerB.java:1.4
Tue Apr 4 10:21:20 2006
+++ fraclet/fraclet-annotation/examples/primitive/src/primitive/ServerB.java
Fri May 26 15:34:17 2006
@@ -18,22 +18,22 @@
==============================================================================*/
package primitive;
-import org.objectweb.fractal.fraclet.annotation.FractalAC;
-import org.objectweb.fractal.fraclet.annotation.FractalComponent;
+import org.objectweb.fractal.fraclet.annotation.Attribute;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
/**
* A Fractal component "ServerB"
* @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
*
*/
-@FractalComponent
+@ComponentDesc
public class ServerB implements Service {
- @FractalAC(value=">>")
+ @Attribute(value=">>")
private String header ;
- @FractalAC(argument="msg")
+ @Attribute(argument="msg")
private String message ;
/* (non-Javadoc)
Index:
fraclet/fraclet-annotation/examples/primitive/src/primitive/Service.java
diff -u
fraclet/fraclet-annotation/examples/primitive/src/primitive/Service.java:1.4
fraclet/fraclet-annotation/examples/primitive/src/primitive/Service.java:1.5
---
fraclet/fraclet-annotation/examples/primitive/src/primitive/Service.java:1.4
Tue Apr 4 10:21:20 2006
+++ fraclet/fraclet-annotation/examples/primitive/src/primitive/Service.java
Fri May 26 15:34:17 2006
@@ -18,7 +18,7 @@
==============================================================================*/
package primitive;
-import org.objectweb.fractal.fraclet.annotation.FractalItf;
+import org.objectweb.fractal.fraclet.annotation.Interface;
/**
* A Fractal interface "s"
@@ -26,7 +26,7 @@
* @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
*
*/
-@FractalItf(name="service")
+@Interface(name="service")
public interface Service {
/**
* Prints the helloworld message.
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Attribute.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Attribute.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Attribute.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,52 @@
+/*==============================================================================
+ Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+ Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+ This library is free software; you can redistribute it and/or modify it
under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or any later
version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+ You should have received a copy of the GNU Lesser General Public License
along
+ with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+
==============================================================================*/
+
+package org.objectweb.fractal.fraclet.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+import spoon.aval.annotation.Severity;
+import spoon.aval.annotation.structure.Inside;
+import spoon.aval.annotation.structure.Prohibits;
+
+/**
+ * An annotation to manage the automatic introduction of the Fractal
attribute
+ * controller
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+@Inside(value=ComponentDesc.class,severity=Severity.WARNING)
+@Prohibits(Requires.class)
+@Target(ElementType.FIELD)
+public @interface Attribute {
+ /**
+ *
+ * @return used to parameterize a Fractal component (see Fractal-ADL
for
+ * more details)
+ */
+ String argument() default "";
+
+ /**
+ *
+ * @return the initial value of the field
+ */
+ String value() default "";
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ComponentDesc.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ComponentDesc.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ComponentDesc.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,37 @@
+/*==============================================================================
+Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+This library is free software; you can redistribute it and/or modify it
under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2.1 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+You should have received a copy of the GNU Lesser General Public License
along
+with this library; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+==============================================================================*/
+
+package org.objectweb.fractal.fraclet.annotation;
+
+import spoon.aval.annotation.structure.AValTarget;
+import spoon.reflect.declaration.CtClass;
+
+/**
+ * An annotation to specify the controller desc of a component
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+@AValTarget(CtClass.class)
+public @interface ComponentDesc {
+ /**
+ *
+ * @return define the type of the component "primitive", "composite",
...
+ */
+ String controllerDesc() default "";
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/DisableADL.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/DisableADL.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/DisableADL.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,15 @@
+package org.objectweb.fractal.fraclet.annotation;
+
+import spoon.aval.annotation.structure.AValTarget;
+import spoon.reflect.declaration.CtClass;
+
+/**
+ * An annotation to prevent the generation of the ADL files associated to
the component.
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+@AValTarget(CtClass.class)
+public @interface DisableADL {
+
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalAC.java
diff -u
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalAC.java:1.3
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalAC.java:removed
---
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalAC.java:1.3
Fri Apr 21 15:34:05 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalAC.java
Fri May 26 15:34:18 2006
@@ -1,52 +0,0 @@
-/*==============================================================================
- Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
- Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
-
- This library is free software; you can redistribute it and/or modify it
under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 2.1 of the License, or any later
version.
-
- This library is distributed in the hope that it will be useful, but WITHOUT
ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
-
- You should have received a copy of the GNU Lesser General Public License
along
- with this library; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
-
==============================================================================*/
-
-package org.objectweb.fractal.fraclet.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-import spoon.aval.annotation.Severity;
-import spoon.aval.annotation.structure.Inside;
-import spoon.aval.annotation.structure.Prohibits;
-
-/**
- * An annotation to manage the automatic introduction of the Fractal
attribute
- * controller
- *
- * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
- *
- */
-@Inside(value=FractalComponent.class,severity=Severity.WARNING)
-@Prohibits(FractalBC.class)
-@Target(ElementType.FIELD)
-public @interface FractalAC {
- /**
- *
- * @return used to parameterize a Fractal component (see Fractal-ADL
for
- * more details)
- */
- String argument() default "";
-
- /**
- *
- * @return the initial value of the field
- */
- String value() default "";
-}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalBC.java
diff -u
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalBC.java:1.4
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalBC.java:removed
---
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalBC.java:1.4
Fri Apr 21 15:34:05 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalBC.java
Fri May 26 15:34:18 2006
@@ -1,69 +0,0 @@
-/*==============================================================================
- Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
- Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
-
- This library is free software; you can redistribute it and/or modify it
under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 2.1 of the License, or any later
version.
-
- This library is distributed in the hope that it will be useful, but WITHOUT
ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
-
- You should have received a copy of the GNU Lesser General Public License
along
- with this library; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
-
==============================================================================*/
-
-package org.objectweb.fractal.fraclet.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-import org.objectweb.fractal.fraclet.annotation.template.util.None;
-
-import spoon.aval.annotation.structure.Inside;
-import spoon.aval.annotation.structure.Prohibits;
-import spoon.aval.annotation.value.Matches;
-
-/**
- * An annotation to inject the binding controller
- *
- * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
- *
- */
-@Inside(FractalComponent.class)
-@Prohibits(FractalAC.class)
-@Target(ElementType.FIELD)
-public @interface FractalBC {
- /**
- *
- * @return the name of the bound Fractal interface
- */
- String name();
-
- /**
- *
- * @return the signature of the interface (optional). Thanks to Java5
type
- * safety this parameter can be automatically computed, even
with
- * collection interfaces (HashMap<String,Service>
- * collectionBinding)
- */
- Class signature() default None.class;
-
- /**
- *
- * @return the cardinality["singleton"/"collection"] of the bound
Fractal
- * interface
- */
- @Matches("(singleton|collection)") String cardinality() default
"singleton";
-
- /**
- *
- * @return the contingency["mandatory"/"optional"] of the Fractal
interface
- */
- @Matches("(mandatory|optional)") String contingency() default
"mandatory";
-
-}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalComponent.java
diff -u
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalComponent.java:1.3
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalComponent.java:removed
---
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalComponent.java:1.3
Fri Apr 21 15:34:05 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalComponent.java
Fri May 26 15:34:18 2006
@@ -1,37 +0,0 @@
-/*==============================================================================
-Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
-Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
-
-This library is free software; you can redistribute it and/or modify it
under
-the terms of the GNU Lesser General Public License as published by the Free
-Software Foundation; either version 2.1 of the License, or any later version.
-
-This library is distributed in the hope that it will be useful, but WITHOUT
ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
-PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
-
-You should have received a copy of the GNU Lesser General Public License
along
-with this library; if not, write to the Free Software Foundation, Inc.,
-59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
-==============================================================================*/
-
-package org.objectweb.fractal.fraclet.annotation;
-
-import spoon.aval.annotation.structure.AValTarget;
-import spoon.reflect.declaration.CtClass;
-
-/**
- * An annotation to generate Fractal-ADL files for the annotated Fractal
component
- * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
- *
- */
-@AValTarget(CtClass.class)
-public @interface FractalComponent {
- /**
- *
- * @return define the type of the component "primitive", "composite",
...
- */
- String controllerDesc() default "";
-}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalImportedInterface.java
diff -u
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalImportedInterface.java:1.2
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalImportedInterface.java:removed
---
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalImportedInterface.java:1.2
Fri Apr 21 15:34:05 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalImportedInterface.java
Fri May 26 15:34:18 2006
@@ -1,57 +0,0 @@
-/*==============================================================================
- Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
- Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
-
- This library is free software; you can redistribute it and/or modify it
under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 2.1 of the License, or any later
version.
-
- This library is distributed in the hope that it will be useful, but WITHOUT
ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
-
- You should have received a copy of the GNU Lesser General Public License
along
- with this library; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
-
==============================================================================*/
-
-package org.objectweb.fractal.fraclet.annotation;
-
-/**
- * An annotation to manage the particular case where a Fractal component uses
- * one or several Java interface imported from a jar. For instance,
- * java.lang.Runnable, which is regularly used in AOKell and Julia to
bootstrap
- * a Fractal application.
- *
- * This annotation encapsulates an array of the @FractalItf annotation.
- *
- * For example if your are annotating a content class which implements 3
interfaces
- * and the java.lang.Runnable interface. And if the interface A is provided
into a
- * jar files, so you cannot annotate this interface, you may annotate your
class as
- * follows:
- *
- * @FractalComponent
- * @FractalImportedInterface(
- * interfaces={
- * @FractalItf("r", signature="java.lang.Runnable"),
- * @FractalItf("a",signature="A")
- * }
- * )
- * public class MyContentClass implements A,B,C,Runnable {
- * (...)
- * }
- *
- * This way the @FractalComponent annotation will look after your interfaces
B, and C which are interfaces that you provide
- * with annotations, and the @FractalImportedInterface will look after your
interfaces A and java.lang.Runnable.
- *
- * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
- *
- */
-public @interface FractalImportedInterface {
- /**
- * The list of annotations @FractalItf to declare
- */
- FractalItf[] interfaces();
-}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalItf.java
diff -u
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalItf.java:1.5
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalItf.java:removed
---
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalItf.java:1.5
Sat Apr 22 14:22:27 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalItf.java
Fri May 26 15:34:18 2006
@@ -1,61 +0,0 @@
-/*==============================================================================
-Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
-Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
-
-This library is free software; you can redistribute it and/or modify it
under
-the terms of the GNU Lesser General Public License as published by the Free
-Software Foundation; either version 2.1 of the License, or any later version.
-
-This library is distributed in the hope that it will be useful, but WITHOUT
ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
-PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
-
-You should have received a copy of the GNU Lesser General Public License
along
-with this library; if not, write to the Free Software Foundation, Inc.,
-59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
-==============================================================================*/
-
-package org.objectweb.fractal.fraclet.annotation;
-
-import org.objectweb.fractal.fraclet.annotation.template.util.None;
-
-import spoon.aval.annotation.structure.AValTarget;
-import spoon.aval.annotation.value.Matches;
-import spoon.aval.annotation.value.Unique;
-import spoon.reflect.declaration.CtInterface;
-
-/**
- * An annotation to generate Fractal-ADL files for Fractal interfaces
- * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
- *
- */
-@AValTarget(CtInterface.class)
-public @interface FractalItf {
- /**
- *
- * @return the name of the Fractal interface
- */
- @Unique String name();
-
- /**
- *
- * @return the java signature of the Fractal interface
- */
- Class signature() default Class.class;
-
- /**
- *
- * @return the cardinality["singleton"/"collection"] of the Fractal
interface
- */
- @Matches("(singleton|collection)") String cardinality() default
"singleton";
- /**
- *
- * @return the contingency["mandatory"/"optional"] of the Fractal
interface
- */
- @Matches("(mandatory|optional)") String contingency() default
"mandatory";
-
-
-
-}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalRC.java
diff -u
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalRC.java:1.1
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalRC.java:removed
---
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalRC.java:1.1
Fri Mar 31 10:44:24 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/FractalRC.java
Fri May 26 15:34:18 2006
@@ -1,33 +0,0 @@
-/*==============================================================================
- Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
- Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
-
- This library is free software; you can redistribute it and/or modify it
under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 2.1 of the License, or any later
version.
-
- This library is distributed in the hope that it will be useful, but WITHOUT
ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
-
- You should have received a copy of the GNU Lesser General Public License
along
- with this library; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
-
==============================================================================*/
-package org.objectweb.fractal.fraclet.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-/**
- * This field annotation provides a way to get the Component reference of a
component
- *
- * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
- *
- */
-@Target(ElementType.FIELD)
-public @interface FractalRC {
-
-}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Interface.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Interface.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Interface.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,56 @@
+/*==============================================================================
+Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+This library is free software; you can redistribute it and/or modify it
under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2.1 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+You should have received a copy of the GNU Lesser General Public License
along
+with this library; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+==============================================================================*/
+
+package org.objectweb.fractal.fraclet.annotation;
+
+import spoon.aval.annotation.structure.AValTarget;
+import spoon.aval.annotation.value.Matches;
+import spoon.aval.annotation.value.Unique;
+import spoon.reflect.declaration.CtInterface;
+
+/**
+ * An annotation to generate Fractal-ADL files for Fractal interfaces
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+@AValTarget(CtInterface.class)
+public @interface Interface {
+ /**
+ *
+ * @return the name of the Fractal interface
+ */
+ @Unique String name();
+
+ /**
+ *
+ * @return the java signature of the Fractal interface
+ */
+ Class signature() default Class.class;
+
+ /**
+ *
+ * @return the cardinality["singleton"/"collection"] of the Fractal
interface
+ */
+ @Matches("(singleton|collection)") String cardinality() default
"singleton";
+ /**
+ *
+ * @return the contingency["mandatory"/"optional"] of the Fractal
interface
+ */
+ @Matches("(mandatory|optional)") String contingency() default
"mandatory";
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/LifeCycle.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/LifeCycle.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/LifeCycle.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,13 @@
+package org.objectweb.fractal.fraclet.annotation;
+
+/**
+ * An annotation on a component method which specifies to run the method
+ * behavior when the component is starting (LifeCycleType.START), or is
stopping
+ * (LifeCycleType.STOP).
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+public @interface LifeCycle {
+ LifeCycleType on() default LifeCycleType.START;
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/LifeCycleType.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/LifeCycleType.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/LifeCycleType.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,11 @@
+package org.objectweb.fractal.fraclet.annotation;
+
+/**
+ * Enum type used by the LifeCycle annotation.
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+public enum LifeCycleType {
+ START, STOP
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Provides.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Provides.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Provides.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,57 @@
+/*==============================================================================
+ Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+ Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+ This library is free software; you can redistribute it and/or modify it
under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or any later
version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+ You should have received a copy of the GNU Lesser General Public License
along
+ with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+
==============================================================================*/
+
+package org.objectweb.fractal.fraclet.annotation;
+
+/**
+ * An annotation to manage the particular case where a Fractal component uses
+ * one or several Java interface imported from a jar. For instance,
+ * java.lang.Runnable, which is regularly used in AOKell and Julia to
bootstrap
+ * a Fractal application.
+ *
+ * This annotation encapsulates an array of the @Interface annotation.
+ *
+ * For example if your are annotating a content class which implements 3
interfaces
+ * and the java.lang.Runnable interface. And if the interface A is provided
into a
+ * jar files, so you cannot annotate this interface, you may annotate your
class as
+ * follows:
+ *
+ * @ComponentDesc
+ * @Provides(
+ * interfaces={
+ * @Interface("r", signature="java.lang.Runnable"),
+ * @Interface("a",signature="A")
+ * }
+ * )
+ * public class MyContentClass implements A,B,C,Runnable {
+ * (...)
+ * }
+ *
+ * This way the @ComponentDesc annotation will look after your interfaces B,
and C which are interfaces that you provide
+ * with annotations, and the @Provides will look after your interfaces A and
java.lang.Runnable.
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+public @interface Provides {
+ /**
+ * The list of annotations @Interface to declare
+ */
+ Interface[] interfaces();
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Requires.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Requires.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Requires.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,69 @@
+/*==============================================================================
+ Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+ Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+ This library is free software; you can redistribute it and/or modify it
under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or any later
version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+ You should have received a copy of the GNU Lesser General Public License
along
+ with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+
==============================================================================*/
+
+package org.objectweb.fractal.fraclet.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+import org.objectweb.fractal.fraclet.annotation.generator.template.util.None;
+
+import spoon.aval.annotation.structure.Prohibits;
+import spoon.aval.annotation.value.Matches;
+
+/**
+ * An annotation to inject the binding controller implementation.
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+@Prohibits(Attribute.class)
+@Target(ElementType.FIELD)
+public @interface Requires {
+ /**
+ *
+ * @return the name of the bound Fractal interface
+ */
+ String name();
+
+ /**
+ *
+ * @return the signature of the interface (optional). Thanks to Java5
type
+ * safety this parameter can be automatically computed, even
with
+ * collection interfaces (HashMap<String,Service>
+ * collectionBinding)
+ */
+ Class signature() default None.class;
+
+ /**
+ *
+ * @return the cardinality["singleton"/"collection"] of the bound
Fractal
+ * interface
+ */
+ @Matches("(singleton|collection)")
+ String cardinality() default "singleton";
+
+ /**
+ *
+ * @return the contingency["mandatory"/"optional"] of the Fractal
interface
+ */
+ @Matches("(mandatory|optional)")
+ String contingency() default "mandatory";
+
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Service.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Service.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/Service.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,36 @@
+/*==============================================================================
+ Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+ Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+ This library is free software; you can redistribute it and/or modify it
under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or any later
version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+ You should have received a copy of the GNU Lesser General Public License
along
+ with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+
==============================================================================*/
+package org.objectweb.fractal.fraclet.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * Specify that a service provided by the component runtime environment
(e.g.,
+ * logging) is injected. Only the "component-controller" reference is
+ * implemented so far (default parameter of the annotation).
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+@Target(ElementType.FIELD)
+public @interface Service {
+ // TODO implement other services
+ String name() default "component-controller";
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ant/FracletAnnotation.java
diff -u
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ant/FracletAnnotation.java:1.5
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ant/FracletAnnotation.java:1.6
---
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ant/FracletAnnotation.java:1.5
Fri Apr 21 15:34:06 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/ant/FracletAnnotation.java
Fri May 26 15:34:17 2006
@@ -19,21 +19,21 @@
package org.objectweb.fractal.fraclet.annotation.ant;
import org.apache.tools.ant.BuildException;
-import org.objectweb.fractal.fraclet.annotation.processor.FractalACProcessor;
-import org.objectweb.fractal.fraclet.annotation.processor.FractalBCProcessor;
-import
org.objectweb.fractal.fraclet.annotation.processor.FractalComponentProcessor;
-import
org.objectweb.fractal.fraclet.annotation.processor.FractalItfProcessor;
-import org.objectweb.fractal.fraclet.annotation.processor.FractalRCProcessor;
+import org.objectweb.fractal.fraclet.annotation.processor.AttributeProcessor;
+import org.objectweb.fractal.fraclet.annotation.processor.RequiresProcessor;
+import org.objectweb.fractal.fraclet.annotation.processor.ADLProcessor;
+import org.objectweb.fractal.fraclet.annotation.processor.InterfaceProcessor;
+import org.objectweb.fractal.fraclet.annotation.processor.ServiceProcessor;
import spoon.SpoonTask;
import spoon.aval.processing.AValProcessor;
/**
* Defines the ANT Fraclet-annotation task (processors are
- * {@link
org.objectweb.fractal.fraclet.annotation.processor.FractalACProcessor},
- * {@link
org.objectweb.fractal.fraclet.annotation.processor.FractalBCProcessor},
- * {@link
org.objectweb.fractal.fraclet.annotation.processor.FractalComponentProcessor},
- * and {@link
org.objectweb.fractal.fraclet.annotation.processor.FractalItfProcessor})
+ * {@link
org.objectweb.fractal.fraclet.annotation.processor.AttributeProcessor},
+ * {@link
org.objectweb.fractal.fraclet.annotation.processor.RequiresProcessor},
+ * {@link org.objectweb.fractal.fraclet.annotation.processor.ADLProcessor},
+ * and {@link
org.objectweb.fractal.fraclet.annotation.processor.InterfaceProcessor})
*/
public class FracletAnnotation extends SpoonTask {
@@ -47,15 +47,15 @@
public void execute() throws BuildException {
addProcessor(new ProcessorType(AValProcessor.class
.getCanonicalName()));
- addProcessor(new ProcessorType(FractalComponentProcessor.class
+ addProcessor(new ProcessorType(ADLProcessor.class
.getCanonicalName()));
- addProcessor(new ProcessorType(FractalACProcessor.class
+ addProcessor(new ProcessorType(AttributeProcessor.class
.getCanonicalName()));
- addProcessor(new ProcessorType(FractalBCProcessor.class
+ addProcessor(new ProcessorType(RequiresProcessor.class
.getCanonicalName()));
- addProcessor(new ProcessorType(FractalRCProcessor.class
+ addProcessor(new ProcessorType(ServiceProcessor.class
.getCanonicalName()));
- addProcessor(new ProcessorType(FractalItfProcessor.class
+ addProcessor(new ProcessorType(InterfaceProcessor.class
.getCanonicalName()));
super.execute();
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/ADLGenerator.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/ADLGenerator.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/ADLGenerator.java
Fri May 26 15:34:17 2006
@@ -0,0 +1,200 @@
+package org.objectweb.fractal.fraclet.annotation.generator;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.fractal.fraclet.annotation.Attribute;
+import org.objectweb.fractal.fraclet.annotation.ComponentDesc;
+import org.objectweb.fractal.fraclet.annotation.Interface;
+import org.objectweb.fractal.fraclet.annotation.Provides;
+import org.objectweb.fractal.fraclet.annotation.Requires;
+import
org.objectweb.fractal.fraclet.annotation.generator.template.AttributeTemplate;
+import org.objectweb.fractal.fraclet.annotation.generator.template.util.None;
+import
org.objectweb.fractal.fraclet.annotation.processor.util.ADLFileFactory;
+
+import spoon.reflect.declaration.CtClass;
+import spoon.reflect.declaration.CtField;
+import spoon.reflect.reference.CtTypeReference;
+
+public class ADLGenerator {
+
+ private PrintWriter pw = null;
+
+ private CtClass<?> processedClass;
+
+ public ADLGenerator(CtClass<?> processedClass, ComponentDesc
fcAnnotation) {
+ this.processedClass = processedClass;
+ // -----------------------------------------------------
+ // create .fractal file
+ // -----------------------------------------------------
+ File outFile =
ADLFileFactory.createADLFile(processedClass.getFactory()
+ .getEnvironment().getDefaultFileGenerator()
+ .getOutputDirectory(), processedClass);
+ try {
+ pw = new PrintWriter(outFile);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ // -----------------------------------------------------
+ // PrintSignature
+ // -----------------------------------------------------
+
+ ADLFileFactory.printLicence(pw);
+ // -----------------------------------------------------
+ // Manage Fractal attributes arguments
+ // -----------------------------------------------------
+ String arguments = "";
+ List<CtField<?>> fields = processedClass.getFields();
+ Map<String, String> attributes = new HashMap<String,
String>();
+ // List<CtField<?>> fields = processedClass.getFields();
+ // iterate over processedClass fields
+ for (CtField<?> field : fields) {
+ // get the Requires annotation
+ Attribute acAnnotation =
field.getAnnotation(Attribute.class);
+ // if the field is not annotated continue
+ if (acAnnotation == null)
+ continue;
+ if (acAnnotation.value() == null)
+ attributes.put(field.getSimpleName(), "");
+ else
+ attributes.put(field.getSimpleName(),
acAnnotation.value());
+ if (acAnnotation.argument() != null
+ && acAnnotation.argument().length() >
0) {
+ arguments += acAnnotation.argument() + ",";
+ String argValue = "${" +
acAnnotation.argument() + "}";
+ attributes.put(field.getSimpleName(),
argValue);
+ }
+ }
+ if (arguments != "")
+ arguments = arguments.substring(0,
(arguments.length() - 1));
+
+ // -----------------------------------------------------
+ // Get Fractal server interfaces
+ // -----------------------------------------------------
+
+ List<CtTypeReference> itfs = new ArrayList<CtTypeReference>();
+ for (CtTypeReference itf :
processedClass.getSuperinterfaces()) {
+ Interface itfAnnotation =
itf.getAnnotation(Interface.class);
+ if (itfAnnotation != null) {
+ itfs.add(itf);
+ }
+ }
+
+ printBeginDefinition(itfs, arguments);
+
+ // -----------------------------------------------------
+ // Get Fractal client interfaces
+ // -----------------------------------------------------
+
+ // iterate over processedClass fields
+ for (CtField<?> field : fields) {
+ // get the Requires annotation
+ Requires bindingAnnotation =
field.getAnnotation(Requires.class);
+ // if the field is not annotated continue
+ if (bindingAnnotation == null)
+ continue;
+ // TODO remove this when Spoon bug will be fixed
+ Class c = bindingAnnotation.signature();
+ if (c.equals(Class.class))
+ c = None.class;
+ ADLFileFactory
+ .printItfSignature(pw, field,
bindingAnnotation.name(), c,
+
bindingAnnotation.cardinality(), bindingAnnotation
+
.contingency(), ADLFileFactory.ROLE_CLIENT);
+ }
+ // -----------------------------------------------------
+ // Manage the local @Interface server itf annotations
+ // -----------------------------------------------------
+
+ Provides importedItfAnnotation = processedClass
+ .getAnnotation(Provides.class);
+ if (importedItfAnnotation != null) {
+ Interface[] itfAnnotations =
importedItfAnnotation.interfaces();
+ for (Interface itfAnnotation : itfAnnotations) {
+ ADLFileFactory.printItfSignature(pw,
itfAnnotation.signature()
+ .getCanonicalName(),
itfAnnotation.name(),
+ itfAnnotation.cardinality(),
itfAnnotation
+
.contingency(), ADLFileFactory.ROLE_SERVER);
+ }
+ }
+
+ // -----------------------------------------------------
+ // Manage attribute
+ // -----------------------------------------------------
+ String attributeControllerSignature =
processedClass.getQualifiedName()
+ + AttributeTemplate.ATTRIBUTESUFFIX;
+
+ printContentClass();
+ printAttributes(attributeControllerSignature, attributes);
+
+ // -----------------------------------------------------
+ // Print Controller Desc
+ // -----------------------------------------------------
+
+ if (!fcAnnotation.controllerDesc().equals(""))
+ pw.println(" <controller desc=\""
+ +
fcAnnotation.controllerDesc() + "\"/>");
+
+ // -----------------------------------------------------
+ // closing file
+ // -----------------------------------------------------
+
+ printEndDefinition();
+ pw.close();
+ }
+
+ private void printContentClass() {
+ pw.println(" <content class=\"" +
processedClass.getQualifiedName()
+ + "\"/>");
+ }
+
+ private void printAttributes(String attributeControllerSignature,
+ Map<String, String> attributes) {
+
+ // <attributes
signature="primitive.ServerAAttributeController">
+ // <attribute value=">> " name="header"/>
+ // <attribute value="${msg}" name="message"/>
+ // </attributes>
+ if (attributes.size() > 0) {
+ pw.println(" <attributes signature=\""
+ + attributeControllerSignature +
"\">");
+ for (String attributeName : attributes.keySet()) {
+ pw.println(" <attribute name=\"" +
attributeName + "\""
+ + " value=\"" + "" +
attributes.get(attributeName)
+ + "\"/>");
+ }
+ pw.println(" </attributes>");
+ }
+ }
+
+ private void printBeginDefinition(List<CtTypeReference> itfs,
+ String arguments) {
+ /* @Todo manage the arguments= option */
+ if (arguments != "")
+ arguments = "arguments=\"" + arguments + "\"";
+ if (itfs.size() > 0) {
+ String extendedADLFiles = "";
+ for (CtTypeReference itf : itfs) {
+ extendedADLFiles += itf + ",";
+
+ }
+ extendedADLFiles = extendedADLFiles.substring(0,
(extendedADLFiles
+ .length() - 1));
+ pw.println("<definition name=\""
+ + processedClass.getQualifiedName() +
"\" extends=\""
+ + extendedADLFiles + "\"" + " " +
arguments + ">");
+ } else
+ pw.println("<definition name=\""
+ + processedClass.getQualifiedName() +
"\"" + " "
+ + arguments + ">");
+ }
+
+ private void printEndDefinition() {
+ pw.println("</definition>");
+ }
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/AttributeTemplate.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/AttributeTemplate.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/AttributeTemplate.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,154 @@
+/*==============================================================================
+ Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+ Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+ This library is free software; you can redistribute it and/or modify it
under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or any later
version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+ You should have received a copy of the GNU Lesser General Public License
along
+ with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+ Contributor(s): Renaud Pawlak (renaud.pawlak@xxxxxxx)
+
==============================================================================*/
+
+package org.objectweb.fractal.fraclet.annotation.generator.template;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.objectweb.fractal.api.control.AttributeController;
+import org.objectweb.fractal.fraclet.annotation.generator.template.util._T_;
+
+import spoon.reflect.Factory;
+import spoon.reflect.declaration.CtClass;
+import spoon.reflect.declaration.CtField;
+import spoon.reflect.declaration.CtInterface;
+import spoon.reflect.declaration.ModifierKind;
+import spoon.reflect.reference.CtTypeReference;
+import spoon.template.Local;
+import spoon.template.Parameter;
+import spoon.template.Substitution;
+import spoon.template.Template;
+
+/**
+ * A template to manage the Attribute annotation. This template generate the
+ * right interface for the Fractal component and use a subclass to introduce
+ * getter/setter
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+public class AttributeTemplate implements Template {
+
+ @Local
+ public static String ATTRIBUTESUFFIX = "AttributeController";
+
+ /**
+ * Constructor for AttributeTemplate This constructor is called from
the Requires
+ * Processor
+ *
+ * @param spoonFactory
+ * the spoon factory
+ * @param field
+ * the target field
+ */
+ @Local
+ public AttributeTemplate(Factory spoonFactory, CtField<?> field) {
+
+ CtClass<?> target = field.getParent(CtClass.class);
+ // the name of the interface to generate
+ String attributeName = target.getQualifiedName() +
ATTRIBUTESUFFIX;
+ String attributeSimpleName = target.getSimpleName() +
ATTRIBUTESUFFIX;
+ // creation of the interface
+ CtInterface<?> itfTarget =
spoonFactory.Interface().get(attributeName);
+ if (itfTarget == null) {
+ itfTarget =
spoonFactory.Interface().create(target.getPackage(),
+ attributeSimpleName);
+ Set<ModifierKind> modifiers = new
HashSet<ModifierKind>();
+ modifiers.add(ModifierKind.PUBLIC);
+ itfTarget.setModifiers(modifiers);
+ itfTarget.getSuperinterfaces().add(
+ spoonFactory.Type()
+
.createReference(AttributeController.class));
+
target.getSuperinterfaces().add(itfTarget.getReference());
+ }
+
+ // create a GetterSetterTemplate to introduce the right get
and set
+ // methods
+ Template t = new GetterSetterTemplate(field.getSimpleName(),
field
+ .getType());
+ // insert all the methods to the class
+ Substitution.insertAll(target, t);
+ // insert all the methods to the interface
+ Substitution.insertAll(itfTarget, t);
+ // }
+ }
+}
+
+/**
+ * A template to insert getter/setter to a given field
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+class GetterSetterTemplate implements Template {
+
+ /**
+ * The constructor for the GetterSetterTemplate
+ *
+ * @param fieldName
+ * the name of the field to instrument
+ * @param typeRef
+ * a CtTypeReference of the type of the field
(field.getType())
+ */
+ @Local
+ public GetterSetterTemplate(String fieldName, CtTypeReference
typeRef) {
+ this.__fractalField_ = fieldName;
+ char[] chars = fieldName.toCharArray();
+ chars[0] = Character.toUpperCase(chars[0]);
+ this.__FractalField_ = new String(chars);
+ this._T_ = typeRef;
+ }
+
+ // the TypeReference of the field type
+ @Parameter
+ CtTypeReference _T_;
+
+ // a local variable to reprensent the field itself
+ @Local
+ _T_ _fractalField_;
+
+ // the simple name of the field
+ @Parameter("_fractalField_")
+ String __fractalField_;
+
+ @Parameter
+ String __FractalField_;
+
+ /**
+ * This method has been automatically injected by Spoon
+ *
+ * @return the reference of the field
+ */
+ public _T_ get__FractalField_() {
+ return _fractalField_;
+ }
+
+ /**
+ * This method has been automatically injected by Spoon
+ *
+ * @param value
+ * the value to set to the field
+ */
+ public void set__FractalField_(_T_ value) {
+ _fractalField_ = value;
+ }
+
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/RequiresTemplate.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/RequiresTemplate.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/RequiresTemplate.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,786 @@
+/*==============================================================================
+Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+This library is free software; you can redistribute it and/or modify it
under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2.1 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful, but WITHOUT
ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A
+PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
+
+You should have received a copy of the GNU Lesser General Public License
along
+with this library; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Initial developer(s): Nicolas Pessemier (nicolas.pessemier@xxxxxxx)
+Contributor(s): Renaud Pawlak (renaud.pawlak@xxxxxxx)
+==============================================================================*/
+
+package org.objectweb.fractal.fraclet.annotation.generator.template;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.control.BindingController;
+import org.objectweb.fractal.api.control.IllegalBindingException;
+import org.objectweb.fractal.fraclet.annotation.LifeCycle;
+import org.objectweb.fractal.fraclet.annotation.Requires;
+import org.objectweb.fractal.fraclet.annotation.Service;
+import
org.objectweb.fractal.fraclet.annotation.generator.template.util.NonTypedFractalAttributeException;
+import org.objectweb.fractal.fraclet.annotation.generator.template.util._R_;
+import org.objectweb.fractal.fraclet.annotation.generator.template.util._T_;
+
+import spoon.reflect.Factory;
+import spoon.reflect.code.CtBlock;
+import spoon.reflect.code.CtStatementList;
+import spoon.reflect.declaration.CtClass;
+import spoon.reflect.declaration.CtField;
+import spoon.reflect.reference.CtTypeReference;
+import spoon.template.Local;
+import spoon.template.Parameter;
+import spoon.template.Substitution;
+import spoon.template.Template;
+import spoon.template.TemplateParameterList;
+
+/**
+ * A template to insert the binding controller methods
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+public class RequiresTemplate implements Template, BindingController {
+
+ @Parameter
+ TemplateParameterList _listFcAdds_;
+
+ @Parameter
+ TemplateParameterList _unbinds_;
+
+ @Parameter
+ TemplateParameterList _lookups_;
+
+ @Parameter
+ TemplateParameterList _binds_;
+
+ /**
+ * Constructor for AttributeTemplate This constructor is called from
the
+ * Requires Processor
+ *
+ * @param spoonFactory
+ * the factory
+ * @param target
+ * the target class
+ */
+ @Local
+ public RequiresTemplate(Factory spoonFactory, CtClass<?> target)
throws NonTypedFractalAttributeException{
+ // 4 sub templates are used, one for each method to insert
+ CtStatementList<?> listFcAdds =
spoonFactory.Core().createStatementList();
+ CtStatementList<?> unbinds =
spoonFactory.Core().createStatementList();
+ CtStatementList<?> binds =
spoonFactory.Core().createStatementList();
+ CtStatementList<?> lookups =
spoonFactory.Core().createStatementList();
+ List<CtField<?>> fields = target.getFields();
+ // iterate over target fields
+ for (CtField<?> field : fields) {
+
+ //
////////////////////////////////////////////////////
+ // /////// Manage the @Service annotation //////////
+ // ///////////////////////////////////////////////////
+
+ Service
serviceAnnotation=field.getAnnotation(Service.class);
+ if (serviceAnnotation!=null){
+ Template rcT= new BindRcTemplate(field
+ .getSimpleName());
+ CtBlock<?> rcBlock =
Substitution.substituteMethodBody(target, rcT, "bind",new
CtTypeReference<?>[]{
+
spoonFactory.Type().createReference(String.class),spoonFactory.Type().createReference(Object.class)});
+
binds.getStatements().add(rcBlock.getStatements().get(0));
+ }
+
+ // TODO manage the @LifeCycle annotation
+ //
////////////////////////////////////////////////////
+ // /////// Manage the @LifeCycle annotation //////////
+ // ///////////////////////////////////////////////////
+
+ LifeCycle
lifecycleAnnotation=field.getAnnotation(LifeCycle.class);
+ if (lifecycleAnnotation!=null){
+ // TODO add a call to the method in the start
or stop method of
+ // the lifecycle
+ }
+ // //////////////////////////////////////////////////
+ // //////////////////////////////////////////////////
+
+ // get the Requires annotation
+ Requires bindingAnnotation =
field.getAnnotation(Requires.class);
+ // if the field is not annotated continue
+ if (bindingAnnotation == null)
+ continue;
+ CtBlock<?> block =null;
+ Template t=null;
+ // add the BindingController interface
+
target.getSuperinterfaces().add(spoonFactory.Type().createReference(BindingController.class));
+ // //////////////////////////////////////////////////
+ // If the cardinality is singleton
+ // //////////////////////////////////////////////////
+ if (bindingAnnotation.cardinality()==null ||
bindingAnnotation.cardinality().equals("singleton") ){
+ //
//////////////////////////////////////////////////
+ // the listFcTemplate
+ //
//////////////////////////////////////////////////
+ t = new
ListFcTemplate(bindingAnnotation.name(),false);
+ block =
Substitution.substituteMethodBody(target, t,
+ "addSingleton",
spoonFactory.Type().createReference(List.class));
+ // insert all the
"interfaces.add("myService")"
+
listFcAdds.getStatements().add(block.getStatements().get(0));
+ //
//////////////////////////////////////////////////
+ // the UnbindFcTemplate
+ //
//////////////////////////////////////////////////
+ t = new
UnbindFcTemplate(bindingAnnotation.name(), field.getType(), field
+ .getSimpleName());
+ block =
Substitution.substituteMethodBody(target, t, "unbindSingleton",
+
spoonFactory.Type().createReference(String.class));
+
unbinds.getStatements().add(block.getStatements().get(0));
+ //
//////////////////////////////////////////////////
+ // the BindFcTemplate
+ //
//////////////////////////////////////////////////
+ t= new
BindFcTemplate(bindingAnnotation.name(), field.getType(), field
+ .getSimpleName());
+ block =
Substitution.substituteMethodBody(target, t, "bindSingleton",new
CtTypeReference<?>[]{
+
spoonFactory.Type().createReference(String.class),spoonFactory.Type().createReference(Object.class)});
+
binds.getStatements().add(block.getStatements().get(0));
+ //
//////////////////////////////////////////////////
+ // the LookupFcTemplate
+ //
//////////////////////////////////////////////////
+ t= new
LookupFcTemplate(bindingAnnotation.name(), field.getType(), field
+ .getSimpleName());
+ block =
Substitution.substituteMethodBody(target, t,
"lookupSingleton",spoonFactory.Type().createReference(String.class));
+
lookups.getStatements().add(block.getStatements().get(0));
+ }
+ // //////////////////////////////////////////////////
+ // If the cardinality is collection
+ // //////////////////////////////////////////////////
+ else if
(bindingAnnotation.cardinality().equals("collection")){
+
+ t = new
ListFcTemplate(field.getSimpleName(),true);
+ block =
Substitution.substituteMethodBody(target, t,
+ "addCollection",
spoonFactory.Type().createReference(List.class));
+ // insert all the
"interfaces.add("myService")"
+
listFcAdds.getStatements().add(block.getStatements().get(0));
+ //
//////////////////////////////////////////////////
+ // the UnbindFcTemplate
+ //
//////////////////////////////////////////////////
+ t = new
UnbindFcTemplate(field.getSimpleName());
+ block =
Substitution.substituteMethodBody(target, t, "unbindCollection",
+
spoonFactory.Type().createReference(String.class));
+
unbinds.getStatements().add(block.getStatements().get(0));
+ //
//////////////////////////////////////////////////
+ // the BindFcTemplate
+ //
//////////////////////////////////////////////////
+ // TODO remove this when Spoon bug will be
fixed
+ if
(bindingAnnotation.signature().equals(Class.class) &&
+
field.getType().getActualTypeArguments().size()<2)
+ throw new
NonTypedFractalAttributeException("Fractal attribute "+field.getSimpleName()+
+ " must be typed to generate the
appropriate binding controller implementation");
+ // TODO remove this when Spoon bug will be
fixed
+ else
if(!bindingAnnotation.signature().equals(Class.class) ){
+ t= new
NotTypedBindFcTemplate(bindingAnnotation.name(),field.getSimpleName(),spoonFactory.Type().createReference(bindingAnnotation.signature()));
+ }
+ else {
+ t= new
BindFcTemplate(bindingAnnotation.name(),field.getSimpleName(),field.getType().getActualTypeArguments().get(1));
+ }
+ block =
Substitution.substituteMethodBody(target, t, "bindCollection",new
CtTypeReference<?>[]{
+
spoonFactory.Type().createReference(String.class),spoonFactory.Type().createReference(Object.class)});
+
binds.getStatements().add(block.getStatements().get(0));
+ //
//////////////////////////////////////////////////
+ // the LookupFcTemplate
+ //
//////////////////////////////////////////////////
+ t= new LookupFcTemplate(field
+ .getSimpleName());
+ block =
Substitution.substituteMethodBody(target, t,
"lookupCollection",spoonFactory.Type().createReference(String.class));
+
lookups.getStatements().add(block.getStatements().get(0));
+ }
+
field.getAnnotations().remove(field.getAnnotation(spoonFactory.Type().createReference(Requires.class)));
+ }
+
+ // set the references to the list statements
+ _listFcAdds_ = listFcAdds;
+ _unbinds_ = unbinds;
+ _binds_ = binds;
+ _lookups_ = lookups;
+ }
+
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see
org.objectweb.fractal.api.control.BindingController#bindFc(java.lang.String,
+ * java.lang.Object) Method automatically generated with Spoon
+ * <http://spoon.gforge.inria.fr>
+ */
+ public void bindFc(String clientItfName, Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException {
+ _binds_.S();
+ throw new NoSuchInterfaceException("Client interface
\'"+clientItfName+"\' is undefined.");
+ }
+
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.objectweb.fractal.api.control.BindingController#listFc()
Method
+ * automatically generated with Spoon
<http://spoon.gforge.inria.fr>
+ */
+ public String[] listFc() {
+ List<String> __interfaces__ = new ArrayList<String>();
+ _listFcAdds_.S();
+ return __interfaces__.toArray(new String[] {});
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see
org.objectweb.fractal.api.control.BindingController#lookupFc(java.lang.String)
+ * Method automatically generated with Spoon
+ * <http://spoon.gforge.inria.fr>
+ */
+ public Object lookupFc(String clientItfName)
+ throws NoSuchInterfaceException {
+ _lookups_.S();
+ throw new NoSuchInterfaceException("Client interface
\'"+clientItfName+"\' is undefined.");
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see
org.objectweb.fractal.api.control.BindingController#unbindFc(java.lang.String)
+ * Method automatically generated with Spoon
+ * <http://spoon.gforge.inria.fr>
+ */
+ public void unbindFc(String clientItfName) throws
NoSuchInterfaceException {
+ _unbinds_.S();
+ throw new NoSuchInterfaceException("Client interface
\'"+clientItfName+"\' is undefined.");
+ }
+}
+
+/**
+ * A template to manage the listFc method
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+class ListFcTemplate implements Template {
+
+ @Parameter
+ // The name of the interface (singleton bindings)
+ String _itfName_;
+
+ @Parameter("_name_")
+ // The name of the java field (collection bindings)
+ String __name_;
+
+ @Local
+ // The field that contains the collection bindings (collection
bindings)
+ Map<String,?> _name_;
+
+ /**
+ *
+ * @param name
+ * the name of the interface in the case of a singleton
binding
+ * or the name of the field in the case of a collection
binding
+ * @param collection
+ * true if the binding is a collection binding
+ */
+ public ListFcTemplate(String name, boolean collection) {
+ if (collection){
+ this.__name_ = name;
+ }else {
+ this._itfName_ = name;
+ }
+ }
+
+ void addSingleton(List<String> __interfaces__) {
+ __interfaces__.add(_itfName_);
+ }
+
+ void addCollection(List<String> __interfaces__){
+ __interfaces__.addAll(_name_.keySet());
+ }
+
+}
+
+/**
+ * A template to manage the unbindFc method
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+class UnbindFcTemplate implements Template {
+
+// /////////////////////////
+ // Parameters for singleton bindings
+ // /////////////////////////
+ @Parameter
+ // The name of the interface (singleton bindings)
+ String _itfName_;
+
+ @Parameter
+ // A Type Reference which is the type of the singleton service
+ CtTypeReference _T_;
+
+ @Local
+ // A Local variable which is the reference to the singeton field
+ _T_ _service_;
+
+ @Parameter("_service_")
+ // The name of the singleton field
+ String __service_;
+
+
+ // /////////////////////////
+ // Parameters for collection bindings
+ // /////////////////////////
+ @Parameter("_servicesMap_")
+ // The name of the java field (collection bindings)
+ String __servicesMap_;
+
+ @Local
+ // The field that contains the collection bindings (collection
bindings)
+ Map<String,?> _servicesMap_;
+
+ /**
+ * Constructor for singleton binding
+ *
+ * @param itfName
+ * @param serviceType
+ * @param serviceName
+ */
+ public UnbindFcTemplate(String itfName, CtTypeReference serviceType,
+ String serviceName) {
+ this._itfName_ = itfName;
+ this._T_ = serviceType;
+ this.__service_ = serviceName;
+
+ }
+
+ /**
+ * Use this constructor for collection bindings
+ *
+ * @param name
+ */
+ public UnbindFcTemplate(String name) {
+ this.__servicesMap_=name;
+ }
+
+ /**
+ * Use this constructor for singleton binding
+ *
+ * @param clientItfName
+ * the Fractal interface name to unbind
+ */
+ void unbindSingleton(String clientItfName) throws
NoSuchInterfaceException{
+ if (clientItfName.equals(_itfName_)) {
+ _service_ = null;
+ return;
+ }
+
+ }
+ /**
+ * Unbind for collection binding
+ *
+ * @param clientItfName
+ * the Fractal interface name to unbind
+ */
+ void unbindCollection(String clientItfName) throws
NoSuchInterfaceException{
+ if (_servicesMap_.containsKey(clientItfName)) {
+ _servicesMap_.remove(clientItfName);
+ return;
+ }
+
+ }
+
+}
+
+/**
+ * A template to manage the bindFc method
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+class BindFcTemplate implements Template {
+
+ // ///////////////////////
+ // Parameters for singleton bindings
+ // /////////////////////////
+ @Parameter
+ // The name of the interface (singleton bindings)
+ String _itfName_;
+
+ @Parameter
+ // A Type Reference which is the type of the singleton service
+ CtTypeReference _T_;
+
+ @Parameter
+ CtTypeReference _R_;
+
+
+ @Local
+ // A Local variable which is the reference to the singeton field
+ _T_ _service_;
+
+
+ @Parameter("_service_")
+ // The name of the singleton field
+ String __service_;
+
+
+ // /////////////////////////
+ // Parameters for collection bindings
+ // /////////////////////////
+ @Parameter("_servicesMap_")
+ // The name of the java field (collection bindings)
+ String __servicesMap_;
+
+ @Local
+ // The field that contains the collection bindings (collection
bindings)
+ Map<String,_R_> _servicesMap_;
+
+
+ /**
+ * Use this constructor for singeton bindings
+ *
+ * @param itfName
+ * The name of the Fractal interface
+ * @param serviceType
+ * The java type of the binding
+ * @param serviceName
+ * The name of the java field
+ */
+ public BindFcTemplate(String itfName, CtTypeReference serviceType,
+ String serviceName) {
+ this._itfName_ = itfName;
+ this._T_ = serviceType;
+ this.__service_ = serviceName;
+
+ }
+
+ /**
+ * Use this constructor for collection bindings`
+ *
+ * @param fieldName
+ * the name of the map field
+ */
+ public BindFcTemplate(String itfName, String fieldName
,CtTypeReference serviceType) {
+ this._itfName_ = itfName;
+ this.__servicesMap_ = fieldName;
+ this._R_=serviceType;
+ }
+
+ /**
+ * Block to add into the bindFc method (for singleton bindings)
+ *
+ * @param clientItfName
+ * the Fractal binding name
+ * @param serverItf
+ * the reference to the server
+ * @throws IllegalBindingException
+ * when attempting to bind incompatible interfaces
+ */
+ void bindSingleton(String clientItfName, Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException {
+ if (clientItfName.equals(_itfName_)) {
+ if
(!(_T_.class.isAssignableFrom(serverItf.getClass()))) {
+ throw new IllegalBindingException("server
interfaces connected to " + clientItfName + " must be instances of " +
_T_.class.getName());
+ }
+ _service_ = (_T_) serverItf;
+ return;
+ }
+ }
+
+ /**
+ * Block to add into the bindFc method (for collection bindings)
+ *
+ * @param clientItfName
+ * the Fractal binding name
+ * @param serverItf
+ * the reference to the server
+ * @throws IllegalBindingException
+ * when attempting to bind incompatible interfaces
+ */
+ void bindCollection(String clientItfName, Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException {
+ if (clientItfName.startsWith(_itfName_)) {
+ if
(!(_R_.class.isAssignableFrom(serverItf.getClass()))) {
+ throw new IllegalBindingException("server
interfaces connected to " + clientItfName + " must be instances of " +
_R_.class.getName());
+ }
+ _servicesMap_.put(clientItfName, (_R_)serverItf);
+ return;
+ }
+
+ }
+}
+
+/**
+ * A template to manage the LookupFc method
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+class LookupFcTemplate implements Template {
+ // ///////////////////////
+ // Parameters for singleton bindings
+ // /////////////////////////
+ @Parameter
+ // The name of the interface (singleton bindings)
+ String _itfName_;
+
+ @Parameter
+ // A Type Reference which is the type of the singleton service
+ CtTypeReference _T_;
+
+ @Local
+ // A Local variable which is the reference to the singeton field
+ _T_ _service_;
+
+ @Parameter("_service_")
+ // The name of the singleton field
+ String __service_;
+
+
+ // /////////////////////////
+ // Parameters for collection bindings
+ // /////////////////////////
+ @Parameter("_servicesMap_")
+ // The name of the java field (collection bindings)
+ String __servicesMap_;
+
+ @Local
+ // The field that contains the collection bindings (collection
bindings)
+ Map<String,?> _servicesMap_;
+
+
+ /**
+ * Use this constructor for singeton bindings
+ *
+ * @param itfName
+ * The name of the Fractal interface
+ * @param serviceType
+ * The java type of the binding
+ * @param serviceName
+ * The name of the java field
+ */
+ public LookupFcTemplate(String itfName, CtTypeReference serviceType,
+ String serviceName) {
+ this._itfName_ = itfName;
+ this._T_ = serviceType;
+ this.__service_ = serviceName;
+
+ }
+
+
+
+ /**
+ * Use this constructor for collection bindings`
+ *
+ * @param fieldName
+ * the name of the map field
+ */
+ public LookupFcTemplate(String fieldName) {
+ this.__servicesMap_ = fieldName;
+ }
+
+
+ /**
+ * Block to add into the bindFc method (for singleton bindings)
+ *
+ * @param clientItfName
+ * the Fractal interface name
+ * @return the reference to the server
+ */
+ Object lookupSingleton(String clientItfName) throws
NoSuchInterfaceException {
+ if (clientItfName.equals(_itfName_)) {
+ return _service_;
+ }
+ return null;
+ }
+
+ /**
+ * Block to add into the bindFc method (for collection bindings)
+ *
+ * @param clientItfName
+ * the Fractal interface name
+ * @return the reference to the server
+ */
+ Object lookupCollection(String clientItfName) throws
NoSuchInterfaceException{
+ if (clientItfName.startsWith(clientItfName)) {
+ return _servicesMap_.get(clientItfName);
+ }
+ return null;
+
+ }
+}
+
+/**
+ * A template to manage the bindFc method when the field is not well typed,
and
+ * the signature parameter is used.
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+class NotTypedBindFcTemplate implements Template {
+
+ // ///////////////////////
+ // Parameters for singleton bindings
+ // /////////////////////////
+ @Parameter
+ // The name of the interface (singleton bindings)
+ String _itfName_;
+
+ @Parameter
+ // A Type Reference which is the type of the singleton service
+ CtTypeReference _T_;
+
+
+ @Local
+ // A Local variable which is the reference to the singeton field
+ _T_ _service_;
+
+
+ @Parameter("_service_")
+ // The name of the singleton field
+ String __service_;
+
+
+ // /////////////////////////
+ // Parameters for collection bindings
+ // /////////////////////////
+ @Parameter("_servicesMap_")
+ // The name of the java field (collection bindings)
+ String __servicesMap_;
+
+ @Local
+ // The field that contains the collection bindings (collection
bindings)
+ Map _servicesMap_;
+
+
+ /**
+ * Use this constructor for singeton bindings
+ *
+ * @param itfName
+ * The name of the Fractal interface
+ * @param serviceType
+ * The java type of the binding
+ * @param serviceName
+ * The name of the java field
+ */
+ public NotTypedBindFcTemplate(String itfName, CtTypeReference
serviceType,
+ String serviceName) {
+ this._itfName_ = itfName;
+ this._T_ = serviceType;
+ this.__service_ = serviceName;
+
+ }
+
+ /**
+ * Use this constructor for collection bindings`
+ *
+ * @param fieldName
+ * the name of the map field
+ */
+ public NotTypedBindFcTemplate(String itfName, String fieldName
,CtTypeReference serviceType) {
+ this._itfName_ = itfName;
+ this.__servicesMap_ = fieldName;
+ this._T_=serviceType;
+ }
+
+ /**
+ * Block to add into the bindFc method (for singleton bindings)
+ *
+ * @param clientItfName
+ * the Fractal binding name
+ * @param serverItf
+ * the reference to the server
+ * @throws IllegalBindingException
+ * when attempting to bind incompatible interfaces
+ */
+ void bindSingleton(String clientItfName, Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException {
+ if (clientItfName.equals(_itfName_)) {
+ if
(!(_T_.class.isAssignableFrom(serverItf.getClass()))) {
+ throw new IllegalBindingException("server
interfaces connected to " + clientItfName + " must be instances of " +
_T_.class.getName());
+ }
+ _service_ = (_T_) serverItf;
+ return;
+ }
+ }
+
+ /**
+ * Block to add into the bindFc method (for collection bindings)
+ *
+ * @param clientItfName
+ * the Fractal binding name
+ * @param serverItf
+ * the reference to the server
+ * @throws IllegalBindingException
+ * when attempting to bind incompatible interfaces
+ */
+ void bindCollection(String clientItfName, Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException {
+ if (clientItfName.startsWith(_itfName_)) {
+ if
(!(_T_.class.isAssignableFrom(serverItf.getClass()))) {
+ throw new IllegalBindingException("server
interfaces connected to " + clientItfName + " must be instances of " +
_T_.class.getName());
+ }
+ _servicesMap_.put(clientItfName, serverItf);
+ return;
+ }
+
+ }
+}
+
+
+/**
+ * A template to manage the bindFc method to get the Component reference
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+class BindRcTemplate implements Template {
+
+ @Local
+ // A Local variable which is the reference to the singeton field
+ Component _service_;
+
+
+ @Parameter("_service_")
+ // The name of the singleton field
+ String __service_;
+
+ /**
+ * Use this constructor for singeton bindings
+ *
+ * @param itfName
+ * The name of the Fractal interface
+ * @param serviceType
+ * The java type of the binding
+ * @param serviceName
+ * The name of the java field
+ */
+ public BindRcTemplate(String serviceName) {
+ this.__service_ = serviceName;
+
+ }
+
+ /**
+ * Block to add into the bindFc method (for singleton bindings)
+ *
+ * @param clientItfName
+ * the Fractal binding name
+ * @param serverItf
+ * the reference to the server
+ * @throws IllegalBindingException
+ * when attempting to bind incompatible interfaces
+ */
+ void bind(String clientItfName, Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException {
+ if (clientItfName.equals("component")) {
+ _service_ = (Component) serverItf;
+ return;
+ }
+ }
+
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/ServiceTemplate.java
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/ServiceTemplate.java:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/ServiceTemplate.java
Fri May 26 15:34:16 2006
@@ -0,0 +1,91 @@
+package org.objectweb.fractal.fraclet.annotation.generator.template;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.control.BindingController;
+import org.objectweb.fractal.api.control.IllegalBindingException;
+
+import spoon.reflect.declaration.CtClass;
+import spoon.template.Local;
+import spoon.template.Parameter;
+import spoon.template.Template;
+
+public class ServiceTemplate implements Template, BindingController {
+
+ /**
+ * Constructor for AttributeTemplate This constructor is called from
the Requires
+ * Processor
+ *
+ * @param spoonFactory
+ * the factory
+ * @param target
+ * the target class
+ */
+ @Local
+ public ServiceTemplate(String serviceName, CtClass<?> target) {
+ this.__service_ = serviceName;
+
+
+ }
+
+ @Local
+ // A Local variable which is the reference to the singeton field
+ Component _service_;
+
+ @Parameter("_service_")
+ // The name of the singleton field
+ String __service_;
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see
org.objectweb.fractal.api.control.BindingController#bindFc(java.lang.String,
+ * java.lang.Object) Method automatically generated with Spoon
+ * <http://spoon.gforge.inria.fr>
+ */
+ public void bindFc(String clientItfName, Object serverItf)
+ throws NoSuchInterfaceException,
IllegalBindingException {
+
+ if (clientItfName.equals("component")) {
+ _service_ = ((Component)(serverItf));
+ return ;
+ }
+ throw new NoSuchInterfaceException(("Client interface \'" +
clientItfName) + "\' is undefined.");
+
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.objectweb.fractal.api.control.BindingController#listFc()
Method
+ * automatically generated with Spoon
<http://spoon.gforge.inria.fr>
+ */
+ public String[] listFc() {
+ return new String[] {};
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see
org.objectweb.fractal.api.control.BindingController#lookupFc(java.lang.String)
+ * Method automatically generated with Spoon
+ * <http://spoon.gforge.inria.fr>
+ */
+ public Object lookupFc(String clientItfName)
+ throws NoSuchInterfaceException {
+ throw new NoSuchInterfaceException("Client interface \'"
+ + clientItfName + "\' is undefined.");
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see
org.objectweb.fractal.api.control.BindingController#unbindFc(java.lang.String)
+ * Method automatically generated with Spoon
+ * <http://spoon.gforge.inria.fr>
+ */
+ public void unbindFc(String clientItfName) throws
NoSuchInterfaceException {
+ throw new NoSuchInterfaceException("Client interface \'"
+ + clientItfName + "\' is undefined.");
+ }
+}
Index:
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/package.html
diff -u /dev/null
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/package.html:1.1
--- /dev/null Fri May 26 15:34:18 2006
+++
fraclet/fraclet-annotation/src/org/objectweb/fractal/fraclet/annotation/generator/template/package.html
Fri May 26 15:34:16 2006
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN"
"classpath://org/objectweb/fractal/adl/xml/basic.dtd">
+<!--==============================================================================
+Fraclet annotation - Copyright (C) 2002-2006 INRIA Futurs / LIFL
+Fractal Component Model (contact: fractal@xxxxxxxxxxxxx)
+
+This library is free software; you can redistribute it and/or modify it
under
+the terms of the GNU Lesser General Public Li