KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > control > binding > TypeBasicBindingMixin


1 package org.objectweb.fractal.julia.control.binding;
2
3 import org.objectweb.fractal.api.factory.InstantiationException;
4 import org.objectweb.fractal.api.type.ComponentType;
5 import org.objectweb.fractal.api.type.InterfaceType;
6
7 import org.objectweb.fractal.julia.Controller;
8 import org.objectweb.fractal.julia.InitializationContext;
9
10 import java.util.HashMap JavaDoc;
11 import java.util.Map JavaDoc;
12
13 /**
14  * Provides a basic type system based initializer to a {@link
15  * org.objectweb.fractal.api.control.BindingController}.
16  * <br>
17  * <br>
18  * <b>Requirements</b>
19  * <ul>
20  * <li>the type of the component to which this controller object belongs must be
21  * an instance of {@link ComponentType}.</li>
22  * </ul>
23  */

24
25 public abstract class TypeBasicBindingMixin implements Controller {
26
27   // -------------------------------------------------------------------------
28
// Private constructor
29
// -------------------------------------------------------------------------
30

31   private TypeBasicBindingMixin () {
32   }
33
34   // -------------------------------------------------------------------------
35
// Fields and methods added and overriden by the mixin class
36
// -------------------------------------------------------------------------
37

38   /**
39    * Initializes the {@link #_this_fcBindings} map, and then calls the overriden
40    * method.
41    *
42    * @param ic information about the component to which this controller object
43    * belongs.
44    * @throws InstantiationException if the initialization fails.
45    */

46
47   public void initFcController (final InitializationContext ic)
48     throws InstantiationException JavaDoc
49   {
50     ComponentType compType = (ComponentType)ic.type;
51     InterfaceType[] itfTypes = compType.getFcInterfaceTypes();
52     boolean isComposite = ic.getOptionalInterface("content-controller") != null;
53
54     // initializes the fcBindings map with empty bindings for all the
55
// interfaces in the component's type
56
for (int j = 0; j < itfTypes.length; j++) {
57       InterfaceType itfType = itfTypes[j];
58       if (!itfType.isFcCollectionItf() &&
59           !itfType.getFcItfName().equals("component") &&
60           !itfType.getFcItfName().endsWith("-controller") &&
61           (itfType.isFcClientItf() || isComposite))
62       {
63         if (_this_fcBindings == null) {
64           _this_fcBindings = new HashMap JavaDoc();
65         }
66         _this_fcBindings.put(itfType.getFcItfName(), _this_fcBindings);
67       }
68     }
69
70     // calls the overriden method
71
_super_initFcController(ic);
72   }
73
74   // -------------------------------------------------------------------------
75
// Fields and methods required by the mixin class in the base class
76
// -------------------------------------------------------------------------
77

78   /**
79    * The <tt>fcBindings</tt> field required by this mixin. This field is
80    * supposed to store the bindings of the component to which this controller
81    * object belongs.
82    */

83
84   public Map JavaDoc _this_fcBindings;
85
86   /**
87    * The {@link Controller#initFcController initFcController} method overriden
88    * by this mixin.
89    *
90    * @param ic information about the component to which this controller object
91    * belongs.
92    * @throws InstantiationException if the initialization fails.
93    */

94
95   public abstract void _super_initFcController (InitializationContext ic)
96     throws InstantiationException JavaDoc;
97 }
98
Popular Tags