KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.objectweb.fractal.api.control.LifeCycleController;
32
33 import org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
34
35 /**
36  * Provides life cycle related checks to a {@link BindingController}.
37  * <br>
38  * <br>
39  * <b>Requirements</b>
40  * <ul>
41  * <li>none (the component may provide a {@link LifeCycleController} interface,
42  * but this is not mandatory - in this case this binding does nothing).</li>
43  * </ul>
44  */

45
46 public abstract class LifeCycleBindingMixin implements BindingController {
47
48   // -------------------------------------------------------------------------
49
// Private constructor
50
// -------------------------------------------------------------------------
51

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

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

70
71   public void unbindFc (final String JavaDoc clientItfName) throws
72     NoSuchInterfaceException,
73     IllegalBindingException,
74     IllegalLifeCycleException
75   {
76     if (_this_weaveableOptLC != null) {
77       String JavaDoc state = _this_weaveableOptLC.getFcState();
78       if (!LifeCycleController.STOPPED.equals(state)) {
79         throw new ChainedIllegalLifeCycleException(
80           null, _this_weaveableOptC, "The component is not stopped");
81       }
82     }
83     _super_unbindFc(clientItfName);
84   }
85
86   // -------------------------------------------------------------------------
87
// Fields and methods required by the mixin class in the base class
88
// -------------------------------------------------------------------------
89

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

95
96   public Component _this_weaveableOptC;
97
98   /**
99    * The <tt>weaveableOptLC</tt> field required by this mixin. This field is
100    * supposed to reference the {@link LifeCycleController} interface of the
101    * component to which this controller object belongs.
102    */

103
104   public LifeCycleController _this_weaveableOptLC;
105
106   /**
107    * The {@link BindingController#unbindFc unbindFc} method overriden by this
108    * mixin.
109    *
110    * @param clientItfName the name of a client interface of the component to
111    * which this interface belongs.
112    * @throws NoSuchInterfaceException if there is no such client interface.
113    * @throws IllegalBindingException if the binding cannot be removed.
114    * @throws IllegalLifeCycleException if this component has a {@link
115    * LifeCycleController} interface, but it is not in an appropriate state
116    * to perform this operation.
117    */

118
119   public abstract void _super_unbindFc (String JavaDoc clientItfName) throws
120     NoSuchInterfaceException,
121     IllegalBindingException,
122     IllegalLifeCycleException;
123 }
124
Popular Tags