private <T> ObjectName getObjectNameForInterface(String type, String alias, Class<T> controlInterface) { try { Set<ObjectName> names = getObjectNamesForInterface(type, alias, controlInterface.getName()); if (names.isEmpty()) return null; if (names.size() != 1) throw new RuntimeException("Alias " + alias + " not unique for type " + type); ObjectName name = null; for (ObjectName on : names) { name = on; break; } return name; } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } }