Project

General

Profile

« Previous | Next » 

Revision 49900

work in progress, the application starts

View differences:

VocabularyClient.java
5 5
import org.apache.commons.logging.Log;
6 6
import org.apache.commons.logging.LogFactory;
7 7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.cache.annotation.CacheEvict;
8 9
import org.springframework.cache.annotation.Cacheable;
9 10
import org.springframework.http.ResponseEntity;
10 11
import org.springframework.stereotype.Component;
......
23 24

  
24 25
	@Cacheable("vocabularies-cache")
25 26
	public Vocabulary getCountries() {
27
		return _getVocabulary(config.getVocabularies().getCountriesEndpoint(), Vocabulary.class);
28
	}
26 29

  
30
	@Cacheable("vocabularies-cache")
31
	public Vocabulary getDatasourceTypologies() {
32
		return _getVocabulary(config.getVocabularies().getDatasourceTypologiesEndpoint(), Vocabulary.class);
33
	}
34

  
35
	private <T> T _getVocabulary(final String endpoint, Class<T> clazz) {
27 36
		final RestTemplate rt = new RestTemplate();
28
		final String endpoint = config.getVocabularies().getCountriesEndpoint();
29
		log.info("get countries vocabulary from " + endpoint);
30
		final ResponseEntity<Vocabulary> rsp = rt.getForEntity(endpoint, Vocabulary.class);
31

  
37
		log.info("get vocabulary from " + endpoint);
38
		final ResponseEntity<T> rsp = rt.getForEntity(endpoint, clazz);
32 39
		return rsp.getBody();
33 40
	}
34 41

  
42
	@CacheEvict(cacheNames = "vocabularies-cache", allEntries = true)
43
	public void dropCache() {
44
		log.info("dropped dsManager vocabulary cache");
45
	}
46

  
35 47
}

Also available in: Unified diff