KickJava   Java API By Example, From Geeks To Geeks.

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


1 /***
2  * Julia: France Telecom's implementation of the Fractal API
3  * Copyright (C) 2001-2002 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.julia.factory;
25
26 import org.objectweb.fractal.api.Component;
27 import org.objectweb.fractal.api.NoSuchInterfaceException;
28 import org.objectweb.fractal.api.control.AttributeController;
29 import org.objectweb.fractal.api.factory.InstantiationException;
30
31 import org.objectweb.fractal.julia.control.attribute.CloneableAttributeController;
32
33 /**
34  * Provides an attribute copy function to a {@link Template}.
35  * <br>
36  * <br>
37  * <b>Requirements</b>
38  * <ul>
39  * <li>none (the template component may provide a {@link
40  * CloneableAttributeController} interface, but this is not mandatory - in this
41  * case this mixin does nothing).</li>
42  * </ul>
43  */

44
45 public abstract class AttributeTemplateMixin implements Template {
46
47   // -------------------------------------------------------------------------
48
// Private constructor
49
// -------------------------------------------------------------------------
50

51   private AttributeTemplateMixin () {
52   }
53
54   // -------------------------------------------------------------------------
55
// Fields and methods added and overriden by the mixin class
56
// -------------------------------------------------------------------------
57

58   /**
59    * Calls the overriden method and then sets the attributes of the created
60    * component. The attributes of the created component are initialized from the
61    * attributes name of this template, if the template has a {@link
62    * CloneableAttributeController} interface, and if the created component has
63    * an {@link org.objectweb.fractal.api.control.AttributeController} interface
64    * (otherwise this mixin does nothing).
65    *
66    * @return the instantiated component.
67    * @throws InstantiationException if the component controller cannot be
68    * instantiated.
69    */

70
71   public Component newFcControllerInstance () throws InstantiationException JavaDoc {
72     Component comp = _super_newFcControllerInstance();
73     if (_this_weaveableOptCAC != null) {
74       // copies the template's attributes into the component, if applicable
75
try {
76         _this_weaveableOptCAC.cloneFcAttributes(
77           (AttributeController)comp.getFcInterface("attribute-controller"));
78       } catch (NoSuchInterfaceException ignored) {
79       }
80     }
81     return comp;
82   }
83
84   // -------------------------------------------------------------------------
85
// Fields and methods required by the mixin class in the base class
86
// -------------------------------------------------------------------------
87

88   /**
89    * The <tt>weaveableOptcCAC</tt> field required by this mixin. This field is
90    * supposed to reference the {@link CloneableAttributeController} interface
91    * of the component to which this controller object belongs.
92    */

93
94   public CloneableAttributeController _this_weaveableOptCAC;
95
96   /**
97    * The {@link Template#newFcControllerInstance newFcControllerInstance}
98    * overriden by this mixin.
99    *
100    * @return the instantiated component.
101    * @throws InstantiationException if the component controller cannot be
102    * instantiated.
103    */

104
105   public abstract Component _super_newFcControllerInstance ()
106     throws InstantiationException JavaDoc;
107 }
108
Popular Tags