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

sirius.kernel.async.BasicTaskContextAdapter Maven / Gradle / Ivy

Go to download

Provides common core classes and the microkernel powering all Sirius applications

There is a newer version: 12.9.1
Show newest version
/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package sirius.kernel.async;

/**
 * Default implementation for TaskContextAdapter
 */
public class BasicTaskContextAdapter implements TaskContextAdapter {

    protected volatile boolean cancelled = false;
    protected volatile boolean erroneous = false;
    protected String state;
    protected TaskContext ctx;

    /**
     * Creates a new BasicTaskContextAdapter for the given TaskContext.
     *
     * @param ctx the current task context for which this adapter is created
     */
    public BasicTaskContextAdapter(TaskContext ctx) {
        this.ctx = ctx;
    }

    @Override
    public void log(String message) {
        Tasks.LOG.INFO(ctx.getSystemString() + ": " + message);
    }

    @Override
    public void trace(String message) {
        if (Tasks.LOG.isFINE()) {
            Tasks.LOG.FINE(ctx.getSystemString() + ": " + message);
        }
    }

    @Override
    public void setState(String message) {
        this.state = message;
    }

    @Override
    public void markErroneous() {
        erroneous = true;
    }

    @Override
    public void cancel() {
        cancelled = true;
    }

    @Override
    public boolean isActive() {
        return !cancelled;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy