KickJava   Java API By Example, From Geeks To Geeks.

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


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.BindingController;
29 import org.objectweb.fractal.api.control.IllegalBindingException;
30 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
31
32 /**
33  * Provides basic checks to a {@link BindingController}.
34  * <br>
35  * <br>
36  * <b>Requirements</b>
37  * <ul>
38  * <li>none.</li>
39  * </ul>
40  */

41
42 public abstract class CheckBindingMixin implements BindingController {
43
44   // -------------------------------------------------------------------------
45
// Private constructor
46
// -------------------------------------------------------------------------
47

48   private CheckBindingMixin () {
49   }
50
51   // -------------------------------------------------------------------------
52
// Fields and methods added and overriden by the mixin class
53
// -------------------------------------------------------------------------
54

55   /**
56    * Checks that the given interface is unbound, and then calls the overriden
57    * method.
58    *
59    * @param clientItfName the name of a client interface of the component to
60    * which this interface belongs.
61    * @param serverItf a server interface.
62    * @throws NoSuchInterfaceException if there is no such client interface.
63    * @throws IllegalBindingException if the binding cannot be created.
64    * @throws IllegalLifeCycleException if this component has a {@link
65    * LifeCycleController} interface, but it is not in an appropriate state
66    * to perform this operation.
67    */

68
69   public void bindFc (final String JavaDoc clientItfName, final Object JavaDoc serverItf) throws
70     NoSuchInterfaceException,
71     IllegalBindingException,
72     IllegalLifeCycleException
73   {
74     if (_this_lookupFc(clientItfName) != null) {
75       throw new ChainedIllegalBindingException(
76         null,
77         _this_weaveableOptC,
78         null,
79         clientItfName,
80         null,
81         "Already bound");
82     }
83     _super_bindFc(clientItfName, serverItf);
84   }
85
86   /**
87    * Checks that the given interface is bound, and then calls the overriden
88    * method.
89    *
90    * @param clientItfName the name of a client interface of the component to
91    * which this interface belongs.
92    * @throws NoSuchInterfaceException if there is no such client interface.
93    * @throws IllegalBindingException if the binding cannot be removed.
94    * @throws IllegalLifeCycleException if this component has a {@link
95    * LifeCycleController} interface, but it is not in an appropriate state
96    * to perform this operation.
97    */

98
99   public void unbindFc (final String JavaDoc clientItfName) throws
100     NoSuchInterfaceException,
101     IllegalBindingException,
102     IllegalLifeCycleException
103   {
104     if (_this_lookupFc(clientItfName) == null) {
105       throw new ChainedIllegalBindingException(null,
106         _this_weaveableOptC,
107         null,
108         clientItfName,
109         null,
110         "Not bound");
111     }
112     _super_unbindFc(clientItfName);
113   }
114
115   // -------------------------------------------------------------------------
116
// Fields and methods required by the mixin class in the base class
117
// -------------------------------------------------------------------------
118

119   /**
120    * The <tt>weaveableOptC</tt> field required by this mixin. This field is
121    * supposed to reference the {@link Component} interface of the component to
122    * which this controller object belongs.
123    */

124
125   public Component _this_weaveableOptC;
126
127   /**
128    * The {@link BindingController#listFc listFc} method required by this mixin.
129    *
130    * @param clientItfName the name of a client interface of the component to
131    * which this interface belongs.
132    * @return the server interface to which the given interface is bound, or <tt>
133    * null</tt> if it is not bound.
134    * @throws NoSuchInterfaceException if the component to which this interface
135    * belongs does not have a client interface whose name is equal to the
136    * given name.
137    */

138
139   public abstract Object JavaDoc _this_lookupFc (String JavaDoc clientItfName) throws
140     NoSuchInterfaceException;
141
142   /**
143    * The {@link BindingController#bindFc bindFc} method overriden by this mixin.
144    *
145    * @param clientItfName the name of a client interface of the component to
146    * which this interface belongs.
147    * @param serverItf a server interface.
148    * @throws NoSuchInterfaceException if there is no such client interface.
149    * @throws IllegalBindingException if the binding cannot be created.
150    * @throws IllegalLifeCycleException if this component has a {@link
151    * LifeCycleController} interface, but it is not in an appropriate state
152    * to perform this operation.
153    */

154
155   public abstract void _super_bindFc (String JavaDoc clientItfName, Object JavaDoc serverItf) throws
156     NoSuchInterfaceException,
157     IllegalBindingException,
158     IllegalLifeCycleException;
159
160   /**
161    * The {@link BindingController#unbindFc unbindFc} method overriden by this
162    * mixin.
163    *
164    * @param clientItfName the name of a client interface of the component to
165    * which this interface belongs.
166    * @throws NoSuchInterfaceException if there is no such client interface.
167    * @throws IllegalBindingException if the binding cannot be removed.
168    * @throws IllegalLifeCycleException if this component has a {@link
169    * LifeCycleController} interface, but it is not in an appropriate state
170    * to perform this operation.
171    */

172
173   public abstract void _super_unbindFc (String JavaDoc clientItfName) throws
174     NoSuchInterfaceException,
175     IllegalBindingException,
176     IllegalLifeCycleException;
177 }
178
Popular Tags