/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.vertx.reactivex.config;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
Defines a configuration retriever that read configuration from
and tracks changes periodically.
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* Defines a configuration retriever that read configuration from
*
* and tracks changes periodically.
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.config.ConfigRetriever original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.config.ConfigRetriever.class)
public class ConfigRetriever {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConfigRetriever that = (ConfigRetriever) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg<ConfigRetriever> __TYPE_ARG = new TypeArg<>( obj -> new ConfigRetriever((io.vertx.config.ConfigRetriever) obj),
ConfigRetriever::getDelegate
);
private final io.vertx.config.ConfigRetriever delegate;
public ConfigRetriever(io.vertx.config.ConfigRetriever delegate) {
this.delegate = delegate;
}
public ConfigRetriever(Object delegate) {
this.delegate = (io.vertx.config.ConfigRetriever)delegate;
}
public io.vertx.config.ConfigRetriever getDelegate() {
return delegate;
}
Creates an instance of the default implementation of the ConfigRetriever
. Params: - vertx – the vert.x instance
- options – the options, must not be
null
, must contain the list of configured store.
Returns: the created instance.
/**
* Creates an instance of the default implementation of the {@link io.vertx.reactivex.config.ConfigRetriever}.
* @param vertx the vert.x instance
* @param options the options, must not be <code>null</code>, must contain the list of configured store.
* @return the created instance.
*/
public static io.vertx.reactivex.config.ConfigRetriever create(io.vertx.reactivex.core.Vertx vertx, io.vertx.config.ConfigRetrieverOptions options) {
io.vertx.reactivex.config.ConfigRetriever ret = io.vertx.reactivex.config.ConfigRetriever.newInstance((io.vertx.config.ConfigRetriever)io.vertx.config.ConfigRetriever.create(vertx.getDelegate(), options));
return ret;
}
Creates an instance of the default implementation of the ConfigRetriever
, using the default settings (json file, system properties and environment variables). Params: - vertx – the vert.x instance
Returns: the created instance.
/**
* Creates an instance of the default implementation of the {@link io.vertx.reactivex.config.ConfigRetriever}, using the default
* settings (json file, system properties and environment variables).
* @param vertx the vert.x instance
* @return the created instance.
*/
public static io.vertx.reactivex.config.ConfigRetriever create(io.vertx.reactivex.core.Vertx vertx) {
io.vertx.reactivex.config.ConfigRetriever ret = io.vertx.reactivex.config.ConfigRetriever.newInstance((io.vertx.config.ConfigRetriever)io.vertx.config.ConfigRetriever.create(vertx.getDelegate()));
return ret;
}
Reads the configuration from the different
and computes the final configuration.
Params: - completionHandler – handler receiving the computed configuration, or a failure if the configuration cannot be retrieved
/**
* Reads the configuration from the different
* and computes the final configuration.
* @param completionHandler handler receiving the computed configuration, or a failure if the configuration cannot be retrieved
*/
public void getConfig(Handler<AsyncResult<JsonObject>> completionHandler) {
delegate.getConfig(completionHandler);
}
Reads the configuration from the different
and computes the final configuration.
/**
* Reads the configuration from the different
* and computes the final configuration.
*/
public void getConfig() {
getConfig(ar -> { });
}
Reads the configuration from the different
and computes the final configuration.
Returns:
/**
* Reads the configuration from the different
* and computes the final configuration.
* @return
*/
public io.reactivex.Single<JsonObject> rxGetConfig() {
return AsyncResultSingle.toSingle($handler -> {
getConfig($handler);
});
}
Closes the retriever.
/**
* Closes the retriever.
*/
public void close() {
delegate.close();
}
Gets the last computed configuration.
Returns: the last configuration
/**
* Gets the last computed configuration.
* @return the last configuration
*/
public JsonObject getCachedConfig() {
JsonObject ret = delegate.getCachedConfig();
return ret;
}
Registers a listener receiving configuration changes. This method cannot only be called if
the configuration is broadcasted.
Params: - listener – the listener
/**
* Registers a listener receiving configuration changes. This method cannot only be called if
* the configuration is broadcasted.
* @param listener the listener
*/
public void listen(Handler<io.vertx.config.ConfigChange> listener) {
delegate.listen(listener);
}
Registers a handler called before every scan. This method is mostly used for logging purpose.
Params: - handler – the handler, must not be
null
Returns: the current config retriever
/**
* Registers a handler called before every scan. This method is mostly used for logging purpose.
* @param handler the handler, must not be <code>null</code>
* @return the current config retriever
*/
public io.vertx.reactivex.config.ConfigRetriever setBeforeScanHandler(Handler<Void> handler) {
delegate.setBeforeScanHandler(handler);
return this;
}
Registers a handler that process the configuration before being injected into getConfig
or listen
. This allows the code to customize the configuration. Params: - processor – the processor, must not be
null
. The method must not return null
. The returned configuration is used. If the processor does not update the configuration, it must return the input configuration. If the processor throws an exception, the failure is passed to the getConfig
handler.
Returns: the current config retriever
/**
* Registers a handler that process the configuration before being injected into {@link io.vertx.reactivex.config.ConfigRetriever#getConfig} or {@link io.vertx.reactivex.config.ConfigRetriever#listen}. This allows
* the code to customize the configuration.
* @param processor the processor, must not be <code>null</code>. The method must not return <code>null</code>. The returned configuration is used. If the processor does not update the configuration, it must return the input configuration. If the processor throws an exception, the failure is passed to the {@link io.vertx.reactivex.config.ConfigRetriever#getConfig} handler.
* @return the current config retriever
*/
public io.vertx.reactivex.config.ConfigRetriever setConfigurationProcessor(Function<JsonObject, JsonObject> processor) {
delegate.setConfigurationProcessor(processor);
return this;
}
Returns: the stream of configurations. It's single stream (unicast) and that delivers the last known config and the successors periodically.
/**
* @return the stream of configurations. It's single stream (unicast) and that delivers the last known config and the successors periodically.
*/
public io.vertx.reactivex.core.streams.ReadStream<JsonObject> configStream() {
if (cached_0 != null) {
return cached_0;
}
io.vertx.reactivex.core.streams.ReadStream<JsonObject> ret = io.vertx.reactivex.core.streams.ReadStream.newInstance((io.vertx.core.streams.ReadStream)delegate.configStream(), TypeArg.unknown());
cached_0 = ret;
return ret;
}
private io.vertx.reactivex.core.streams.ReadStream<JsonObject> cached_0;
public static ConfigRetriever newInstance(io.vertx.config.ConfigRetriever arg) {
return arg != null ? new ConfigRetriever(arg) : null;
}
}