2
* Copyright (C) 2009 by Eric Lambert <Eric.Lambert@sun.com>
3
* Use and distribution licensed under the
4
* GNU Lesser General Public License (LGPL) version 2.1.
5
* See the COPYING file in the parent directory for full text.
7
package org.gearman.worker;
9
import java.util.concurrent.Callable;
10
import org.gearman.client.GearmanJobEventListener;
11
import org.gearman.common.GearmanPacket;
15
* This interface exposes the API which GearmanFunction classes will need to
19
* A Gearman Function represents the work to be accomplished by a
20
* {@link GearmanJob}. It defines how the job is executed and the data, if
21
* any, against which that execution will occurr.
23
public interface GearmanFunction extends Callable<GearmanPacket> {
26
* Retrieves the name of the funcion. This is used by a {@link GearmanWorker}
27
* to determine if the function has been regisitered with the user and
28
* therefor can be executed by the Worker.
30
* @return the name of the function.
35
* Some functions require a dataset upon which to operate. This method is
36
* used to load that data so that it is available when the function is
39
* @param data The data used by the function at execution time.
41
void setData(Object data);
44
* Set the handle of the job for which this function is executing.
46
* @param handle the job handle.
47
* @throws IllegalArgumentException if the handle is null or empty.
49
void setJobHandle(byte [] handle) throws IllegalArgumentException;
51
byte [] getJobHandle();
53
void registerEventListener(GearmanJobEventListener listener);
55
void fireEvent(GearmanPacket event);