Skip to content
Snippets Groups Projects
Unverified Commit c7c99b60 authored by Luca Keidel's avatar Luca Keidel
Browse files

Implemented option to spawn wallets without a GUI

parent 9886bd32
No related branches found
No related tags found
1 merge request!5Configuration system
......@@ -18,6 +18,7 @@ import java.util.List;
public class Main {
private static int numberOfWallets = 2;
private static boolean createGUI = false;
private static ActorSystem cSystem;
......@@ -56,9 +57,9 @@ public class Main {
if (i > 0) {
//chain the wallets. wallet2 knows wallet1, wallet3 knows wallet2 and so on.
props = WalletImpl.props(cActiveActors.get(i - 1), nameOfTheWallet);
props = WalletImpl.props(cActiveActors.get(i - 1), nameOfTheWallet, createGUI);
} else {
props = WalletImpl.props(null, nameOfTheWallet);
props = WalletImpl.props(null, nameOfTheWallet, createGUI);
}
ActorRef actorRef = cSystem.actorOf(props, nameOfTheWallet);
......
......@@ -91,7 +91,7 @@ public class MainRemote {
}
// spawn wallet
system.actorOf(WalletImpl.props(preknownNeighbour, walletName), walletName);
system.actorOf(WalletImpl.props(preknownNeighbour, walletName, true), walletName);
}
}
......@@ -7,18 +7,24 @@ import fucoin.gui.WalletGuiControlImpl;
public class WalletCreator implements Creator<AbstractWallet> {
private ActorRef preKnownNeighbour;
private String walletName;
private boolean createGUI;
public WalletCreator(ActorRef preKnownNeighbour, String walletName) {
public WalletCreator(ActorRef preKnownNeighbour, String walletName, boolean createGUI) {
this.preKnownNeighbour = preKnownNeighbour;
this.walletName = walletName;
this.createGUI = createGUI;
}
@Override
public WalletImpl create() throws Exception {
WalletImpl wallet = new WalletImpl(preKnownNeighbour, walletName);
WalletGuiControlImpl gui = new WalletGuiControlImpl(wallet);
wallet.setGui(gui);
if (createGUI) {
WalletGuiControlImpl gui = new WalletGuiControlImpl(wallet);
wallet.setGui(gui);
}
return wallet;
}
}
......@@ -32,8 +32,8 @@ public class WalletImpl extends AbstractWallet {
}
}
public static Props props(ActorRef preKnownNeighbour, String walletName) {
return Props.create(new WalletCreator(preKnownNeighbour, walletName));
public static Props props(ActorRef preKnownNeighbour, String walletName, boolean createGUI) {
return Props.create(new WalletCreator(preKnownNeighbour, walletName, createGUI));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment