Search in sources :

Example 1 with ConfigurationMetadataProvider

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());
}
Also used : SimpleConfig(org.apache.sling.caconfig.it.example.SimpleConfig) ConfigurationMetadataProvider(org.apache.sling.caconfig.spi.ConfigurationMetadataProvider) ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 2 with ConfigurationMetadataProvider

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);
}
Also used : ConfigurationMetadataProvider(org.apache.sling.caconfig.spi.ConfigurationMetadataProvider) ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata)

Example 3 with ConfigurationMetadataProvider

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);
        }
    });
}
Also used : HashMap(java.util.HashMap) PropertyMetadata(org.apache.sling.caconfig.spi.metadata.PropertyMetadata) ConfigurationMetadataProvider(org.apache.sling.caconfig.spi.ConfigurationMetadataProvider) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) SortedSet(java.util.SortedSet) ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata)

Aggregations

ConfigurationMetadataProvider (org.apache.sling.caconfig.spi.ConfigurationMetadataProvider)3 ConfigurationMetadata (org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata)3 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 HashMap (java.util.HashMap)1 SortedSet (java.util.SortedSet)1 SimpleConfig (org.apache.sling.caconfig.it.example.SimpleConfig)1 PropertyMetadata (org.apache.sling.caconfig.spi.metadata.PropertyMetadata)1 Test (org.junit.Test)1