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

com.transferwise.tasks.entrypoints.EntryPointsService Maven / Gradle / Ivy

There is a newer version: 1.43.0
Show 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;

  @Autowired
  private MdcService mdcService;

  @Override
  public  T continueOrCreate(String group, String name, Supplier supplier) {
    if (TwContext.current().isEntryPoint()) {
      return mdcService.with(() -> supplier.get());
    }

    return createEntrypoint(group, name, supplier);
  }

  @Override
  public  T createEntrypoint(String group, String name, Supplier supplier) {
    return unitOfWorkManager.createEntryPoint(group, name).toContext().execute(mdcService.with(() -> supplier));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy