use of org.apache.sling.caconfig.spi.ConfigurationMetadataProvider in project sling by apache.
the class ConfigurationMetadataProviderIT method testConfigurationMetadata.
@Test
public void testConfigurationMetadata() {
ConfigurationMetadataProvider underTest = teleporter.getService(ConfigurationMetadataProvider.class);
ConfigurationMetadata configMetadata = underTest.getConfigurationMetadata(SimpleConfig.class.getName());
assertNotNull(configMetadata);
assertEquals(SimpleConfig.class.getName(), configMetadata.getName());
}
use of org.apache.sling.caconfig.spi.ConfigurationMetadataProvider in project sling by apache.
the class ConfigurationMetadataPrinter method printConfiguration.
@Override
public void printConfiguration(PrintWriter pw, ServiceReference<ConfigurationMetadataProvider> serviceReference, BundleContext bundleContext) {
ConfigurationMetadataProvider service = bundleContext.getService(serviceReference);
for (String configName : service.getConfigurationNames()) {
ConfigurationMetadata metadata = service.getConfigurationMetadata(configName);
pw.print(INDENT);
pw.print(BULLET);
pw.println(metadata.getName());
for (PropertyMetadata<?> property : metadata.getPropertyMetadata().values()) {
pw.print(INDENT_2);
pw.print(BULLET);
pw.print(property.getName());
pw.print("(");
pw.print(property.getType().getSimpleName());
pw.print(")");
if (property.getDefaultValue() != null) {
pw.print(" = ");
printValue(pw, property.getDefaultValue());
}
pw.println();
}
}
bundleContext.ungetService(serviceReference);
}
use of org.apache.sling.caconfig.spi.ConfigurationMetadataProvider in project sling by apache.
the class ConfigurationMetadataProviderMultiplexerImplTest method registerConfigurationMetadataProvider.
private void registerConfigurationMetadataProvider(String... names) {
final Map<String, ConfigurationMetadata> metadata = new HashMap<>();
for (String name : names) {
metadata.put(name, new ConfigurationMetadata(name, ImmutableList.<PropertyMetadata<?>>of(), false));
}
context.registerService(ConfigurationMetadataProvider.class, new ConfigurationMetadataProvider() {
@Override
public SortedSet<String> getConfigurationNames() {
return new TreeSet<>(metadata.keySet());
}
@Override
public ConfigurationMetadata getConfigurationMetadata(String configName) {
return metadata.get(configName);
}
});
}
Aggregations