1   package com.trendmicro.grid.acl.ds.jpa;
2   
3   import com.trendmicro.grid.acl.ds.SourceRepository;
4   import com.trendmicro.grid.acl.ds.datatypes.SharedSource;
5   import com.trendmicro.grid.acl.ds.jpa.entities.JpaSource;
6   import com.trendmicro.grid.acl.l0.datatypes.SourceIdentifier;
7   import org.springframework.stereotype.Service;
8   
9   import javax.annotation.Resource;
10  import java.util.Collections;
11  
12  /**
13   * TODO: Create Description.
14   *
15   * @author juergen_kellerer, 2010-06-01
16   * @version 1.0
17   */
18  @Service
19  public class JpaSourceFetcher extends AbstractFetcher<SourceIdentifier, JpaSource, SourceRepository> {
20  
21  	@Resource
22  	JpaSourceRepository fallbackRepository;
23  
24  	public JpaSourceFetcher() {
25  		super(SourceRepository.class);
26  	}
27  
28  	@Override
29  	protected JpaSourceRepository getFallbackRepository() {
30  		return fallbackRepository;
31  	}
32  
33  	@Override
34  	protected SharedSource fetch(SourceRepository repository, SourceIdentifier key) {
35  		return repository.getSources(Collections.singleton(key)).iterator().next();
36  	}
37  }