Revision 1c21abc1
Added by Andreas Kohlbecker about 4 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/service/TermServiceRequestExecutor.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.service; |
2 | 2 |
|
3 | 3 |
import java.util.HashMap; |
4 |
import java.util.HashSet; |
|
5 |
import java.util.List; |
|
6 | 4 |
import java.util.Map; |
7 |
import java.util.Set; |
|
8 | 5 |
|
9 | 6 |
import org.apache.log4j.Logger; |
10 |
import org.springframework.remoting.support.RemoteInvocation; |
|
11 | 7 |
import org.springframework.remoting.support.RemoteInvocationResult; |
12 | 8 |
|
13 | 9 |
import eu.etaxonomy.cdm.api.cache.CdmServiceCacher; |
14 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
15 | 10 |
import eu.etaxonomy.cdm.model.term.TermType; |
16 | 11 |
|
17 | 12 |
|
... | ... | |
26 | 21 |
cdmServiceCacher = csc; |
27 | 22 |
} |
28 | 23 |
|
29 |
@Override |
|
30 |
public void cache(RemoteInvocation ri, RemoteInvocationResult rir) { |
|
31 |
if(cdmServiceCacher != null) { |
|
32 |
if(ri.getMethodName().equals("listByTermType")) { |
|
33 |
if(ri.getArguments()[1] == null) { |
|
34 |
Set<DefinedTermBase<?>> terms = new HashSet<>(); |
|
35 |
if(rir.getValue() != null) { |
|
36 |
terms.addAll((List<DefinedTermBase<?>>)rir.getValue()); |
|
37 |
|
|
38 |
for(DefinedTermBase<?> term : terms) { |
|
39 |
cdmServiceCacher.load(term); |
|
40 |
} |
|
41 |
termTypeMap.put((TermType)ri.getArguments()[0], rir); |
|
42 |
} |
|
43 |
|
|
44 |
} |
|
45 |
} |
|
46 |
} else { |
|
47 |
logger.info("Default CdmServiceCacher is null. Cannot cache terms"); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public RemoteInvocationResult fromCache(RemoteInvocation ri) { |
|
53 |
return termTypeMap.get(ri.getArguments()[0]); |
|
54 |
} |
|
55 |
|
|
56 | 24 |
} |
Also available in: Unified diff
ref #8842 replacing caching in CdmServiceRequestExecutor by CachingHttpInvokerProxyFactoryBean to avoid having states