SQLProviderModule extends DefaultProviderModule implements HostInfoProvider, StateProvider { @Override protected void createPropertyProviders(Resource.Type type) { List<PropertyProvider> providers = new LinkedList<PropertyProvider>(); if (type.equals(Resource.Type.Component)) { providers.add(new JMXPropertyProvider( SCOMMetricHelper.getJMXPropertyIds(type), urlStreamProvider, this, this, PropertyHelper.getPropertyId("ServiceComponentInfo", "cluster_name"), null, PropertyHelper.getPropertyId("ServiceComponentInfo", "component_name"), PropertyHelper.getPropertyId("ServiceComponentInfo", "state"))); providers.add(new SQLPropertyProvider( SCOMMetricHelper.getSqlServerPropertyIds(type), this, PropertyHelper.getPropertyId("ServiceComponentInfo", "cluster_name"), null, PropertyHelper.getPropertyId("ServiceComponentInfo", "component_name"), PropertyHelper.getPropertyId("ServiceComponentInfo", "service_name"), connectionFactory)); } else if (type.equals(Resource.Type.HostComponent)) { providers.add(new JMXPropertyProvider( SCOMMetricHelper.getJMXPropertyIds(type), urlStreamProvider, this, this, PropertyHelper.getPropertyId("HostRoles", "cluster_name"), PropertyHelper.getPropertyId("HostRoles", "host_name"), PropertyHelper.getPropertyId("HostRoles", "component_name"), PropertyHelper.getPropertyId("HostRoles", "state"))); providers.add(new SQLPropertyProvider( SCOMMetricHelper.getSqlServerPropertyIds(type), this, PropertyHelper.getPropertyId("HostRoles", "cluster_name"), PropertyHelper.getPropertyId("HostRoles", "host_name"), PropertyHelper.getPropertyId("HostRoles", "component_name"), PropertyHelper.getPropertyId("HostRoles", "service_name"), connectionFactory)); } putPropertyProviders(type, providers); } SQLProviderModule(); @Override String getHostName(String clusterName, String componentName); @Override Set<String> getHostNames(String clusterName, String componentName); @Override String getHostName(String id); @Override String getHostAddress(String id); @Override State getRunningState(String hostName, String componentName); @Override Process setRunningState(String hostName, String componentName, State state);  }
@Test public void testCreatePropertyProviders() { SQLProviderModule providerModule = new SQLProviderModule(); providerModule.createPropertyProviders(Resource.Type.Component); List<PropertyProvider> providers = providerModule.getPropertyProviders(Resource.Type.Component); Assert.assertTrue(providers.get(0) instanceof JMXPropertyProvider); Assert.assertTrue(providers.get(1) instanceof SQLPropertyProvider); providerModule.createPropertyProviders(Resource.Type.HostComponent); providers = providerModule.getPropertyProviders(Resource.Type.HostComponent); Assert.assertTrue(providers.get(0) instanceof JMXPropertyProvider); Assert.assertTrue(providers.get(1) instanceof SQLPropertyProvider); }