CosmosFactory Class

  • java.lang.Object
    • com.azure.spring.data.cosmos.CosmosFactory

public class CosmosFactory

Factory class for CosmosDb to create client

Field Summary

Modifier and Type Field and Description
protected String databaseName

Database Name to be used for operations.

Constructor Summary

Constructor Description
CosmosFactory(CosmosAsyncClient cosmosAsyncClient, String databaseName)

Validate config and initialization

Method Summary

Modifier and Type Method and Description
static CosmosAsyncClient createCosmosAsyncClient(CosmosClientBuilder cosmosClientBuilder)

Create Cosmos Async Client

CosmosAsyncClient getCosmosAsyncClient()

To create a CosmosAsyncClient

String getDatabaseName()

Get Cosmos Database Name

String overrideContainerName()

This returns container name for each operation.

Methods inherited from java.lang.Object

Field Details

databaseName

protected String databaseName

Database Name to be used for operations. This is not practically tied to CosmosFactory instance. This can be updated even for same cosmosAsyncClient.

Constructor Details

CosmosFactory

public CosmosFactory(CosmosAsyncClient cosmosAsyncClient, String databaseName)

Validate config and initialization

Parameters:

cosmosAsyncClient - cosmosAsyncClient
databaseName - databaseName

Method Details

createCosmosAsyncClient

public static CosmosAsyncClient createCosmosAsyncClient(CosmosClientBuilder cosmosClientBuilder)

Create Cosmos Async Client

Parameters:

cosmosClientBuilder - CosmosClientBuilder

Returns:

CosmosAsyncClient

getCosmosAsyncClient

public CosmosAsyncClient getCosmosAsyncClient()

To create a CosmosAsyncClient

Returns:

CosmosAsyncClient

getDatabaseName

public String getDatabaseName()

Get Cosmos Database Name

Returns:

Cosmos Database Name

overrideContainerName

public String overrideContainerName()

This returns container name for each operation. By default, container name will be derived from entity definition. NOTE: Using this API will override container name defined on entity definition.

Returns:

container name

Applies to