All Downloads are FREE. Search and download functionalities are using the official Maven repository.

brooklyn.util.task.AbstractExecutionContext Maven / Gradle / Ivy

There is a newer version: 0.7.0-M1
Show newest version
package brooklyn.util.task;

import java.util.Map;
import java.util.concurrent.Callable;

import com.google.common.collect.Maps;

import brooklyn.management.ExecutionContext;
import brooklyn.management.ExecutionManager;
import brooklyn.management.Task;

public abstract class AbstractExecutionContext implements ExecutionContext {

    /**
     * Submits the given runnable/callable/task for execution (in a separate thread);
     * supported keys in the map include: tags (add'l tags to put on the resulting task), 
     * description (string), and others as described in the reference below
     *   
     * @see ExecutionManager#submit(Map, Task) 
     */
    public Task submit(Map properties, Runnable runnable) { return submitInternal(properties, runnable); }
    
    /** @see #submit(Map, Runnable) */
    public Task submit(Runnable runnable) { return submitInternal(Maps.newLinkedHashMap(), runnable); }
 
    /** @see #submit(Map, Runnable) */
    public  Task submit(Callable callable) { return submitInternal(Maps.newLinkedHashMap(), callable); }
    
    /** @see #submit(Map, Runnable) */
    public  Task submit(Map properties, Callable callable) { return submitInternal(properties, callable); }
 
    /** @see #submit(Map, Runnable) */
    public  Task submit(Task task) { return submitInternal(Maps.newLinkedHashMap(), task); }
    
    /** @see #submit(Map, Runnable) */
    public  Task submit(Map properties, Task task) { return submitInternal(properties, task); }

    /**
     * Provided for compatibility
     * 
     * Submit is preferred if a handle on the resulting Task is desired (although a task can be passed in so this is not always necessary) 
     *
     * @see #submit(Map, Runnable) 
     */
    public void execute(Runnable r) { submit(r); }

    protected abstract  Task submitInternal(Map properties, Object task);
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy