1   package com.trendmicro.grid.acl.ds.cache.commands;
2   
3   import org.aspectj.lang.ProceedingJoinPoint;
4   
5   import java.util.Collection;
6   import java.util.Map;
7   import java.util.concurrent.atomic.AtomicLong;
8   
9   /**
10   * Returns the values of all keys asking the proceeding join point.
11   *
12   * @author juergen_kellerer, 2011-03-24
13   * @version 1.0
14   */
15  public class GetFromPJPSourceCommand<K, V> extends GetFromSourceCommand<K, V> {
16  
17  	private final ProceedingJoinPoint proceedingJoinPoint;
18  
19  	/**
20  	 * Creates the command.
21  	 *
22  	 * @param keys                the keys to look after.
23  	 * @param proceedingJoinPoint the wrapped delegate call.
24  	 */
25  	public GetFromPJPSourceCommand(AtomicLong fetchedKeyCount, Collection<K> keys, ProceedingJoinPoint proceedingJoinPoint) {
26  		super(fetchedKeyCount, keys);
27  		this.proceedingJoinPoint = proceedingJoinPoint;
28  	}
29  
30  	@Override
31  	public Map<K, V> doCall() throws Exception {
32  		try {
33  			@SuppressWarnings("unchecked")
34  			Collection<V> result = (Collection<V>) proceedingJoinPoint.proceed(new Object[]{keys});
35  			return new MapAdapter<K, V>(keys, result);
36  		} catch (Exception e) {
37  			throw e;
38  		} catch (Throwable throwable) {
39  			throw new Exception(throwable);
40  		}
41  	}
42  }