com.transferwise.tasks.entrypoints.EntryPointsService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-tasks-core Show documentation
Show all versions of tw-tasks-core Show documentation
Transferwise Tasks Executor - Fire and forget until Alert.
The newest version!
package com.transferwise.tasks.entrypoints;
import com.transferwise.common.context.TwContext;
import com.transferwise.common.context.UnitOfWorkManager;
import java.util.function.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
public class EntryPointsService implements IEntryPointsService {
@Autowired
private UnitOfWorkManager unitOfWorkManager;
@Override
public T continueOrCreate(String group, String name, Supplier supplier) {
if (TwContext.current().isEntryPoint()) {
return supplier.get();
}
return unitOfWorkManager.createEntryPoint(group, name).toContext().execute(supplier);
}
}