Search in sources :

Example 1 with DataLayerConnectionModule

use of org.forgerock.openam.sm.datalayer.api.DataLayerConnectionModule in project OpenAM by OpenRock.

the class DataLayerGuiceModule method configure.

@Override
protected void configure() {
    bind(TokenIdGenerator.class).to(ThreadSafeTokenIdGenerator.class);
    install(new FactoryModuleBuilder().implement(JavaBeanAdapter.class, JavaBeanAdapter.class).build(JavaBeanAdapterFactory.class));
    Key<Map<ConnectionType, LdapDataLayerConfiguration>> connectionMapKey = Key.get(new TypeLiteral<Map<ConnectionType, LdapDataLayerConfiguration>>() {
    });
    binder().bind(connectionMapKey).toProvider(ConfigurationMapProvider.class).in(Singleton.class);
    for (ConnectionType connectionType : ConnectionType.values()) {
        if (connectionType != ConnectionType.UMA_LABELS) {
            try {
                DataLayerConnectionModule module = connectionType.getConfigurationClass().newInstance();
                module.setConnectionType(connectionType);
                binder().install(module);
            } catch (Exception e) {
                throw new IllegalStateException("Could not initialise connection module for " + connectionType, e);
            }
        }
    }
}
Also used : DataLayerConnectionModule(org.forgerock.openam.sm.datalayer.api.DataLayerConnectionModule) TokenIdGenerator(org.forgerock.openam.cts.api.tokens.TokenIdGenerator) ThreadSafeTokenIdGenerator(org.forgerock.openam.sm.datalayer.utils.ThreadSafeTokenIdGenerator) JavaBeanAdapterFactory(org.forgerock.openam.cts.adapters.JavaBeanAdapterFactory) ConnectionType(org.forgerock.openam.sm.datalayer.api.ConnectionType) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JavaBeanAdapterFactory (org.forgerock.openam.cts.adapters.JavaBeanAdapterFactory)1 TokenIdGenerator (org.forgerock.openam.cts.api.tokens.TokenIdGenerator)1 ConnectionType (org.forgerock.openam.sm.datalayer.api.ConnectionType)1 DataLayerConnectionModule (org.forgerock.openam.sm.datalayer.api.DataLayerConnectionModule)1 ThreadSafeTokenIdGenerator (org.forgerock.openam.sm.datalayer.utils.ThreadSafeTokenIdGenerator)1