1 57 58 package org.apache.commons.discovery.resource.names; 59 60 import java.util.Vector ; 61 62 import org.apache.commons.discovery.ResourceNameDiscover; 63 import org.apache.commons.discovery.ResourceNameListener; 64 import org.apache.commons.discovery.log.DiscoveryLogFactory; 65 import org.apache.commons.logging.Log; 66 67 68 75 public class NameDiscoverers extends ResourceNameDiscoverImpl 76 implements ResourceNameDiscover, ResourceNameListener 77 { 78 private static Log log = DiscoveryLogFactory.newLog(NameDiscoverers.class); 79 public static void setLog(Log _log) { 80 log = _log; 81 } 82 83 private Vector discoverers = new Vector (); 85 88 public NameDiscoverers() { 89 } 90 91 96 public void addResourceNameDiscover(ResourceNameDiscover discover) { 97 if (discover != null) { 98 discover.setListener(getListener()); 99 discoverers.addElement(discover); 100 } 101 } 102 103 public void setListener(ResourceNameListener listener) { 104 super.setListener(listener); 105 for (int i = 0; i < discoverers.size(); i++) { 106 ((ResourceNameDiscover)discoverers.get(i)).setListener(listener); 107 } 108 } 109 110 protected ResourceNameDiscover getResourceNameDiscover(int idx) { 111 return (ResourceNameDiscover)discoverers.get(idx); 112 } 113 114 protected int size() { 115 return discoverers.size(); 116 } 117 118 123 public boolean find(String resourceName) { 124 if (log.isDebugEnabled()) 125 log.debug("find: resourceName='" + resourceName + "'"); 126 127 for (int i = 0; i < discoverers.size(); i++) { 128 if (!((ResourceNameDiscover)discoverers.get(i)).find(resourceName)) { 129 return false; 130 } 131 } 132 return true; 133 } 134 135 public boolean found(String resourceName) { 136 return find(resourceName); 137 } 138 } 139 | Popular Tags |