Search in sources :

Example 1 with ConnectionType

use of org.forgerock.openam.sm.datalayer.api.ConnectionType 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)

Example 2 with ConnectionType

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

the class CTSQueueConfigurationTest method setup.

@BeforeMethod
public void setup() throws InvalidConfigurationException {
    mockConfigFactory = mock(ConnectionConfigFactory.class);
    mockConfig = mock(ConnectionConfig.class);
    given(mockConfigFactory.getConfig(any(ConnectionType.class))).willReturn(mockConfig);
    LdapDataLayerConfiguration dataLayerConfiguration = mock(LdapDataLayerConfiguration.class);
    given(dataLayerConfiguration.getStoreMode()).willReturn(StoreMode.DEFAULT);
    Map<ConnectionType, LdapDataLayerConfiguration> configMap = mock(Map.class);
    given(configMap.get(anyObject())).willReturn(dataLayerConfiguration);
    config = new CTSQueueConfiguration(mockConfigFactory, mock(Debug.class));
}
Also used : ConnectionType(org.forgerock.openam.sm.datalayer.api.ConnectionType) LdapDataLayerConfiguration(org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration) ConnectionConfigFactory(org.forgerock.openam.sm.ConnectionConfigFactory) ConnectionConfig(org.forgerock.openam.sm.ConnectionConfig) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

ConnectionType (org.forgerock.openam.sm.datalayer.api.ConnectionType)2 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 ConnectionConfig (org.forgerock.openam.sm.ConnectionConfig)1 ConnectionConfigFactory (org.forgerock.openam.sm.ConnectionConfigFactory)1 DataLayerConnectionModule (org.forgerock.openam.sm.datalayer.api.DataLayerConnectionModule)1 LdapDataLayerConfiguration (org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration)1 ThreadSafeTokenIdGenerator (org.forgerock.openam.sm.datalayer.utils.ThreadSafeTokenIdGenerator)1 BeforeMethod (org.testng.annotations.BeforeMethod)1