KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > control > content > LifeCycleContentMixin


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.content;
25
26 import org.objectweb.fractal.api.Component;
27 import org.objectweb.fractal.api.control.ContentController;
28 import org.objectweb.fractal.api.control.IllegalContentException;
29 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
30 import org.objectweb.fractal.api.control.LifeCycleController;
31
32 import org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
33
34 /**
35  * Provides lifecycle related checks to a {@link ContentController}.
36  * <br>
37  * <br>
38  * <b>Requirements</b>
39  * <ul>
40  * <li>none (the component may provide a {@link LifeCycleController} interface,
41  * but this is not mandatory - in this case this mixin does nothing).</li>
42  * </ul>
43  */

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

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

58   /**
59    * Checks that the component is stopped and then calls the overriden method.
60    *
61    * @param subComponent the component to be removed from this component.
62    * @throws IllegalContentException if the given component cannot be removed
63    * from this component.
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 removeFcSubComponent (final Component subComponent)
70     throws IllegalContentException, IllegalLifeCycleException
71   {
72     if (_this_weaveableOptLC != null) {
73       String JavaDoc state = _this_weaveableOptLC.getFcState();
74       if (!LifeCycleController.STOPPED.equals(state)) {
75         throw new ChainedIllegalLifeCycleException(
76           null, _this_weaveableOptC, "The component is not stopped");
77       }
78     }
79     _super_removeFcSubComponent(subComponent);
80   }
81
82   // -------------------------------------------------------------------------
83
// Fields and methods required by the mixin class in the base class
84
// -------------------------------------------------------------------------
85

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

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

99
100   public LifeCycleController _this_weaveableOptLC;
101
102   /**
103    * The {@link ContentController#removeFcSubComponent removeFcSubComponent}
104    * method overriden by this mixin.
105    *
106    * @param subComponent the component to be removed from this component.
107    * @throws IllegalContentException if the given component cannot be removed
108    * from this component.
109    * @throws IllegalLifeCycleException if this component has a {@link
110    * LifeCycleController} interface, but it is not in an appropriate state
111    * to perform this operation.
112    */

113
114   public abstract void _super_removeFcSubComponent (Component subComponent)
115     throws IllegalContentException, IllegalLifeCycleException;
116 }
117
Popular Tags