@Override public Object invoke(FederatedServiceCollection collection, Method method, Object[] args) throws ServiceException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (args.length == 0) { throw new ServiceException("unexpected number of arguments"); } SituationQueryBean query = (SituationQueryBean) args[0]; Set<String> agencyIds = new HashSet<String>(); if (query.getAffects() != null) { for (SituationQueryBean.AffectsBean affects : query.getAffects()) { if (affects.getAgencyId() != null) { agencyIds.add(affects.getAgencyId()); } addAgencyId(affects.getRouteId(), agencyIds); addAgencyId(affects.getTripId(), agencyIds); addAgencyId(affects.getStopId(), agencyIds); } } FederatedService service = collection.getServiceForAgencyIds(agencyIds); return method.invoke(service, args); }