01: /*
02: * Created on 13-Feb-2006
03: */
04: package uk.org.ponder.rsf.flow.jsfnav;
05:
06: import java.util.List;
07: import java.util.Map;
08:
09: import uk.org.ponder.reflect.ReflectiveCache;
10:
11: /** Maintains an application-wide pool of navigation cases reported by views. This
12: * communicates with ViewProducers to receive any local definitions of NavigationCases
13: * that the views have generated, in order to ease the common case of single-step
14: * POSTS.
15: * <p>Note that for efficiency reasons, this class operate VERY SPECIFIC SEMANTICS
16: * on the contained objects.
17: * <p>Firstly, it will apply object identity by reference
18: * handle on the NavigationCase lists that it is supplied with - in the most
19: * common case that the navigation cases have not changed since the last time
20: * the ViewProducer was executed, this should be signalled by returning the
21: * SELFSAME list handle to this class, which will then be able to avoid blocking
22: * the ConcurrentHashMap it contains by issuing a write.
23: * <p>Secondly, and as a consequence, NavigationCase lists, once supplied to,
24: * or after delivered from this class, must NEVER be modified!! To change the
25: * stored lists, supply a different object handle.
26: * @author Antranig Basman (amb26@ponder.org.uk)
27: */
28:
29: public class NavigationCasePooler implements NavigationCaseReceiver {
30:
31: private Map pooledmap;
32:
33: public void setReflectiveCache(ReflectiveCache reflectivecache) {
34: pooledmap = reflectivecache.getConcurrentMap(1);
35: }
36:
37: public void receiveNavigationCases(String viewid,
38: List navigationCases) {
39: if (navigationCases != null) {
40: Object oldcases = pooledmap.get(viewid);
41: if (navigationCases != oldcases) {
42: pooledmap.put(viewid, navigationCases);
43: }
44: }
45: }
46:
47: public Map getPooledMap() {
48: return pooledmap;
49: }
50:
51: }
|