1 23 package com.sun.enterprise.web.connector.grizzly; 24 25 import java.util.Iterator ; 26 import java.util.concurrent.ConcurrentHashMap ; 27 import java.util.concurrent.ConcurrentLinkedQueue ; 28 29 import com.sun.enterprise.web.connector.grizzly.FileCache.FileCacheEntry; 30 import org.apache.catalina.Container; 31 import org.apache.catalina.ContainerEvent; 32 import org.apache.catalina.ContainerListener; 33 import org.apache.catalina.Context; 34 import org.apache.catalina.Host; 35 36 42 public class CatalinaListener implements ContainerListener{ 43 44 public void containerEvent(ContainerEvent event) { 45 if (Container.REMOVE_CHILD_EVENT.equals(event.getType()) ) { 46 Context context; 47 String contextPath; 48 Host host; 49 50 Object container = event.getData(); 51 if ( container instanceof Context) { 52 context = (Context)container; 53 54 if ( context != null 55 && context.findConstraints().length == 0 56 && context.findFilterDefs().length == 0 ){ 57 58 contextPath = context.getPath(); 59 host = (Host)context.getParent(); 60 int[] ports = host.getPorts(); 61 for (int i=0; i < ports.length; i++){ 62 removeContextPath(ports[i],contextPath); 63 } 64 } 65 } 66 } 67 } 68 69 70 76 private void removeContextPath(int port, String contextPath) { 77 FileCacheFactory fileCacheFactory = FileCacheFactory.getFactory(port); 78 ConcurrentHashMap <String ,FileCacheEntry> 79 cachedEntries = fileCacheFactory.getCache(); 80 81 if ( cachedEntries == null){ 82 return; 83 } 84 85 Iterator <String > iterator = cachedEntries.keySet().iterator(); 86 String cachedPath; 87 while (iterator.hasNext()){ 88 cachedPath = iterator.next(); 89 if ( cachedPath.startsWith(contextPath) ){ 90 cachedEntries.remove(cachedPath).run(); 91 } 92 } 93 } 94 } 95 96 | Popular Tags |