1 17 package org.apache.geronimo.deployment; 18 19 import java.util.Collections ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 import java.util.Set ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import javax.management.ObjectName ; 26 27 import org.apache.geronimo.gbean.GBeanData; 28 import org.apache.geronimo.gbean.GBeanName; 29 import org.apache.geronimo.kernel.GBeanNotFoundException; 30 31 34 public class GBeanDataRegistry { 35 private final Map registry = new HashMap (); 36 37 public void preregister(ObjectName name) { 38 registry.put(name, null); 39 } 40 41 public void register(GBeanData gbean) { 42 registry.put(gbean.getName(), gbean); 43 } 44 45 public synchronized GBeanData getGBeanInstance(ObjectName name) throws GBeanNotFoundException { 46 GBeanData gbeanData = (GBeanData) registry.get(name); 47 if (gbeanData == null) { 48 throw new GBeanNotFoundException(name.getCanonicalName()); 49 } 50 return gbeanData; 51 } 52 53 public Set getGBeanNames() { 54 return Collections.unmodifiableSet(registry.keySet()); 55 } 56 57 public GBeanData[] getGBeans() { 58 return (GBeanData[])registry.values().toArray(new GBeanData[registry.size()]); 59 } 60 61 62 public Set listGBeans(ObjectName pattern) { 63 Set result = new HashSet (); 64 for (Iterator i = registry.entrySet().iterator(); i.hasNext();) { 65 Map.Entry entry = (Map.Entry ) i.next(); 66 ObjectName name = (ObjectName ) entry.getKey(); 67 if (pattern.apply(name)) { 68 result.add(name); 69 } 70 } 71 return result; 72 } 73 } 74 | Popular Tags |