Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public interface TaskDecorator

Wraps every task an executor runs, as Spring’s does: the place to carry something from the submitting thread – a tenant, a trace, a security principal – to the one that runs the task, and to clear it afterwards.

Tasks.executor("mail").setTaskDecorator(new TaskDecorator() {
    public Runnable decorate(final Runnable task) {
        final String tenant = Tenant.current();
        return new Runnable() {
            public void run() {
                Tenant.set(tenant);
                try {
                    task.run();
                } finally {
                    Tenant.clear();
                }
            }
        };
    }
});

Methods

public abstract Runnable decorate(Runnable task)The runnable to run in place of task, called on the submitting thread.

Method details

decorate

public abstract Runnable decorate(Runnable task)
The runnable to run in place of task, called on the submitting thread.

Parameters

task Runnable
the task as submitted

Returns

what the executor runs; returning task leaves it as it is