KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > control > activity > task > ContainerLifeCycleMixin


1 /**
2  * Dream Copyright (C) 2003-2004 INRIA Rhone-Alpes
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option) any
7  * later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Contact: dream@objectweb.org
19  *
20  * Initial developer(s): Matthieu Leclercq
21  * Contributor(s):
22  */

23
24 package org.objectweb.dream.control.activity.task;
25
26 import org.objectweb.dream.util.Error;
27 import org.objectweb.fractal.api.Component;
28 import org.objectweb.fractal.api.NoSuchInterfaceException;
29 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
30
31 /**
32  * Mixin that delegate method to content object. The content of the component
33  * must implements {@link TaskLifeCycleController}.
34  */

35 public abstract class ContainerLifeCycleMixin
36     implements
37       TaskLifeCycleController
38 {
39
40   // -------------------------------------------------------------------------
41
// Private constructor
42
// -------------------------------------------------------------------------
43

44   private ContainerLifeCycleMixin()
45   {
46   }
47
48   // -------------------------------------------------------------------------
49
// Fields and methods added and overriden by the mixin class
50
// -------------------------------------------------------------------------
51

52   /**
53    * @see TaskLifeCycleController#asyncStop(TaskStoppedListener)
54    */

55   public void asyncStop(TaskStoppedListener listener)
56   {
57     getContent().asyncStop(listener);
58   }
59
60   /**
61    * @see org.objectweb.fractal.api.control.LifeCycleController#getFcState()
62    */

63   public String JavaDoc getFcState()
64   {
65     return getContent().getFcState();
66   }
67
68   /**
69    * @see org.objectweb.fractal.api.control.LifeCycleController#startFc()
70    */

71   public void startFc() throws IllegalLifeCycleException
72   {
73     getContent().startFc();
74   }
75
76   /**
77    * @see org.objectweb.fractal.api.control.LifeCycleController#stopFc()
78    */

79   public void stopFc() throws IllegalLifeCycleException
80   {
81     getContent().stopFc();
82   }
83
84   /**
85    * Returns the content of the component.
86    *
87    * @return the content of the component.
88    */

89   public TaskLifeCycleController getContent()
90   {
91     try
92     {
93       return (TaskLifeCycleController) _this_weaveableOptC
94           .getFcInterface("/content");
95     }
96     catch (NoSuchInterfaceException e)
97     {
98       Error.error("Unable to find component content", null);
99       return null;
100     }
101     catch (ClassCastException JavaDoc e)
102     {
103       Error.error(
104           "The content object does not implements TaskLifeCycleController",
105           null);
106       return null;
107     }
108   }
109
110   // -------------------------------------------------------------------------
111
// Fields and methods required by the mixin class in the base class
112
// -------------------------------------------------------------------------
113

114   /**
115    * The <tt>weaveableOptC</tt> field required by this mixin. This field is
116    * supposed to reference the {@link Component}interface of the component to
117    * which this controller object belongs.
118    */

119
120   public Component _this_weaveableOptC;
121
122 }
Popular Tags