For this tutorial, start two instances of the demo GUI. In this tutorial, we will:
- Attach a POJO to the cache and see it being replicated.
- Set a Collection attribute in this POJO
- Manipulate this Collection attribute and see the changes visible in the GUI and being replicated
- Detach a POJO from the cache.
- In the 1st GUI instance, create a POJO with a Collection attribute:
joe = new Person();
joe.setName("Joe Black");
lang = new ArrayList();
lang.add("Spanish");
joe.setLanguages(lang);
- Attach the POJO to the cache:
cache.attach("pojo/joe", joe);
- Get a proxy reference to the Collection and add a new element to it:
proxyLang = joe.getLanguages();
proxyLang.add("English");
- Detach the pojo from the cache:
cache.detach("pojo/joe");
- Use the proxy reference to the Collection to add another element and see how this does not get
added to the cache:
proxyLang.add("French");