0
We have a web service that one of its parameters is called source and this source is always validated against a code in the database.
For each of our services, I have to validate this code. This code doesn’t change, so I want to keep it in a constant, but I still have to validate it to prevent customers from sending a wrong code.
Basically, what I want is this:
@Service
public class Service {
    @Autowired
    private LogBS logBS;
    // Eu sei que a palavra reservada "this" não pode ser utilizada em contexto estático.
    public static final Long CODIGO_LOG_WEB_SERVICE = this.logBS.recuperarCodigoLogWebService("webServiceName");
    public void validarCodigoOrigem(final Long origem) {
        if (!origem.equals(CODIGO_LOG_WEB_SERVICE)) {
            throw new ServiceException("Código de web service errado!");
        }
    }
}
I know something similar can be done with Spring cache, but it is possible to do it with a constant?