public static <T extends ServiceConfiguration> Iterable<ServiceConfiguration> filter( final Predicate<T> pred) throws PersistenceException { List<ServiceConfiguration> configs = Lists.newArrayList(); for (ComponentId compId : ComponentIds.list()) { Iterables.addAll(configs, filter(compId.getClass(), pred)); } return configs; }
public static ServiceConfiguration createBogus( final Class<? extends ComponentId> compIdClass, final Class<?> ownerType) { ComponentId compId = ComponentIds.lookup(compIdClass); return new EphemeralConfiguration( compId, compId.getPartition(), ownerType.getCanonicalName(), ServiceUris.internal(compId, Internets.localHostInetAddress(), ownerType.getSimpleName())); }
public static <T extends ServiceConfiguration> T lookupByName(final String name) { for (ComponentId c : ComponentIds.list()) { ServiceConfiguration example = ServiceBuilders.lookup(c.getClass()).newInstance(); example.setName(name); try { return (T) lookup(example); } catch (Exception ex) { } } throw new NoSuchElementException( "Failed to lookup any registered component with the name: " + name); }