Class C8DB.Builder
- java.lang.Object
-
- com.c8db.internal.InternalC8DBBuilder
-
- com.c8db.C8DB.Builder
-
- Enclosing interface:
- C8DB
public static class C8DB.Builder extends InternalC8DBBuilder
Builder class to build an instance ofC8DB.
-
-
Field Summary
Fields Modifier and Type Field Description protected Protocolprotocol-
Fields inherited from class com.c8db.internal.InternalC8DBBuilder
acquireHostList, acquireHostListInterval, chunksize, connectionTtl, customSerializer, deserializer, email, host, hosts, httpCookieSpec, jwtAuth, loadBalancingStrategy, maxConnections, password, serializer, sslContext, timeout, user, useSsl, vpackBuilder, vpackParserBuilder
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description C8DB.BuilderacquireHostList(Boolean acquireHostList)Whether or not the driver should acquire a list of available coordinators in an ArangoDB cluster or a single server with active failover.C8DB.BuilderacquireHostListInterval(Integer acquireHostListInterval)Setting the Interval for acquireHostList<A extends Annotation>
C8DB.BuilderannotationFieldFilter(Class<A> type, com.arangodb.velocypack.VPackAnnotationFieldFilter<A> fieldFilter)Register a customVPackAnnotationFieldFilterfor a specific type to be used within the internal serialization process.<A extends Annotation>
C8DB.BuilderannotationFieldNaming(Class<A> type, com.arangodb.velocypack.VPackAnnotationFieldNaming<A> fieldNaming)Register a customVPackAnnotationFieldNamingfor a specific type to be used within the internal serialization process.C8DBbuild()Returns an instance ofC8DB.C8DB.Builderchunksize(Integer chunksize)Sets the chunk size whenProtocol.VSTis used.C8DB.BuilderconnectionTtl(Long connectionTtl)Set the maximum time to life of a connection.C8DB.Builderemail(String email)C8DB.Builderhost(String host, int port)Adds a host to connect to.C8DB.BuilderloadBalancingStrategy(LoadBalancingStrategy loadBalancingStrategy)Sets the load balancing strategy to be used in an ArangoDB cluster setup.C8DB.BuilderloadProperties(InputStream in)protected voidloadProperties(Properties properties)C8DB.BuildermaxConnections(Integer maxConnections)Sets the maximum number of connections the built in connection pool will open per host.C8DB.Builderpassword(String password)Sets the password for the user for authentication.<T> C8DB.BuilderregisterDeserializer(Class<T> clazz, com.arangodb.velocypack.VPackDeserializer<T> deserializer)Register a customVPackDeserializerfor a specific type to be used within the internal serialization process.<T> C8DB.BuilderregisterEnclosingSerializer(Class<T> clazz, com.arangodb.velocypack.VPackSerializer<T> serializer)Register a special serializer for a member class which can only be identified by its enclosing class.<T> C8DB.BuilderregisterInstanceCreator(Class<T> clazz, com.arangodb.velocypack.VPackInstanceCreator<T> creator)Register a customVPackInstanceCreatorfor a specific type to be used within the internal serialization process.C8DB.BuilderregisterJsonDeserializer(com.arangodb.velocypack.ValueType type, com.arangodb.velocypack.VPackJsonDeserializer deserializer)Register a customVPackJsonDeserializerfor a specific type to be used within the internal serialization process.C8DB.BuilderregisterJsonDeserializer(String attribute, com.arangodb.velocypack.ValueType type, com.arangodb.velocypack.VPackJsonDeserializer deserializer)Register a customVPackJsonDeserializerfor a specific type and attribute name to be used within the internal serialization process.C8DB.BuilderregisterJsonModule(com.arangodb.velocypack.VPackParserModule module)Register aVPackParserModuleto be used within the internal serialization process.C8DB.BuilderregisterJsonModules(com.arangodb.velocypack.VPackParserModule... modules)Register a list ofVPackParserModuleto be used within the internal serialization process.<T> C8DB.BuilderregisterJsonSerializer(Class<T> clazz, com.arangodb.velocypack.VPackJsonSerializer<T> serializer)Register a customVPackJsonSerializerfor a specific type to be used within the internal serialization process.<T> C8DB.BuilderregisterJsonSerializer(String attribute, Class<T> clazz, com.arangodb.velocypack.VPackJsonSerializer<T> serializer)Register a customVPackJsonSerializerfor a specific type and attribute name to be used within the internal serialization process.C8DB.BuilderregisterModule(com.arangodb.velocypack.VPackModule module)Register aVPackModuleto be used within the internal serialization process.C8DB.BuilderregisterModules(com.arangodb.velocypack.VPackModule... modules)Register a list ofVPackModuleto be used within the internal serialization process.<T> C8DB.BuilderregisterSerializer(Class<T> clazz, com.arangodb.velocypack.VPackSerializer<T> serializer)Register a customVPackSerializerfor a specific type to be used within the internal serialization process.C8DB.Builderserializer(C8Serialization serialization)Replace the built-in serializer/deserializer with the given one.C8DB.BuildersetDeserializer(C8Deserializer deserializer)Deprecated.useserializer(C8Serialization)insteadC8DB.BuildersetSerializer(C8Serializer serializer)Deprecated.useserializer(C8Serialization)insteadC8DB.BuildersslContext(SSLContext sslContext)Sets the SSL context to be used whentrueis passed throughuseSsl(Boolean).C8DB.Buildertimeout(Integer timeout)Sets the connection and request timeout in milliseconds.C8DB.BuilderuseProtocol(Protocol protocol)C8DB.Builderuser(String user)Sets the username to use for authentication.C8DB.BuilderuseSsl(Boolean useSsl)If set totrueSSL will be used when connecting to an ArangoDB server.-
Methods inherited from class com.c8db.internal.InternalC8DBBuilder
createHostHandler, createHostList, createHostResolver, deserializer, getProperty, serializer, setAcquireHostList, setAcquireHostListInterval, setChunksize, setConnectionTtl, setEmail, setHost, setLoadBalancingStrategy, setMaxConnections, setPassword, setSerializer, setSslContext, setTimeout, setUser, setUseSsl
-
-
-
-
Field Detail
-
protocol
protected Protocol protocol
-
-
Method Detail
-
loadProperties
protected void loadProperties(Properties properties)
- Overrides:
loadPropertiesin classInternalC8DBBuilder
-
useProtocol
public C8DB.Builder useProtocol(Protocol protocol)
-
loadProperties
public C8DB.Builder loadProperties(InputStream in) throws C8DBException
- Overrides:
loadPropertiesin classInternalC8DBBuilder- Throws:
C8DBException
-
host
public C8DB.Builder host(String host, int port)
Adds a host to connect to. Multiple hosts can be added to provide fallbacks.- Parameters:
host- address of the hostport- port of the host- Returns:
C8DB.Builder
-
timeout
public C8DB.Builder timeout(Integer timeout)
Sets the connection and request timeout in milliseconds.- Parameters:
timeout- timeout in milliseconds- Returns:
C8DB.Builder
-
user
public C8DB.Builder user(String user)
Sets the username to use for authentication.- Parameters:
user- the user in the database (default:root)- Returns:
C8DB.Builder
-
password
public C8DB.Builder password(String password)
Sets the password for the user for authentication.- Parameters:
password- the password of the user in the database (default:null)- Returns:
C8DB.Builder
-
email
public C8DB.Builder email(String email)
-
useSsl
public C8DB.Builder useSsl(Boolean useSsl)
If set totrueSSL will be used when connecting to an ArangoDB server.- Parameters:
useSsl- whether or not use SSL (default:false)- Returns:
C8DB.Builder
-
sslContext
public C8DB.Builder sslContext(SSLContext sslContext)
Sets the SSL context to be used whentrueis passed throughuseSsl(Boolean).- Parameters:
sslContext- SSL context to be used- Returns:
C8DB.Builder
-
chunksize
public C8DB.Builder chunksize(Integer chunksize)
Sets the chunk size whenProtocol.VSTis used.- Parameters:
chunksize- size of a chunk in bytes- Returns:
C8DB.Builder
-
maxConnections
public C8DB.Builder maxConnections(Integer maxConnections)
Sets the maximum number of connections the built in connection pool will open per host.Defaults:
Protocol.VST== 1Protocol.HTTP_JSON== 20Protocol.HTTP_VPACK== 20- Parameters:
maxConnections- max number of connections- Returns:
C8DB.Builder
-
connectionTtl
public C8DB.Builder connectionTtl(Long connectionTtl)
Set the maximum time to life of a connection. After this time the connection will be closed automatically.- Parameters:
connectionTtl- the maximum time to life of a connection in milliseconds- Returns:
C8DB.Builder
-
acquireHostList
public C8DB.Builder acquireHostList(Boolean acquireHostList)
Whether or not the driver should acquire a list of available coordinators in an ArangoDB cluster or a single server with active failover.The host list will be used for failover and load balancing.
- Parameters:
acquireHostList- whether or not automatically acquire a list of available hosts (default: false)- Returns:
C8DB.Builder
-
acquireHostListInterval
public C8DB.Builder acquireHostListInterval(Integer acquireHostListInterval)
Setting the Interval for acquireHostList- Parameters:
acquireHostListInterval- Interval in Seconds- Returns:
C8DB.Builder
-
loadBalancingStrategy
public C8DB.Builder loadBalancingStrategy(LoadBalancingStrategy loadBalancingStrategy)
Sets the load balancing strategy to be used in an ArangoDB cluster setup.- Parameters:
loadBalancingStrategy- the load balancing strategy to be used (default:LoadBalancingStrategy.NONE- Returns:
C8DB.Builder
-
registerSerializer
public <T> C8DB.Builder registerSerializer(Class<T> clazz, com.arangodb.velocypack.VPackSerializer<T> serializer)
Register a customVPackSerializerfor a specific type to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
clazz- the type the serializer should be registered forserializer- serializer to register- Returns:
C8DB.Builder
-
registerEnclosingSerializer
public <T> C8DB.Builder registerEnclosingSerializer(Class<T> clazz, com.arangodb.velocypack.VPackSerializer<T> serializer)
Register a special serializer for a member class which can only be identified by its enclosing class.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
clazz- the type of the enclosing classserializer- serializer to register- Returns:
C8DB.Builder
-
registerDeserializer
public <T> C8DB.Builder registerDeserializer(Class<T> clazz, com.arangodb.velocypack.VPackDeserializer<T> deserializer)
Register a customVPackDeserializerfor a specific type to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
clazz- the type the serializer should be registered fordeserializer-- Returns:
C8DB.Builder
-
registerInstanceCreator
public <T> C8DB.Builder registerInstanceCreator(Class<T> clazz, com.arangodb.velocypack.VPackInstanceCreator<T> creator)
Register a customVPackInstanceCreatorfor a specific type to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
clazz- the type the instance creator should be registered forcreator-- Returns:
C8DB.Builder
-
registerJsonDeserializer
public C8DB.Builder registerJsonDeserializer(com.arangodb.velocypack.ValueType type, com.arangodb.velocypack.VPackJsonDeserializer deserializer)
Register a customVPackJsonDeserializerfor a specific type to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
type- the type the serializer should be registered fordeserializer-- Returns:
C8DB.Builder
-
registerJsonDeserializer
public C8DB.Builder registerJsonDeserializer(String attribute, com.arangodb.velocypack.ValueType type, com.arangodb.velocypack.VPackJsonDeserializer deserializer)
Register a customVPackJsonDeserializerfor a specific type and attribute name to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
attribute-type- the type the serializer should be registered fordeserializer-- Returns:
C8DB.Builder
-
registerJsonSerializer
public <T> C8DB.Builder registerJsonSerializer(Class<T> clazz, com.arangodb.velocypack.VPackJsonSerializer<T> serializer)
Register a customVPackJsonSerializerfor a specific type to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
clazz- the type the serializer should be registered forserializer-- Returns:
C8DB.Builder
-
registerJsonSerializer
public <T> C8DB.Builder registerJsonSerializer(String attribute, Class<T> clazz, com.arangodb.velocypack.VPackJsonSerializer<T> serializer)
Register a customVPackJsonSerializerfor a specific type and attribute name to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
attribute-clazz- the type the serializer should be registered forserializer-- Returns:
C8DB.Builder
-
annotationFieldFilter
public <A extends Annotation> C8DB.Builder annotationFieldFilter(Class<A> type, com.arangodb.velocypack.VPackAnnotationFieldFilter<A> fieldFilter)
Register a customVPackAnnotationFieldFilterfor a specific type to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
type- the type the serializer should be registered forfieldFilter-- Returns:
C8DB.Builder
-
annotationFieldNaming
public <A extends Annotation> C8DB.Builder annotationFieldNaming(Class<A> type, com.arangodb.velocypack.VPackAnnotationFieldNaming<A> fieldNaming)
Register a customVPackAnnotationFieldNamingfor a specific type to be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
type- the type the serializer should be registered forfieldNaming-- Returns:
C8DB.Builder
-
registerModule
public C8DB.Builder registerModule(com.arangodb.velocypack.VPackModule module)
Register aVPackModuleto be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
module- module to register- Returns:
C8DB.Builder
-
registerModules
public C8DB.Builder registerModules(com.arangodb.velocypack.VPackModule... modules)
Register a list ofVPackModuleto be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
modules- modules to register- Returns:
C8DB.Builder
-
registerJsonModule
public C8DB.Builder registerJsonModule(com.arangodb.velocypack.VPackParserModule module)
Register aVPackParserModuleto be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
module- module to register- Returns:
C8DB.Builder
-
registerJsonModules
public C8DB.Builder registerJsonModules(com.arangodb.velocypack.VPackParserModule... modules)
Register a list ofVPackParserModuleto be used within the internal serialization process.Attention:can not be used together with
serializer(C8Serialization)- Parameters:
modules- modules to register- Returns:
C8DB.Builder
-
setSerializer
@Deprecated public C8DB.Builder setSerializer(C8Serializer serializer)
Deprecated.useserializer(C8Serialization)insteadReplace the built-in serializer with the given serializer.
ATTENTION!: Use at your own risk- Parameters:
serializer- custom serializer- Returns:
C8DB.Builder
-
setDeserializer
@Deprecated public C8DB.Builder setDeserializer(C8Deserializer deserializer)
Deprecated.useserializer(C8Serialization)insteadReplace the built-in deserializer with the given deserializer.
ATTENTION!: Use at your own risk- Parameters:
deserializer- custom deserializer- Returns:
C8DB.Builder
-
serializer
public C8DB.Builder serializer(C8Serialization serialization)
Replace the built-in serializer/deserializer with the given one.
ATTENTION!: Any registered custom serializer/deserializer or module will be ignored.- Parameters:
serialization- custom serializer/deserializer- Returns:
C8DB.Builder
-
-