KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > factory > SingletonTemplateMixin


1 package org.objectweb.fractal.julia.factory;
2
3 import org.objectweb.fractal.api.Component;
4 import org.objectweb.fractal.api.factory.InstantiationException;
5
6 /**
7  * Provides a singleton behavior to a {@link Template}.
8  * <b>A singleton composite template must only contain other singleton
9  * templates, otherwise the "singleton" semantics will not be ensured.</b>
10  * <br>
11  * <br>
12  * <b>Requirements</b>
13  * <ul>
14  * <li>none.</li>
15  * </ul>
16  */

17
18 public abstract class SingletonTemplateMixin implements Template {
19
20   // -------------------------------------------------------------------------
21
// Private constructor
22
// -------------------------------------------------------------------------
23

24   private SingletonTemplateMixin () {
25   }
26
27   // -------------------------------------------------------------------------
28
// Fields and methods added and overriden by the mixin class
29
// -------------------------------------------------------------------------
30

31   /**
32    * The singleton instance created by this template.
33    */

34
35   public Component fcInstance;
36
37   /**
38    * Calls the overriden method only if the {@link #fcInstance} field is
39    * <tt>null</tt>.
40    *
41    * @return the instantiated component.
42    * @throws InstantiationException if the component controller cannot be
43    * instantiated.
44    */

45
46   public Component newFcControllerInstance () throws InstantiationException JavaDoc {
47     if (fcInstance == null) {
48       fcInstance = _super_newFcControllerInstance();
49     }
50     return fcInstance;
51   }
52
53   // -------------------------------------------------------------------------
54
// Fields and methods required by the mixin class in the base class
55
// -------------------------------------------------------------------------
56

57   /**
58    * The {@link Template#newFcControllerInstance newFcControllerInstance}
59    * overriden by this mixin.
60    *
61    * @return the instantiated component.
62    * @throws InstantiationException if the component controller cannot be
63    * instantiated.
64    */

65
66   public abstract Component _super_newFcControllerInstance ()
67     throws InstantiationException JavaDoc;
68 }
69
Popular Tags