KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
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: dream@objectweb.org
20  *
21  * Initial developer(s): Matthieu Leclercq
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.control.activity.task;
26
27 import java.util.Map JavaDoc;
28
29 import org.objectweb.dream.util.Error;
30 import org.objectweb.fractal.api.control.LifeCycleController;
31
32 /**
33  * This mixin activates new added task. ie : call
34  * {@link TaskActivationController#activateTask(Task) }when a task is added (
35  * {@link TaskController#addTask(Task, Map) addTask}) and the component is
36  * started. This miwin also deactivates removed task.
37  */

38 public abstract class LifeCycleActivationTaskMixin
39 {
40
41   // -------------------------------------------------------------------------
42
// Fields and methods added and overriden by the mixin class
43
// -------------------------------------------------------------------------
44

45   /**
46    * @see TaskController#addTask(Task, Map)
47    */

48   public void addTask(Task task, Map JavaDoc hints) throws IllegalTaskException
49   {
50     _super_addTask(task, hints);
51     if (_this_weaveableOptLC == null
52         || _this_weaveableOptLC.getFcState()
53             .equals(LifeCycleController.STARTED))
54     {
55       try
56       {
57         _this_weaveableTAC.activateTask(task);
58       }
59       catch (NoSuchTaskException e)
60       {
61         // can't happend
62
Error.bug(null, e);
63       }
64     }
65   }
66
67   /**
68    * @see TaskController#removeTask(Task)
69    */

70   public void removeTask(Task task) throws NoSuchTaskException,
71       IllegalTaskException
72   {
73     _this_weaveableTAC.deactivateTask(task);
74     _super_removeTask(task);
75   }
76
77   // -------------------------------------------------------------------------
78
// Fields and methods required by the mixin class in the base class
79
// -------------------------------------------------------------------------
80

81   /**
82    * The <code>weaveableTAC</code> field required by this mixin. This field is
83    * supposed to reference the {@link TaskActivationController }interface of
84    * the component to which this controller object belongs.
85    */

86   public TaskActivationController _this_weaveableTAC;
87
88   /**
89    * The <code>weaveableOptLC</code> field required by this mixin. This field
90    * is supposed to reference the {@link LifeCycleController }interface of the
91    * component to which this controller object belongs.
92    */

93   public LifeCycleController _this_weaveableOptLC;
94
95   /**
96    * The {@link TaskController#addTask(Task, Map) }method overriden by this
97    * mixin.
98    *
99    * @see TaskController#addTask(Task, Map)
100    */

101   public abstract void _super_addTask(Task task, Map JavaDoc hints)
102       throws IllegalTaskException;
103
104   /**
105    * The {@link TaskController#removeTask(Task) }method overriden by this
106    * mixin.
107    *
108    * @see TaskController#removeTask(Task)
109    */

110   public abstract void _super_removeTask(Task task) throws NoSuchTaskException,
111       IllegalTaskException;
112 }
Popular Tags