KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > mybatchfwk > ITaskExecutor


1 /*
2  * MyBatchFramework - Open-source batch framework.
3  * Copyright (C) 2006 Jérôme Bertèche cyberteche@users.sourceforge.net
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.1 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  * Jérôme Bertèche
16  * Email: cyberteche@users.sourceforge.net
17  */

18 package net.sf.mybatchfwk;
19
20 /**
21  * The task executor service interface
22  * @author Jérôme Bertèche (cyberteche@users.sourceforge.net)
23  */

24 public interface ITaskExecutor {
25     
26     /**
27      * Execute the given task, waiting for free space in blocking queue if necessary
28      * @param task the task to execute
29      * @return true is the task has been added to the execution queue, false otherwise (the user can shutdown this service through JMX)
30      */

31     public boolean execute(ITask task) throws BatchException;
32     
33     /**
34      * Indicate the running state of the executor (the user can shutdown this service through JMX).
35      * If false, then no more task must be execute.
36      *
37      * @return true is the service is running, false otherwise
38      */

39     public boolean isRunning();
40     
41     /**
42      * Returns the approximate total number of tasks that have been
43      * scheduled for execution. Because the states of tasks and
44      * threads may change dynamically during computation, the returned
45      * value is only an approximation, but one that does not ever
46      * decrease across successive calls.
47      *
48      * @return the number of tasks
49      */

50     public long getTaskCount();
51 }
52
Popular Tags