1 29 30 package nextapp.echo2.webcontainer; 31 32 import java.util.HashMap ; 33 import java.util.Map ; 34 35 import nextapp.echo2.app.update.ServerComponentUpdate; 36 37 41 public class PartialUpdateManager { 42 43 47 private Map registry = null; 48 49 55 public void add(String propertyName, PartialUpdateParticipant updateParticipant) { 56 if (registry == null) { 57 registry = new HashMap (); 58 } 59 registry.put(propertyName, updateParticipant); 60 } 61 62 71 public boolean canProcess(RenderContext rc, ServerComponentUpdate update) { 72 if (registry == null) { 73 return false; 74 } 75 String [] propertyNames = update.getUpdatedPropertyNames(); 76 for (int i = 0; i < propertyNames.length; ++i) { 77 PartialUpdateParticipant propertyRender = (PartialUpdateParticipant) registry.get(propertyNames[i]); 78 if (propertyRender == null) { 79 return false; 80 } else if (!propertyRender.canRenderProperty(rc, update)) { 81 return false; 82 } 83 } 84 return true; 85 } 86 87 95 public void process(RenderContext rc, ServerComponentUpdate update) { 96 String [] propertyNames = update.getUpdatedPropertyNames(); 97 for (int i = 0; i < propertyNames.length; ++i) { 98 PartialUpdateParticipant propertyRender = (PartialUpdateParticipant) registry.get(propertyNames[i]); 99 if (propertyRender == null) { 100 continue; 102 } 103 propertyRender.renderProperty(rc, update); 104 } 105 } 106 } 107 | Popular Tags |