Mail Archive Home | fractal-commits List | March 2006 Index
| <-- Date Index --> | <-- Thread Index --> |
Date: Friday, March 31, 2006 @ 10:44:13
Author: pessemier
Path: .../fraclet/fraclet-annotation/examples/primitive/src/primitive
Modified: Client.java
Add the @FractalRC field annotation to get the Component reference of a
component
-------------+
Client.java | 141 ++++++++++++++++++++++++++++++++--------------------------
1 files changed, 78 insertions(+), 63 deletions(-)
Index: fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java
diff -u
fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java:1.6
fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java:1.7
---
fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java:1.6
Wed Mar 22 16:10:18 2006
+++ fraclet/fraclet-annotation/examples/primitive/src/primitive/Client.java
Fri Mar 31 10:44:12 2006
@@ -1,64 +1,79 @@
-/*==============================================================================
-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 primitive;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-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;
-
-/**
- * A Fractal component client
- *
- * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
- *
- */
-@FractalComponent(controllerDesc="primitive")
-@FractalImportedInterface(interfaces=@FractalItf(name="r",signature="java.lang.Runnable"))
-public class Client implements Runnable {
-
- @FractalBC(name = "default")
- private Service defaut;
-
- /**
- * Reference to the service bound."
- */
- @FractalBC(name = "service", cardinality = "collection")
- private Map<String,Service> services = new HashMap<String,Service>();
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Runnable#run()
- */
- public void run() {
- for (Iterator i = services.entrySet().iterator();
i.hasNext();) {
- Entry service = (Entry) i.next();
- System.out.println("Calling " + service.getKey() +
"...");
- ((Service) service.getValue()).print();
- }
- System.out.println("Default service says: ");
- this.defaut.print();
- }
+/*==============================================================================
+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 primitive;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+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;
+
+/**
+ * A Fractal component client
+ *
+ * @author Nicolas Pessemier <Nicolas.Pessemier@xxxxxxx>
+ *
+ */
+@FractalComponent
+@FractalImportedInterface(interfaces=@FractalItf(name="r",signature="java.lang.Runnable"))
+public class Client implements Runnable {
+
+ @FractalBC(name = "default")
+ private Service defaut;
+
+ @FractalRC
+ private Component ref;
+
+ /**
+ * Reference to the service bound."
+ */
+ @FractalBC(name = "service", cardinality = "collection")
+ private Map<String,Service> services = new HashMap<String,Service>();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ NameController nc=null;
+ try {
+ nc =
(NameController)ref.getFcInterface("name-controller");
+ } catch (NoSuchInterfaceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ String componentName=nc.getFcName();
+ for (Iterator i = services.entrySet().iterator();
i.hasNext();) {
+ Entry service = (Entry) i.next();
+ System.out.println(componentName+" Calling " +
service.getKey() + "...");
+ ((Service) service.getValue()).print();
+ }
+ System.out.println("Default service says: ");
+ this.defaut.print();
+ }
}
\ No newline at end of file
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.