1 17 18 package org.apache.geronimo.console.util; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 import java.util.Set ; 23 24 import org.apache.geronimo.gbean.AbstractName; 25 import org.apache.geronimo.gbean.AbstractNameQuery; 26 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 27 import org.apache.geronimo.kernel.Kernel; 28 import org.apache.geronimo.kernel.KernelRegistry; 29 30 33 public final class ObjectNameConstants { 34 35 public static final AbstractName SE_REALM_MBEAN_NAME; 37 public static final AbstractName DEPLOYER_OBJECT_NAME; 38 39 static { 40 Kernel kernel = KernelRegistry.getSingleKernel(); 41 SE_REALM_MBEAN_NAME = getUniquename("PropertiesLoginManager", "GBean", kernel); 42 DEPLOYER_OBJECT_NAME = getUniquename("Deployer", "Deployer", kernel); 43 } 44 45 private static AbstractName getUniquename(String name, String type, Kernel kernel) { 46 Map properties = new HashMap (2); 47 properties.put(NameFactory.J2EE_NAME, name); 48 properties.put(NameFactory.J2EE_TYPE, type); 49 AbstractNameQuery query = new AbstractNameQuery(null, properties); 50 Set results = kernel.listGBeans(query); 51 if (results.isEmpty()) { 52 throw new RuntimeException ("No services found with name " + name + " and type " + type); 53 } 54 if (results.size() != 1) { 55 throw new RuntimeException ("More than one service was found with name " + name + " and type " + type + ", returns: " + results); 56 } 57 return (AbstractName) results.iterator().next(); 58 } 59 60 } 61 | Popular Tags |