final VPackParser vpackParser = vpackParserBuilder.build(); final ArangoSerializer serializerTemp = serializer != null ? serializer : new ArangoSerializerImpl(vpacker, vpackerNull, vpackParser);
public InternalArangoDBBuilder() { super(); vpackBuilder = new VPack.Builder(); vpackParserBuilder = new VPackParser.Builder(); vpackBuilder.registerModule(new VPackDriverModule()); vpackParserBuilder.registerModule(new VPackDriverModule()); host = new HostDescription(ArangoDefaults.DEFAULT_HOST, ArangoDefaults.DEFAULT_PORT); hosts = new ArrayList<HostDescription>(); user = ArangoDefaults.DEFAULT_USER; loadProperties(ArangoDB.class.getResourceAsStream(DEFAULT_PROPERTY_FILE)); }
/** * Returns an instance of {@link ArangoDBAsync}. * * @return {@link ArangoDBAsync} */ public synchronized ArangoDBAsync build() { if (hosts.isEmpty()) { hosts.add(host); } final VPack vpacker = vpackBuilder.serializeNullValues(false).build(); final VPack vpackerNull = vpackBuilder.serializeNullValues(true).build(); final VPackParser vpackParser = vpackParserBuilder.build(); final ArangoSerializer serializerTemp = serializer != null ? serializer : new ArangoSerializerImpl(vpacker, vpackerNull, vpackParser); final ArangoDeserializer deserializerTemp = deserializer != null ? deserializer : new ArangoDeserializerImpl(vpackerNull, vpackParser); final DefaultArangoSerialization internal = new DefaultArangoSerialization(serializerTemp, deserializerTemp); final ArangoSerialization custom = customSerializer != null ? customSerializer : internal; final ArangoSerializationFactory util = new ArangoSerializationFactory(internal, custom); final int max = maxConnections != null ? Math.max(1, maxConnections) : ArangoDefaults.MAX_CONNECTIONS_VST_DEFAULT; final ConnectionFactory connectionFactory = new VstConnectionFactoryAsync(host, timeout, connectionTtl, useSsl, sslContext); final HostResolver hostResolver = createHostResolver(createHostList(max, connectionFactory), max, connectionFactory); final HostHandler hostHandler = createHostHandler(hostResolver); return new ArangoDBAsyncImpl(asyncBuilder(hostHandler), util, syncBuilder(hostHandler), hostResolver, new ArangoContext()); }
/** * Returns an instance of {@link ArangoDBAsync}. * * @return {@link ArangoDBAsync} */ public synchronized ArangoDBAsync build() { if (hosts.isEmpty()) { hosts.add(host); } final VPack vpacker = vpackBuilder.serializeNullValues(false).build(); final VPack vpackerNull = vpackBuilder.serializeNullValues(true).build(); final VPackParser vpackParser = vpackParserBuilder.build(); final ArangoSerializer serializerTemp = serializer != null ? serializer : new ArangoSerializerImpl(vpacker, vpackerNull, vpackParser); final ArangoDeserializer deserializerTemp = deserializer != null ? deserializer : new ArangoDeserializerImpl(vpackerNull, vpackParser); final DefaultArangoSerialization internal = new DefaultArangoSerialization(serializerTemp, deserializerTemp); final ArangoSerialization custom = customSerializer != null ? customSerializer : internal; final ArangoSerializationFactory util = new ArangoSerializationFactory(internal, custom); final int max = maxConnections != null ? Math.max(1, maxConnections) : ArangoDefaults.MAX_CONNECTIONS_VST_DEFAULT; final ConnectionFactory connectionFactory = new VstConnectionFactoryAsync(host, timeout, connectionTtl, useSsl, sslContext); final HostResolver hostResolver = createHostResolver(createHostList(max, connectionFactory), max, connectionFactory); final HostHandler hostHandler = createHostHandler(hostResolver); return new ArangoDBAsyncImpl(asyncBuilder(hostHandler), util, syncBuilder(hostHandler), hostResolver, new ArangoContext()); }
/** * Register a custom {@link VPackJsonDeserializer} for a specific type and attribute name to be used within the * internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param attribute * @param type * the type the serializer should be registered for * @param deserializer * @return {@link ArangoDBAsync.Builder} */ public Builder registerJsonDeserializer( final String attribute, final ValueType type, final VPackJsonDeserializer deserializer) { vpackParserBuilder.registerDeserializer(attribute, type, deserializer); return this; }
/** * Register a custom {@link VPackJsonSerializer} for a specific type and attribute name to be used within the * internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param attribute * @param clazz * the type the serializer should be registered for * @param serializer * @return {@link ArangoDBAsync.Builder} */ public <T> Builder registerJsonSerializer( final String attribute, final Class<T> clazz, final VPackJsonSerializer<T> serializer) { vpackParserBuilder.registerSerializer(attribute, clazz, serializer); return this; }
/** * Register a custom {@link VPackJsonDeserializer} for a specific type and attribute name to be used within the * internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param attribute * @param type * the type the serializer should be registered for * @param deserializer * @return {@link ArangoDBAsync.Builder} */ public Builder registerJsonDeserializer( final String attribute, final ValueType type, final VPackJsonDeserializer deserializer) { vpackParserBuilder.registerDeserializer(attribute, type, deserializer); return this; }
/** * Register a custom {@link VPackJsonSerializer} for a specific type and attribute name to be used within the * internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param attribute * @param clazz * the type the serializer should be registered for * @param serializer * @return {@link ArangoDBAsync.Builder} */ public <T> Builder registerJsonSerializer( final String attribute, final Class<T> clazz, final VPackJsonSerializer<T> serializer) { vpackParserBuilder.registerSerializer(attribute, clazz, serializer); return this; }
/** * Register a custom {@link VPackJsonSerializer} for a specific type and attribute name to be used within the * internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param attribute * @param clazz * the type the serializer should be registered for * @param serializer * @return {@link ArangoDB.Builder} */ public <T> Builder registerJsonSerializer( final String attribute, final Class<T> clazz, final VPackJsonSerializer<T> serializer) { vpackParserBuilder.registerSerializer(attribute, clazz, serializer); return this; }
/** * Register a custom {@link VPackJsonDeserializer} for a specific type and attribute name to be used within the * internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param attribute * @param type * the type the serializer should be registered for * @param deserializer * @return {@link ArangoDB.Builder} */ public Builder registerJsonDeserializer( final String attribute, final ValueType type, final VPackJsonDeserializer deserializer) { vpackParserBuilder.registerDeserializer(attribute, type, deserializer); return this; }
/** * Register a custom {@link VPackJsonSerializer} for a specific type to be used within the internal * serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param clazz * the type the serializer should be registered for * @param serializer * @return {@link ArangoDBAsync.Builder} */ public <T> Builder registerJsonSerializer(final Class<T> clazz, final VPackJsonSerializer<T> serializer) { vpackParserBuilder.registerSerializer(clazz, serializer); return this; }
/** * Register a custom {@link VPackJsonSerializer} for a specific type to be used within the internal * serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param clazz * the type the serializer should be registered for * @param serializer * @return {@link ArangoDBAsync.Builder} */ public <T> Builder registerJsonSerializer(final Class<T> clazz, final VPackJsonSerializer<T> serializer) { vpackParserBuilder.registerSerializer(clazz, serializer); return this; }
/** * Register a custom {@link VPackJsonDeserializer} for a specific type to be used within the internal * serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param type * the type the serializer should be registered for * @param deserializer * @return {@link ArangoDBAsync.Builder} */ public Builder registerJsonDeserializer(final ValueType type, final VPackJsonDeserializer deserializer) { vpackParserBuilder.registerDeserializer(type, deserializer); return this; }
/** * Register a custom {@link VPackJsonSerializer} for a specific type to be used within the internal * serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param clazz * the type the serializer should be registered for * @param serializer * @return {@link ArangoDB.Builder} */ public <T> Builder registerJsonSerializer(final Class<T> clazz, final VPackJsonSerializer<T> serializer) { vpackParserBuilder.registerSerializer(clazz, serializer); return this; }
/** * Register a custom {@link VPackJsonDeserializer} for a specific type to be used within the internal * serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param type * the type the serializer should be registered for * @param deserializer * @return {@link ArangoDBAsync.Builder} */ public Builder registerJsonDeserializer(final ValueType type, final VPackJsonDeserializer deserializer) { vpackParserBuilder.registerDeserializer(type, deserializer); return this; }
/** * Register a {@link VPackParserModule} to be used within the internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param module * module to register * @return {@link ArangoDB.Builder} */ public Builder registerJsonModule(final VPackParserModule module) { vpackParserBuilder.registerModule(module); return this; }
/** * Register a {@link VPackParserModule} to be used within the internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param module * module to register * @return {@link ArangoDBAsync.Builder} */ public Builder registerJsonModule(final VPackParserModule module) { vpackParserBuilder.registerModule(module); return this; }
/** * Register a list of {@link VPackParserModule} to be used within the internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param modules * modules to register * @return {@link ArangoDB.Builder} */ public Builder registerJsonModules(final VPackParserModule... modules) { vpackParserBuilder.registerModules(modules); return this; }
/** * Register a custom {@link VPackJsonDeserializer} for a specific type to be used within the internal * serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param type * the type the serializer should be registered for * @param deserializer * @return {@link ArangoDB.Builder} */ public Builder registerJsonDeserializer(final ValueType type, final VPackJsonDeserializer deserializer) { vpackParserBuilder.registerDeserializer(type, deserializer); return this; }
/** * Register a list of {@link VPackParserModule} to be used within the internal serialization process. * * <p> * <strong>Attention:</strong>can not be used together with {@link #serializer(ArangoSerialization)} * </p> * * @param modules * modules to register * @return {@link ArangoDBAsync.Builder} */ public Builder registerJsonModules(final VPackParserModule... module) { vpackParserBuilder.registerModules(module); return this; }