@Test public void testListNames() throws ListProviderException { assertEquals(3, servicesListProvider.getList("", servicesQuery).size()); assertEquals(3, servicesListProvider.getList(ServicesListProvider.LIST_NAME, servicesQuery).size()); assertEquals(3, servicesListProvider.getList(ServicesListProvider.LIST_STATUS, servicesQuery).size()); }
@Override public Map<String, String> getList(String listName, ResourceListQuery query) throws ListProviderException { ServicesListQuery servicesQuery; try { servicesQuery = (ServicesListQuery) query; } catch (ClassCastException ex) { servicesQuery = new ServicesListQuery(query); } Map<String, String> result = new HashMap<String,String>(); if (LIST_STATUS.equals(listName)) { for (ServiceState s : ServiceState.values()) { result.put(s.toString(), SERVICE_STATUS_FILTER_PREFIX + s.toString()); } return result; } List<ServiceRegistration> serviceRegistrations; try { serviceRegistrations = serviceRegistry.getServiceRegistrations(); } catch (ServiceRegistryException ex) { throw new ListProviderException("Failed to get service registrations.", ex); } for (ServiceRegistration serviceRegistration : serviceRegistrations) { if (servicesQuery.getHostname().isSome() && !StringUtils.equals(servicesQuery.getHostname().get(), serviceRegistration.getHost())) continue; if (servicesQuery.getActions().isSome() && servicesQuery.getActions().get() && serviceRegistration.getServiceState() == ServiceState.NORMAL) continue; result.put(serviceRegistration.getServiceType(), serviceRegistration.getServiceType()); } if (servicesQuery.getLimit().isSome() || servicesQuery.getLimit().isSome()) { int limit = servicesQuery.getLimit().getOrElse(0); int offset = servicesQuery.getOffset().getOrElse(0); result = new SmartIterator(limit, offset).applyLimitAndOffset(result); } return result; }
ServicesListProvider implements ResourceListProvider { @Override public Map<String, String> getList(String listName, ResourceListQuery query) throws ListProviderException { ServicesListQuery servicesQuery; try { servicesQuery = (ServicesListQuery) query; } catch (ClassCastException ex) { servicesQuery = new ServicesListQuery(query); } Map<String, String> result = new HashMap<String,String>(); if (LIST_STATUS.equals(listName)) { for (ServiceState s : ServiceState.values()) { result.put(s.toString(), SERVICE_STATUS_FILTER_PREFIX + s.toString()); } return result; } List<ServiceRegistration> serviceRegistrations; try { serviceRegistrations = serviceRegistry.getServiceRegistrations(); } catch (ServiceRegistryException ex) { throw new ListProviderException("Failed to get service registrations.", ex); } for (ServiceRegistration serviceRegistration : serviceRegistrations) { if (servicesQuery.getHostname().isSome() && !StringUtils.equals(servicesQuery.getHostname().get(), serviceRegistration.getHost())) continue; if (servicesQuery.getActions().isSome() && servicesQuery.getActions().get() && serviceRegistration.getServiceState() == ServiceState.NORMAL) continue; result.put(serviceRegistration.getServiceType(), serviceRegistration.getServiceType()); } if (servicesQuery.getLimit().isSome() || servicesQuery.getLimit().isSome()) { int limit = servicesQuery.getLimit().getOrElse(0); int offset = servicesQuery.getOffset().getOrElse(0); result = new SmartIterator(limit, offset).applyLimitAndOffset(result); } return result; } }
ServicesListProvider implements ResourceListProvider { @Override public Map<String, String> getList(String listName, ResourceListQuery query) throws ListProviderException { ServicesListQuery servicesQuery; try { servicesQuery = (ServicesListQuery) query; } catch (ClassCastException ex) { servicesQuery = new ServicesListQuery(query); } Map<String, String> result = new HashMap<String,String>(); if (LIST_STATUS.equals(listName)) { for (ServiceState s : ServiceState.values()) { result.put(s.toString(), SERVICE_STATUS_FILTER_PREFIX + s.toString()); } return result; } List<ServiceRegistration> serviceRegistrations; try { serviceRegistrations = serviceRegistry.getServiceRegistrations(); } catch (ServiceRegistryException ex) { throw new ListProviderException("Failed to get service registrations.", ex); } for (ServiceRegistration serviceRegistration : serviceRegistrations) { if (servicesQuery.getHostname().isSome() && !StringUtils.equals(servicesQuery.getHostname().get(), serviceRegistration.getHost())) continue; if (servicesQuery.getActions().isSome() && servicesQuery.getActions().get() && serviceRegistration.getServiceState() == ServiceState.NORMAL) continue; result.put(serviceRegistration.getServiceType(), serviceRegistration.getServiceType()); } if (servicesQuery.getLimit().isSome() || servicesQuery.getLimit().isSome()) { int limit = servicesQuery.getLimit().getOrElse(0); int offset = servicesQuery.getOffset().getOrElse(0); result = new SmartIterator(limit, offset).applyLimitAndOffset(result); } return result; }  }
ServicesListProvider implements ResourceListProvider { @Override public Map<String, String> getList(String listName, ResourceListQuery query) throws ListProviderException { ServicesListQuery servicesQuery; try { servicesQuery = (ServicesListQuery) query; } catch (ClassCastException ex) { servicesQuery = new ServicesListQuery(query); } Map<String, String> result = new HashMap<String,String>(); if (LIST_STATUS.equals(listName)) { for (ServiceState s : ServiceState.values()) { result.put(s.toString(), SERVICE_STATUS_FILTER_PREFIX + s.toString()); } return result; } List<ServiceRegistration> serviceRegistrations; try { serviceRegistrations = serviceRegistry.getServiceRegistrations(); } catch (ServiceRegistryException ex) { throw new ListProviderException("Failed to get service registrations.", ex); } for (ServiceRegistration serviceRegistration : serviceRegistrations) { if (servicesQuery.getHostname().isSome() && !StringUtils.equals(servicesQuery.getHostname().get(), serviceRegistration.getHost())) continue; if (servicesQuery.getActions().isSome() && servicesQuery.getActions().get() && serviceRegistration.getServiceState() == ServiceState.NORMAL) continue; result.put(serviceRegistration.getServiceType(), serviceRegistration.getServiceType()); } if (servicesQuery.getLimit().isSome() || servicesQuery.getLimit().isSome()) { int limit = servicesQuery.getLimit().getOrElse(0); int offset = servicesQuery.getOffset().getOrElse(0); result = new SmartIterator(limit, offset).applyLimitAndOffset(result); } return result; }  @Override String[] getListNames(); @Override Map<String, String> getList(String listName, ResourceListQuery query); void setServiceRegistry(ServiceRegistry serviceRegistry); @Override boolean isTranslatable(String listName); @Override String getDefault(); }
ServicesListProvider implements ResourceListProvider { @Override public Map<String, String> getList(String listName, ResourceListQuery query) throws ListProviderException { ServicesListQuery servicesQuery; try { servicesQuery = (ServicesListQuery) query; } catch (ClassCastException ex) { servicesQuery = new ServicesListQuery(query); } Map<String, String> result = new HashMap<String,String>(); if (LIST_STATUS.equals(listName)) { for (ServiceState s : ServiceState.values()) { result.put(s.toString(), SERVICE_STATUS_FILTER_PREFIX + s.toString()); } return result; } List<ServiceRegistration> serviceRegistrations; try { serviceRegistrations = serviceRegistry.getServiceRegistrations(); } catch (ServiceRegistryException ex) { throw new ListProviderException("Failed to get service registrations.", ex); } for (ServiceRegistration serviceRegistration : serviceRegistrations) { if (servicesQuery.getHostname().isSome() && !StringUtils.equals(servicesQuery.getHostname().get(), serviceRegistration.getHost())) continue; if (servicesQuery.getActions().isSome() && servicesQuery.getActions().get() && serviceRegistration.getServiceState() == ServiceState.NORMAL) continue; result.put(serviceRegistration.getServiceType(), serviceRegistration.getServiceType()); } if (servicesQuery.getLimit().isSome() || servicesQuery.getLimit().isSome()) { int limit = servicesQuery.getLimit().getOrElse(0); int offset = servicesQuery.getOffset().getOrElse(0); result = new SmartIterator(limit, offset).applyLimitAndOffset(result); } return result; }  @Override String[] getListNames(); @Override Map<String, String> getList(String listName, ResourceListQuery query); void setServiceRegistry(ServiceRegistry serviceRegistry); @Override boolean isTranslatable(String listName); @Override String getDefault(); static final String LIST_NAME; static final String LIST_STATUS; static final String SERVICE_STATUS_FILTER_PREFIX; }