public abstract class AbstractManagerFactoryBuilder<T extends AbstractManagerFactoryBuilder<T>> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Cluster |
cluster |
protected ConfigMap |
configMap |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractManagerFactoryBuilder(Cluster cluster) |
| Modifier and Type | Method and Description |
|---|---|
abstract <M extends AbstractManagerFactory> |
build() |
protected static ConfigurationContext |
buildConfigContext(Cluster cluster,
ConfigMap configMap) |
T |
doForceSchemaCreation(boolean forceSchemaCreation)
Whether Achilles should force table creation if they do not already
exist in the keyspace This flag is useful for dev only.
|
protected abstract T |
getThis() |
T |
validateSchema(boolean validateSchema)
Whether Achilles should validate the schema generated by the java classes/annotations with the live schema of the cluster.
|
T |
withBeanValidation(boolean enableBeanValidation)
Activate Bean Validation (JSR303)
|
T |
withBeanValidator(javax.validation.Validator validator)
Provide custom validator for Bean Validation (JSR303)
|
T |
withDefaultExecutorService(ExecutorService executorService)
Pass an ExecutorService (ThreadPool) to Achilles to be used internally for asynchronous operations.
|
T |
withDefaultKeyspaceName(String defaultKeyspaceName)
Define the keyspace name to be used by Achilles.
|
T |
withDefaultReadConsistency(ConsistencyLevel defaultReadConsistency)
Define the default Consistency level to be used for all READ
operations
|
T |
withDefaultReadConsistencyMap(Map<String,ConsistencyLevel> readConsistencyMap)
Define the default Consistency level map to be used for all READ
operations The map keys represent table names and values represent
the corresponding consistency level
|
T |
withDefaultSerialConsistency(ConsistencyLevel defaultSerialConsistency)
Define the default Consistency level to be used for all LightWeightTransaction operations
operations
|
T |
withDefaultSerialConsistencyMap(Map<String,ConsistencyLevel> serialConsistencyMap)
Define the default Consistency level map to be used for all LightWeightTransaction operations
operations The map keys represent table names and values represent
the corresponding consistency level
|
T |
withDefaultWriteConsistency(ConsistencyLevel defaultWriteConsistency)
Define the default Consistency level to be used for all WRITE
operations
|
T |
withDefaultWriteConsistencyMap(Map<String,ConsistencyLevel> writeConsistencyMap)
Define the default Consistency level map to be used for all WRITE
operations The map keys represent table names and values represent
the corresponding consistency level
|
T |
withEventInterceptors(List<info.archinnov.achilles.type.interceptor.Interceptor<?>> interceptors)
Provide a list of event interceptors
|
T |
withExecutorServiceMaxThreadCount(int maxThreadCount)
Define the max thread count for the ExecutorService (ThreadPool) to be used internally for asynchronous operations.
|
T |
withExecutorServiceMinThreadCount(int minThreadCount)
Define the min thread count for the ExecutorService (ThreadPool) to be used internally for asynchronous operations.
|
T |
withExecutorServiceThreadFactory(ThreadFactory factory)
Define the Thread Factory for the ExecutorService (ThreadPool) to be used internally for asynchronous operations.
|
T |
withExecutorServiceThreadKeepAliveDuration(int keepAliveDuration)
Define the thread keep-alive duration in second for the ExecutorService (ThreadPool) to be used internally for asynchronous operations.
|
T |
withExecutorServiceThreadQueueSize(int threadQueueSize)
Define the LinkedBlockingQueue size for the ExecutorService (ThreadPool) to be used internally for asynchronous operations.
|
T |
withGlobalInsertStrategy(info.archinnov.achilles.type.strategy.InsertStrategy globalInsertStrategy)
Define the global insert strategy
|
T |
withJacksonMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Define a pre-configured Jackson Object Mapper for serialization of
non-primitive types
|
T |
withJacksonMapperFactory(JacksonMapperFactory jacksonMapperFactory)
Define a pre-configured map of Jackson Object Mapper for
serialization of non-primitive types
|
T |
withManagedEntityClasses(Class<?>... entityClasses)
Define a list of entities to be managed by Achilles.
|
T |
withManagedEntityClasses(List<Class<?>> entityClasses)
Define a list of entities to be managed by Achilles.
|
T |
withMaxDMLResultsDisplayed(int maxDMLResultsDisplayed)
Specify how many returned rows to be displayed if ACHILLES_DML_STATEMENT logger or entity logger is debug-enabled.
|
T |
withMaxPreparedStatementCacheSize(int maxPreparedStatementCacheSize)
Specify maximum size for the internal prepared statements LRU cache.
|
T |
withNativeSession(Session nativeSession)
Define the pre-configured
com.datastax.driver.core.Session object to
be used instead of creating a new one |
T |
withParameter(ConfigurationParameters parameter,
Object value)
Pass an arbitrary parameter to configure Achilles
|
T |
withPostLoadBeanValidation(boolean enablePostLoadBeanValidation)
Activate Bean Validation (JSR303)
|
<FROM,TO> T |
withRuntimeCodec(info.archinnov.achilles.type.codec.CodecSignature<FROM,TO> codecSignature,
info.archinnov.achilles.type.codec.Codec<FROM,TO> codec)
Specify a runtime codec to register with Achilles
|
T |
withRuntimeCodecs(Map<info.archinnov.achilles.type.codec.CodecSignature<?,?>,info.archinnov.achilles.type.codec.Codec<?,?>> runtimeCodecs)
Specify runtime codecs to register with Achilles
|
T |
withSchemaNameProvider(info.archinnov.achilles.type.SchemaNameProvider schemaNameProvider)
Define the schema name provider to be used instead of default keyspace/table names
|
T |
withStatementsCache(StatementsCache statementsCache)
Define the statements cache object to be used for prepared statements.
|
protected AbstractManagerFactoryBuilder(Cluster cluster)
protected static ConfigurationContext buildConfigContext(Cluster cluster, ConfigMap configMap)
protected abstract T getThis()
public abstract <M extends AbstractManagerFactory> M build()
public T withJacksonMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public T withJacksonMapperFactory(JacksonMapperFactory jacksonMapperFactory)
public T withDefaultReadConsistency(ConsistencyLevel defaultReadConsistency)
public T withDefaultWriteConsistency(ConsistencyLevel defaultWriteConsistency)
public T withDefaultSerialConsistency(ConsistencyLevel defaultSerialConsistency)
public T withDefaultReadConsistencyMap(Map<String,ConsistencyLevel> readConsistencyMap)
public T withDefaultWriteConsistencyMap(Map<String,ConsistencyLevel> writeConsistencyMap)
public T withDefaultSerialConsistencyMap(Map<String,ConsistencyLevel> serialConsistencyMap)
public T doForceSchemaCreation(boolean forceSchemaCreation)
public T validateSchema(boolean validateSchema)
public T withNativeSession(Session nativeSession)
com.datastax.driver.core.Session object to
be used instead of creating a new onepublic T withDefaultKeyspaceName(String defaultKeyspaceName)
public T withEventInterceptors(List<info.archinnov.achilles.type.interceptor.Interceptor<?>> interceptors)
public T withBeanValidation(boolean enableBeanValidation)
public T withPostLoadBeanValidation(boolean enablePostLoadBeanValidation)
public T withBeanValidator(javax.validation.Validator validator)
public T withMaxPreparedStatementCacheSize(int maxPreparedStatementCacheSize)
public T withGlobalInsertStrategy(info.archinnov.achilles.type.strategy.InsertStrategy globalInsertStrategy)
globalInsertStrategy - public T withSchemaNameProvider(info.archinnov.achilles.type.SchemaNameProvider schemaNameProvider)
schemaNameProvider - public T withDefaultExecutorService(ExecutorService executorService)
new ThreadPoolExecutor(5, 20, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue(1000),
new DefaultExecutorThreadFactory())
executorService - an executor service (thread pool) to be used by Achilles for internal for asynchronous operationspublic T withExecutorServiceMinThreadCount(int minThreadCount)
// Create proxy
new ThreadPoolExecutor(minThreadCount, 20, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue(1000),
new DefaultExecutorThreadFactory())
minThreadCount - min thread count for the executor servicepublic T withExecutorServiceMaxThreadCount(int maxThreadCount)
// Create proxy
new ThreadPoolExecutor(5, maxThreadCount, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue(1000),
new DefaultExecutorThreadFactory())
maxThreadCount - max thread count for the executor servicepublic T withExecutorServiceThreadKeepAliveDuration(int keepAliveDuration)
// Create proxy
new ThreadPoolExecutor(5, 20, keepAliveDuration, TimeUnit.SECONDS,
new LinkedBlockingQueue(1000),
new DefaultExecutorThreadFactory())
keepAliveDuration - thread keep-alive duration in second for the executor servicepublic T withExecutorServiceThreadQueueSize(int threadQueueSize)
// Create proxy
new ThreadPoolExecutor(5, 20, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue(threadQueueSize),
new DefaultExecutorThreadFactory())
threadQueueSize - the LinkedBlockingQueue size for the executor servicepublic T withExecutorServiceThreadFactory(ThreadFactory factory)
// Create proxy
new ThreadPoolExecutor(5, 20, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue(threadQueueSize),
new DefaultExecutorThreadFactory())
factory - the thread factorypublic T withManagedEntityClasses(List<Class<?>> entityClasses)
entityClasses - entities to be managed by Achillespublic T withManagedEntityClasses(Class<?>... entityClasses)
entityClasses - entities to be managed by Achillespublic T withStatementsCache(StatementsCache statementsCache)
StatementsCachestatementsCache - cache object for the prepared statementspublic T withParameter(ConfigurationParameters parameter, Object value)
parameter - an instance of the ConfigurationParameters enumvalue - the value of the parameterpublic <FROM,TO> T withRuntimeCodec(info.archinnov.achilles.type.codec.CodecSignature<FROM,TO> codecSignature, info.archinnov.achilles.type.codec.Codec<FROM,TO> codec)
final Codec<MyBean, String> beanCodec = new .... // Create your codec with initialization logic here
final Codec<MyEnum, String> enumCodec = new .... // Create your codec with initialization logic here
final CodecSignature<MyBean, String> codecSignature1 = new CodecSignature(MyBean.class, String.class);
final CodecSignature<MyBean, String> codecSignature2 = new CodecSignature(MyEnum.class, String.class);
final Map<CodecSignature<?, ?>, Codec<?, ?>> runtimeCodecs = new HashMap<>();
runtimeCodecs.put(codecSignature1, beanCodec);
runtimeCodecs.put(codecSignature2, enumCodec);
ManagerFactory factory = ManagerFactoryBuilder
.builder(cluster)
...
.withRuntimeCodec(codecSignature1, beanCodec)
.withRuntimeCodec(codecSignature2, enumCodec)
.build();
codecSignature - codec signature, defined by sourceType,targetType and optionally codecNamecodec - runtime codecpublic T withRuntimeCodecs(Map<info.archinnov.achilles.type.codec.CodecSignature<?,?>,info.archinnov.achilles.type.codec.Codec<?,?>> runtimeCodecs)
final Codec<MyBean, String> beanCodec = new .... // Create your codec with initialization logic here
final Codec<MyEnum, String> enumCodec = new .... // Create your codec with initialization logic here
final CodecSignature<MyBean, String> codecSignature1 = new CodecSignature(MyBean.class, String.class);
final CodecSignature<MyBean, String> codecSignature2 = new CodecSignature(MyEnum.class, String.class);
final Map<CodecSignature<?, ?>, Codec<?, ?>> runtimeCodecs = new HashMap<>();
runtimeCodecs.put(codecSignature1, beanCodec);
runtimeCodecs.put(codecSignature2, enumCodec);
ManagerFactory factory = ManagerFactoryBuilder
.builder(cluster)
...
.withRuntimeCodecs(runtimeCodecs)
.build();
runtimeCodecs - a map of codec signature and its corresponding codecpublic T withMaxDMLResultsDisplayed(int maxDMLResultsDisplayed)
maxDMLResultsDisplayed - max returned rows to be displayedCopyright © 2012-2021. All Rights Reserved.