org.keycloak.connections.mongo

## Class DefaultMongoConnectionFactoryProvider

- java.lang.Object
- - org.keycloak.connections.mongo.DefaultMongoConnectionFactoryProvider

- All Implemented Interfaces:
    MongoConnectionProviderFactory, ProviderFactory<MongoConnectionProvider>, ServerInfoAwareProviderFactory

      public class DefaultMongoConnectionFactoryProvider
      extends Object
      implements MongoConnectionProviderFactory, ServerInfoAwareProviderFactory

  Author:
    Stian Thorgersen

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Config.Scope` | `config`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultMongoConnectionFactoryProvider()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkBooleanOption(String optionName, com.mongodb.MongoClientOptions.Builder builder)`
    `protected void` | `checkIntOption(String optionName, com.mongodb.MongoClientOptions.Builder builder)`
    `void` | `close()` This is called when the server shuts down.
    `MongoConnectionProvider` | `create(KeycloakSession session)`
    `protected com.mongodb.MongoClient` | `createMongoClient()` Override this method if you want more possibility to configure Mongo client.
    `protected com.mongodb.MongoClientOptions` | `getClientOptions()`
    `com.mongodb.DB` | `getDBBeforeUpdate()`
    `String` | `getId()`
    `Map<String,String>` | `getOperationalInfo()` Return actual info about the provider.
    `void` | `init(Config.Scope config)` Only called once when the factory is first created.
    `void` | `postInit(KeycloakSessionFactory factory)` Called after all provider factories have been initialized
    `protected void` | `updateOrValidateDB(String databaseSchema, KeycloakSession session, MongoUpdaterProvider mongoUpdater)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### config

          protected Config.Scope config

  - ### Constructor Detail

    - #### DefaultMongoConnectionFactoryProvider

          public DefaultMongoConnectionFactoryProvider()

  - ### Method Detail

    - #### init

          public void init(Config.Scope config)

      Description copied from interface: `ProviderFactory`
      Only called once when the factory is first created. This config is pulled from keycloak_server.json
      Specified by:
        `init` in interface `ProviderFactory<MongoConnectionProvider>`

    - #### postInit

          public void postInit(KeycloakSessionFactory factory)

      Description copied from interface: `ProviderFactory`
      Called after all provider factories have been initialized
      Specified by:
        `postInit` in interface `ProviderFactory<MongoConnectionProvider>`

    - #### getDBBeforeUpdate

          public com.mongodb.DB getDBBeforeUpdate()

      Specified by:
        `getDBBeforeUpdate` in interface `MongoConnectionProviderFactory`
      Returns:
        DB object, which may not be yet updated to current Keycloak version. Useful just if something needs to be done even before DB update (for example acquire DB lock)

    - #### create

          public MongoConnectionProvider create(KeycloakSession session)

      Specified by:
        `create` in interface `ProviderFactory<MongoConnectionProvider>`

    - #### updateOrValidateDB

          protected void updateOrValidateDB(String databaseSchema,
                                            KeycloakSession session,
                                            MongoUpdaterProvider mongoUpdater)

    - #### close

          public void close()

      Description copied from interface: `ProviderFactory`
      This is called when the server shuts down.
      Specified by:
        `close` in interface `ProviderFactory<MongoConnectionProvider>`

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `ProviderFactory<MongoConnectionProvider>`

    - #### createMongoClient

          protected com.mongodb.MongoClient createMongoClient()
                                                       throws UnknownHostException

      Override this method if you want more possibility to configure Mongo client. It can be also used to inject mongo client from different source. This method can assume that "config" is already set and can use it.
      Returns:
        mongoClient instance, which will be shared for whole Keycloak
      Throws:
        `UnknownHostException`

    - #### getClientOptions

          protected com.mongodb.MongoClientOptions getClientOptions()

    - #### checkBooleanOption

          protected void checkBooleanOption(String optionName,
                                            com.mongodb.MongoClientOptions.Builder builder)

    - #### checkIntOption

          protected void checkIntOption(String optionName,
                                        com.mongodb.MongoClientOptions.Builder builder)

    - #### getOperationalInfo

          public Map<String,String> getOperationalInfo()

      Description copied from interface: `ServerInfoAwareProviderFactory`
      Return actual info about the provider. This info contains informations about providers configuration and operational conditions (eg. errors in connection to remote systems etc) which is shown on "Server Info" page then.
      Specified by:
        `getOperationalInfo` in interface `ServerInfoAwareProviderFactory`
      Returns:
        Map with keys describing value and relevant values itself

Copyright © 2016 JBoss by Red Hat. All rights reserved.