KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > control > activity > scheduler > ForwarderSchedulerImpl


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): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.control.activity.scheduler;
26
27 import org.objectweb.dream.AbstractComponent;
28 import org.objectweb.dream.control.activity.task.Task;
29 import org.objectweb.fractal.api.NoSuchInterfaceException;
30 import org.objectweb.fractal.api.control.IllegalBindingException;
31 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
32
33 /**
34  * Basic implementation of a forwarder scheduler. This scheduler is only bound
35  * to one upper-level that it executes. The <code>schedule</code> method only
36  * executes the upper-level task to which this scheduler is bound.
37  */

38 public class ForwarderSchedulerImpl extends AbstractComponent
39     implements
40       Scheduler
41 {
42
43   /** The task that is executed. */
44   protected Task task;
45
46   // ---------------------------------------------------------------------------
47
// Implementation of the Scheduler interface
48
// ---------------------------------------------------------------------------
49

50   /**
51    * @see Scheduler#schedule(Object)
52    */

53   public Object JavaDoc schedule(Object JavaDoc hints) throws InterruptedException JavaDoc,
54       StoppedSchedulerException
55   {
56     return task.execute(hints);
57   }
58
59   // ---------------------------------------------------------------------------
60
// Implementation of the BindingController interface
61
// ---------------------------------------------------------------------------
62

63   /**
64    * @see org.objectweb.fractal.api.control.BindingController#bindFc(String,
65    * Object)
66    */

67   public synchronized void bindFc(String JavaDoc clientItfName, Object JavaDoc serverItf)
68       throws NoSuchInterfaceException, IllegalBindingException,
69       IllegalLifeCycleException
70   {
71     super.bindFc(clientItfName, serverItf);
72     if (clientItfName.equals(Task.ITF_NAME))
73     {
74       task = (Task) serverItf;
75     }
76   }
77
78   /**
79    * @see org.objectweb.fractal.api.control.BindingController#listFc()
80    */

81   public String JavaDoc[] listFc()
82   {
83     return new String JavaDoc[]{Task.ITF_NAME};
84   }
85
86 }
Popular Tags