Search in sources :

Example 1 with ConfigurationAdapterDescriptor

use of org.apache.knox.gateway.config.spi.ConfigurationAdapterDescriptor in project knox by apache.

the class ConfigurationAdapterFactory method loadAdapters.

private static void loadAdapters() {
    Map<Class<?>, Class<? extends ConfigurationAdapter>> all = new HashMap<>();
    ServiceLoader<ConfigurationAdapterDescriptor> loader = ServiceLoader.load(ConfigurationAdapterDescriptor.class);
    if (loader != null) {
        Iterator<ConfigurationAdapterDescriptor> i = loader.iterator();
        if (i != null) {
            while (i.hasNext()) {
                ConfigurationAdapterDescriptor descriptor = i.next();
                Map<Class<?>, Class<? extends ConfigurationAdapter>> add = descriptor.providedConfigurationAdapters();
                if (add != null) {
                    all.putAll(add);
                }
            }
        }
    }
    ADAPTERS = Collections.unmodifiableMap(all);
}
Also used : ConfigurationAdapter(org.apache.knox.gateway.config.ConfigurationAdapter) HashMap(java.util.HashMap) ConfigurationAdapterDescriptor(org.apache.knox.gateway.config.spi.ConfigurationAdapterDescriptor)

Example 2 with ConfigurationAdapterDescriptor

use of org.apache.knox.gateway.config.spi.ConfigurationAdapterDescriptor in project knox by apache.

the class BeanConfigurationAdapterDescriptorTest method testDescriptor.

@Test
public void testDescriptor() {
    ConfigurationAdapterDescriptor descriptor = new BeanConfigurationAdapterDescriptor();
    Map<Class<?>, Class<? extends ConfigurationAdapter>> map = descriptor.providedConfigurationAdapters();
    assertThat(map, hasKey((Class) Object.class));
    Class<? extends ConfigurationAdapter> type = map.get(Object.class);
    assertThat("Descriptor didn't return " + BeanConfigurationAdapter.class.getName(), type == BeanConfigurationAdapter.class);
}
Also used : ConfigurationAdapter(org.apache.knox.gateway.config.ConfigurationAdapter) ConfigurationAdapterDescriptor(org.apache.knox.gateway.config.spi.ConfigurationAdapterDescriptor) Test(org.junit.Test)

Aggregations

ConfigurationAdapter (org.apache.knox.gateway.config.ConfigurationAdapter)2 ConfigurationAdapterDescriptor (org.apache.knox.gateway.config.spi.ConfigurationAdapterDescriptor)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1