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

com.geneea.celery.TaskRegistry Maven / Gradle / Ivy

Go to download

Java library for interfacing with http://celeryproject.org including code for both task submissions and task execution.

There is a newer version: 1.10.4
Show newest version
package com.geneea.celery;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Streams;

import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.function.Function;

/**
 * Loads registered {@link CeleryTask} services and provides them by their class name.
 */
class TaskRegistry {

    private static final Map TASKS = Streams
            .stream(ServiceLoader.load(CeleryTaskLoader.class))
            .map((loader) -> loader.loadTask())
            .collect(ImmutableMap.toImmutableMap((v) -> v.getClass().getName(), Function.identity()));

    static Set getRegisteredTaskNames() {
        return TASKS.keySet();
    }

    static Object getTask(String taskName) {
        return TASKS.get(taskName);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy