Fix write proxy initialization

This commit is contained in:
2020-09-02 09:51:08 +02:00
parent efbca9cbc9
commit 8b204b3715
4 changed files with 27 additions and 54 deletions

View File

@ -51,12 +51,6 @@ public final class Cache<T> implements Consumer<T>, Serializable {
*/
public void setProcessor(Consumer<T> processor) { this.processor = processor; }
/**
* @return the processor
* @since Envoy Client v0.2-beta
*/
public Consumer<T> getProcessor() { return processor; }
/**
* Relays all cached elements to the processor.
*

View File

@ -18,24 +18,33 @@ import envoy.client.ui.SceneContext;
*/
public class Context {
private WriteProxy writeProxy;
private LocalDB localDB;
private Stage stage;
private SceneContext sceneContext;
private final Client client = new Client();
private WriteProxy writeProxy;
private LocalDB localDB;
private Stage stage;
private SceneContext sceneContext;
private static final Context instance = new Context();
private Context() {}
/**
* @return the instance of {@code Context} used throughout Envoy
* @since Envoy Client v0.2-beta
*/
public static Context getInstance() { return instance; }
/**
* Initializes the write proxy given that {@code localDB} is initialized.
*
* @since Envoy Client v0.2-beta
*/
public void initWriteProxy() {
if (localDB == null) throw new IllegalStateException("The LocalDB has to be initialized!");
writeProxy = new WriteProxy(client, localDB);
}
/**
* @return the localDB
* @since Envoy Client v0.2-beta
@ -81,14 +90,6 @@ public class Context {
*/
public Stage getStage() { return stage; }
private Context() {}
/**
* @param writeProxy the writeProxy to set
* @since Envoy Client v0.2-beta
*/
public void setWriteProxy(WriteProxy writeProxy) { this.writeProxy = writeProxy; }
/**
* @param stage the stage to set
* @since Envoy Client v0.2-beta