1 14 package org.wings; 15 16 import org.wings.resource.DynamicCodeResource; 17 import org.wings.resource.DynamicResource; 18 import org.wings.script.DynamicScriptResource; 19 import org.wings.style.DynamicStyleSheetResource; 20 21 import java.util.HashSet ; 22 import java.util.Iterator ; 23 import java.util.Set ; 24 25 31 public class DefaultReloadManager 32 implements ReloadManager { 33 private final transient static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("org.wings"); 34 38 protected final Set dirtyResources; 39 40 public DefaultReloadManager() { 41 dirtyResources = new HashSet (); 42 } 43 44 public void reload(SComponent component) { 45 SFrame parent = component.getParentFrame(); 46 47 if (parent == null) { 48 return; 49 } 50 51 markDirty(parent.getDynamicResource(DynamicCodeResource.class)); 52 markDirty(parent.getDynamicResource(DynamicStyleSheetResource.class)); 53 markDirty(parent.getDynamicResource(DynamicScriptResource.class)); 54 } 55 56 public synchronized void markDirty(DynamicResource d) { 57 if (d == null) { 58 log.warn("markDirty: null"); 59 return; 60 } 61 dirtyResources.add(d); 62 } 63 64 public Set getDirtyResources() { 65 return dirtyResources; 66 } 67 68 public synchronized void clear() { 69 dirtyResources.clear(); 70 } 71 72 public synchronized void invalidateResources() { 73 Iterator it = dirtyResources.iterator(); 75 while (it.hasNext()) { 76 DynamicResource resource = (DynamicResource) it.next(); 77 resource.invalidate(); 78 it.remove(); 79 } 80 } 81 } 82 83 84 | Popular Tags |