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; ...@@ -18,6 +18,7 @@ import java.util.List;
public class Main { public class Main {
private static int numberOfWallets = 2; private static int numberOfWallets = 2;
private static boolean createGUI = false;
private static ActorSystem cSystem; private static ActorSystem cSystem;
...@@ -56,9 +57,9 @@ public class Main { ...@@ -56,9 +57,9 @@ public class Main {
if (i > 0) { if (i > 0) {
//chain the wallets. wallet2 knows wallet1, wallet3 knows wallet2 and so on. //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 { } else {
props = WalletImpl.props(null, nameOfTheWallet); props = WalletImpl.props(null, nameOfTheWallet, createGUI);
} }
ActorRef actorRef = cSystem.actorOf(props, nameOfTheWallet); ActorRef actorRef = cSystem.actorOf(props, nameOfTheWallet);
......
...@@ -91,7 +91,7 @@ public class MainRemote { ...@@ -91,7 +91,7 @@ public class MainRemote {
} }
// spawn wallet // 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; ...@@ -7,18 +7,24 @@ import fucoin.gui.WalletGuiControlImpl;
public class WalletCreator implements Creator<AbstractWallet> { public class WalletCreator implements Creator<AbstractWallet> {
private ActorRef preKnownNeighbour; private ActorRef preKnownNeighbour;
private String walletName; private String walletName;
private boolean createGUI;
public WalletCreator(ActorRef preKnownNeighbour, String walletName) { public WalletCreator(ActorRef preKnownNeighbour, String walletName, boolean createGUI) {
this.preKnownNeighbour = preKnownNeighbour; this.preKnownNeighbour = preKnownNeighbour;
this.walletName = walletName; this.walletName = walletName;
this.createGUI = createGUI;
} }
@Override @Override
public WalletImpl create() throws Exception { public WalletImpl create() throws Exception {
WalletImpl wallet = new WalletImpl(preKnownNeighbour, walletName); WalletImpl wallet = new WalletImpl(preKnownNeighbour, walletName);
WalletGuiControlImpl gui = new WalletGuiControlImpl(wallet); if (createGUI) {
wallet.setGui(gui); WalletGuiControlImpl gui = new WalletGuiControlImpl(wallet);
wallet.setGui(gui);
}
return wallet; return wallet;
} }
} }
...@@ -32,8 +32,8 @@ public class WalletImpl extends AbstractWallet { ...@@ -32,8 +32,8 @@ public class WalletImpl extends AbstractWallet {
} }
} }
public static Props props(ActorRef preKnownNeighbour, String walletName) { public static Props props(ActorRef preKnownNeighbour, String walletName, boolean createGUI) {
return Props.create(new WalletCreator(preKnownNeighbour, walletName)); return Props.create(new WalletCreator(preKnownNeighbour, walletName, createGUI));
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment