Boa noite,
Não estou conseguindo chamar meu método @Aspect no spring boot.
Adicionada as dependências e o @EnableAspectJAutoProxy na application.
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
@Aspect
@Component
@Transactional(propagation = Propagation.REQUIRED)
public class TenancyAspect {
@Autowired
private EntityManager manager;
@Before("execution(* br.com.app.repository.*.*(..))")
public void definirTenant() {
String tenantId = TenancyInterceptor.getTenantId();
if (tenantId != null) {
manager.unwrap(Session.class).enableFilter("tenant").setParameter("id", tenantId);
}
}
}