KickJava   Java API By Example, From Geeks To Geeks.

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


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.control.binding;
25
26 import org.objectweb.fractal.api.Component;
27 import org.objectweb.fractal.api.NoSuchInterfaceException;
28 import org.objectweb.fractal.api.control.ContentController;
29 import org.objectweb.fractal.api.control.IllegalBindingException;
30 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
31 import org.objectweb.fractal.api.type.InterfaceType;
32
33 import org.objectweb.fractal.julia.ComponentInterface;
34 import org.objectweb.fractal.julia.Interceptor;
35
36 /**
37  * Provides {@link ComponentInterface} management to a {@link
38  * org.objectweb.fractal.api.control.BindingController}.
39  * <br>
40  * <br>
41  * <b>Requirements</b>
42  * <ul>
43  * <li>the component to which this component belongs must provide the {@link
44  * Component} and {@link ContentController} interfaces. Its type must be an
45  * instance of {@link org.objectweb.fractal.api.type.ComponentType}, and its
46  * interfaces must implement {@link ComponentInterface}.</li>
47  * </ul>
48  */

49
50 public abstract class CompositeBindingMixin {
51
52   // -------------------------------------------------------------------------
53
// Private constructor
54
// -------------------------------------------------------------------------
55

56   private CompositeBindingMixin () {
57   }
58
59   // -------------------------------------------------------------------------
60
// Fields and methods added and overriden by the mixin class
61
// -------------------------------------------------------------------------
62

63   /**
64    * Calls the overriden method and then updates the {@link
65    * ComponentInterface#getFcItfImpl getFcItfImpl} link (or the {@link
66    * Interceptor#getFcItfDelegate getFcItfDelegate} link of the corresponding
67    * interceptor) of the <tt>clientItfName</tt> interface to <tt>serverItf</tt>.
68    *
69    * @param clientItfType the type of the <tt>clientItfName</tt> interface.
70    * @param clientItfName the name of a client interface of the component to
71    * which this interface belongs.
72    * @param serverItf a server interface.
73    * @throws NoSuchInterfaceException if there is no such client interface.
74    * @throws IllegalBindingException if the binding cannot be created.
75    * @throws IllegalLifeCycleException if this component has a {@link
76    * org.objectweb.fractal.api.control.LifeCycleController} interface, but
77    * it is not in an appropriate state to perform this operation.
78    */

79
80   public void bindFc (
81     final InterfaceType clientItfType,
82     final String JavaDoc clientItfName,
83     final Object JavaDoc serverItf)
84     throws
85     NoSuchInterfaceException,
86     IllegalBindingException,
87     IllegalLifeCycleException
88   {
89     _super_bindFc(clientItfType, clientItfName, serverItf);
90     Object JavaDoc complementaryItf;
91     if (clientItfType.isFcClientItf()) {
92       complementaryItf =
93         _this_weaveableCC.getFcInternalInterface(clientItfName);
94     } else {
95       complementaryItf =
96         _this_weaveableC.getFcInterface(clientItfName);
97     }
98     ComponentInterface itf = (ComponentInterface)complementaryItf;
99     if (itf.hasFcInterceptor()) {
100       Object JavaDoc newImpl = itf.getFcItfImpl();
101       ((Interceptor)newImpl).setFcItfDelegate(serverItf);
102     } else {
103       itf.setFcItfImpl(serverItf);
104     }
105   }
106
107   /**
108    * Calls the overriden method and then updates the {@link
109    * ComponentInterface#getFcItfImpl getFcItfImpl} link (or the {@link
110    * Interceptor#getFcItfDelegate getFcItfDelegate} link of the corresponding
111    * interceptor) of the <tt>clientItfName</tt> interface to <tt>null</tt>.
112    *
113    * @param clientItfType the type of the <tt>clientItfName</tt> interface.
114    * @param clientItfName the name of a client interface of the component to
115    * which this interface belongs.
116    * @throws NoSuchInterfaceException if there is no such client interface.
117    * @throws IllegalBindingException if the binding cannot be removed.
118    * @throws IllegalLifeCycleException if this component has a {@link
119    * org.objectweb.fractal.api.control.LifeCycleController} interface, but
120    * it is not in an appropriate state to perform this operation.
121    */

122
123   public void unbindFc (
124     final InterfaceType clientItfType,
125     final String JavaDoc clientItfName)
126     throws
127     NoSuchInterfaceException,
128     IllegalBindingException,
129     IllegalLifeCycleException
130   {
131     _super_unbindFc(clientItfType, clientItfName);
132     Object JavaDoc complementaryItf;
133     if (clientItfType.isFcClientItf()) {
134       complementaryItf =
135         _this_weaveableCC.getFcInternalInterface(clientItfName);
136     } else {
137       complementaryItf =
138         _this_weaveableC.getFcInterface(clientItfName);
139     }
140     ComponentInterface itf = (ComponentInterface)complementaryItf;
141     if (itf.hasFcInterceptor()) {
142       Object JavaDoc newImpl = itf.getFcItfImpl();
143       ((Interceptor)newImpl).setFcItfDelegate(null);
144     } else {
145       itf.setFcItfImpl(null);
146     }
147   }
148
149   // -------------------------------------------------------------------------
150
// Fields and methods required by the mixin class in the base class
151
// -------------------------------------------------------------------------
152

153   /**
154    * The <tt>weaveableC</tt> field required by this mixin. This field is
155    * supposed to reference the {@link Component} interface of the component to
156    * which this controller object belongs.
157    */

158
159   public Component _this_weaveableC;
160
161   /**
162    * The <tt>weaveableCC</tt> field required by this mixin. This field is
163    * supposed to reference the {@link ContentController} interface of the
164    * component to which this controller object belongs.
165    */

166
167   public ContentController _this_weaveableCC;
168
169   /**
170    * The {@link TypeBindingMixin#bindFc(InterfaceType,String,Object) bindFc}
171    * method overriden by this mixin.
172    *
173    * @param clientItfType the type of the <tt>clientItfName</tt> interface.
174    * @param clientItfName the name of a client interface of the component to
175    * which this interface belongs.
176    * @param serverItf a server interface.
177    * @throws NoSuchInterfaceException if there is no such client interface.
178    * @throws IllegalBindingException if the binding cannot be created.
179    * @throws IllegalLifeCycleException if this component has a {@link
180    * org.objectweb.fractal.api.control.LifeCycleController} interface, but
181    * it is not in an appropriate state to perform this operation.
182    */

183
184   public abstract void _super_bindFc (
185     InterfaceType clientItfType,
186     String JavaDoc clientItfName,
187     Object JavaDoc serverItf)
188     throws
189     NoSuchInterfaceException,
190     IllegalBindingException,
191     IllegalLifeCycleException;
192
193   /**
194    * The {@link TypeBindingMixin#unbindFc(InterfaceType,String) unbindFc}
195    * method overriden by this mixin.
196    *
197    * @param clientItfType the type of the <tt>clientItfName</tt> interface.
198    * @param clientItfName the name of a client interface of the component to
199    * which this interface belongs.
200    * @throws NoSuchInterfaceException if there is no such client interface.
201    * @throws IllegalBindingException if the binding cannot be removed.
202    * @throws IllegalLifeCycleException if this component has a {@link
203    * org.objectweb.fractal.api.control.LifeCycleController} interface, but
204    * it is not in an appropriate state to perform this operation.
205    */

206
207   public abstract void _super_unbindFc (
208     InterfaceType clientItfType,
209     String JavaDoc clientItfName)
210     throws
211     NoSuchInterfaceException,
212     IllegalBindingException,
213     IllegalLifeCycleException;
214 }
215
Popular Tags