Rename *Handler methods

This commit is contained in:
Chris Beams 2014-11-05 13:12:30 +01:00
parent f72bdf5f71
commit 44dc76e07e
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
28 changed files with 56 additions and 51 deletions

View File

@ -78,7 +78,7 @@ class TomP2POfferRepository implements OfferRepository {
// deactivate it for the moment until the port forwarding bug is fixed
// if (future.isSuccess()) {
Platform.runLater(() -> {
resultHandler.onResult();
resultHandler.handleResult();
offerRepositoryListeners.stream().forEach(listener -> {
try {
Object offerDataObject = offerData.object();
@ -101,13 +101,13 @@ class TomP2POfferRepository implements OfferRepository {
@Override
public void exceptionCaught(Throwable ex) throws Exception {
Platform.runLater(() -> {
faultHandler.onFault("Failed to add offer to DHT", ex);
faultHandler.handleFault("Failed to add offer to DHT", ex);
});
}
});
} catch (IOException ex) {
Platform.runLater(() -> {
faultHandler.onFault("Failed to add offer to DHT", ex);
faultHandler.handleFault("Failed to add offer to DHT", ex);
});
}
}

View File

@ -168,7 +168,8 @@ public class TradeManager {
settings.getAcceptedLanguageLocales());
if (createOfferCoordinatorMap.containsKey(offer.getId())) {
errorMessageHandler.onFault("A createOfferCoordinator for the offer with the id " + offer.getId() + " " +
errorMessageHandler.handleErrorMessage("A createOfferCoordinator for the offer with the id " + offer
.getId() + " " +
"already exists.");
}
else {
@ -185,13 +186,13 @@ public class TradeManager {
resultHandler.onResult(transactionId);
} catch (Exception e) {
//TODO retry policy
errorMessageHandler.onFault("Could not save offer. Reason: " +
errorMessageHandler.handleErrorMessage("Could not save offer. Reason: " +
(e.getCause() != null ? e.getCause().getMessage() : e.toString()));
createOfferCoordinatorMap.remove(offer.getId());
}
},
(message, throwable) -> {
errorMessageHandler.onFault(message);
errorMessageHandler.handleErrorMessage(message);
createOfferCoordinatorMap.remove(offer.getId());
}, offerRepository);
createOfferCoordinatorMap.put(offer.getId(), createOfferCoordinator);

View File

@ -142,7 +142,7 @@ public class CreateOfferCoordinator {
private void onFailed(String message, Throwable throwable) {
//TODO recover policy, timer
faultHandler.onFault(message, throwable);
faultHandler.handleFault(message, throwable);
}

View File

@ -42,24 +42,24 @@ public class BroadCastOfferFeeTx {
log.info("sendResult onSuccess:" + transaction);
if (transaction != null) {
try {
resultHandler.onResult();
resultHandler.handleResult();
} catch (Exception e) {
faultHandler.onFault("Offer fee payment failed.", e);
faultHandler.handleFault("Offer fee payment failed.", e);
}
}
else {
faultHandler.onFault("Offer fee payment failed.",
faultHandler.handleFault("Offer fee payment failed.",
new Exception("Offer fee payment failed. Transaction = null."));
}
}
@Override
public void onFailure(@NotNull Throwable t) {
faultHandler.onFault("Offer fee payment failed with an exception.", t);
faultHandler.handleFault("Offer fee payment failed with an exception.", t);
}
});
} catch (Throwable t) {
faultHandler.onFault("Offer fee payment failed because an exception occurred.", t);
faultHandler.handleFault("Offer fee payment failed because an exception occurred.", t);
}
}
}

View File

@ -34,10 +34,11 @@ public class CreateOfferFeeTx {
try {
resultHandler.onResult(walletFacade.createOfferFeeTx(offerId));
} catch (InsufficientMoneyException e) {
faultHandler.onFault("Offer fee payment failed because there is insufficient money in the trade wallet. " +
faultHandler.handleFault("Offer fee payment failed because there is insufficient money in the trade " +
"wallet. " +
"", e);
} catch (Throwable t) {
faultHandler.onFault("Offer fee payment failed because of an exception occurred. ", t);
faultHandler.handleFault("Offer fee payment failed because of an exception occurred. ", t);
}
}
}

View File

@ -66,9 +66,9 @@ public class VerifyOffer {
// getAddressInfoByTradeID(offerId)
// TODO when offer is flattened continue here...
resultHandler.onResult();
resultHandler.handleResult();
} catch (Throwable t) {
faultHandler.onFault("Offer validation failed.", t);
faultHandler.handleFault("Offer validation failed.", t);
}
}
}

View File

@ -50,7 +50,7 @@ public class CreateDepositTx {
resultHandler.onResult(offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex);
} catch (InsufficientMoneyException e) {
log.error("Create deposit tx faultHandler.onFault due InsufficientMoneyException " + e);
exceptionHandler.onError(
exceptionHandler.handleException(
new Exception("Create deposit tx faultHandler.onFault due InsufficientMoneyException " + e));
}
}

View File

@ -49,7 +49,7 @@ public class HandleTakeOfferRequest {
@Override
public void onFailed() {
log.error("AcceptTakeOfferRequestMessage did not arrive at peer");
exceptionHandler.onError(new Exception("AcceptTakeOfferRequestMessage did not arrive at peer"));
exceptionHandler.handleException(new Exception("AcceptTakeOfferRequestMessage did not arrive at peer"));
}
});
}

View File

@ -48,13 +48,14 @@ public class RequestTakerDepositPayment {
@Override
public void onResult() {
log.trace("RequestTakerDepositPaymentMessage successfully arrived at peer");
resultHandler.onResult();
resultHandler.handleResult();
}
@Override
public void onFailed() {
log.error("RequestTakerDepositPaymentMessage did not arrive at peer");
exceptionHandler.onError(new Exception("RequestTakerDepositPaymentMessage did not arrive at peer"));
exceptionHandler.handleException(new Exception("RequestTakerDepositPaymentMessage did not arrive at " +
"peer"));
}
});
}

View File

@ -43,13 +43,13 @@ public class SendDepositTxIdToTaker {
@Override
public void onResult() {
log.trace("DepositTxPublishedMessage successfully arrived at peer");
resultHandler.onResult();
resultHandler.handleResult();
}
@Override
public void onFailed() {
log.error("DepositTxPublishedMessage did not arrive at peer");
exceptionHandler.onError(new Exception("DepositTxPublishedMessage did not arrive at peer"));
exceptionHandler.handleException(new Exception("DepositTxPublishedMessage did not arrive at peer"));
}
});
}

View File

@ -72,19 +72,19 @@ public class SendSignedPayoutTx {
@Override
public void onResult() {
log.trace("BankTransferInitedMessage successfully arrived at peer");
resultHandler.onResult();
resultHandler.handleResult();
}
@Override
public void onFailed() {
log.error("BankTransferInitedMessage did not arrive at peer");
exceptionHandler.onError(new Exception("BankTransferInitedMessage did not arrive at peer"));
exceptionHandler.handleException(new Exception("BankTransferInitedMessage did not arrive at peer"));
}
});
} catch (Exception e) {
log.error("Exception at OffererCreatesAndSignsPayoutTx " + e);
exceptionHandler.onError(e);
exceptionHandler.handleException(e);
}
}
}

View File

@ -44,7 +44,7 @@ public class SetupListenerForBlockChainConfirmation {
listener.onDepositTxConfirmedInBlockchain();
depositTransaction.getConfidence().removeEventListener(this);
log.trace("Tx is in blockchain");
resultHandler.onResult();
resultHandler.handleResult();
}
}
});

View File

@ -59,12 +59,12 @@ public class SignAndPublishDepositTx {
@Override
public void onFailure(@NotNull Throwable t) {
log.error("offererSignAndPublishTx faultHandler.onFault:" + t);
exceptionHandler.onError(t);
exceptionHandler.handleException(t);
}
});
} catch (Exception e) {
log.error("offererSignAndPublishTx faultHandler.onFault:" + e);
exceptionHandler.onError(e);
exceptionHandler.handleException(e);
}
}

View File

@ -33,7 +33,7 @@ public class VerifyTakeOfferFeePayment {
//TODO mocked yet, need a confidence listeners
int numOfPeersSeenTx = walletFacade.getNumOfPeersSeenTx(takeOfferFeeTxId);
if (numOfPeersSeenTx > 2) {
resultHandler.onResult();
resultHandler.handleResult();
}
}

View File

@ -34,15 +34,16 @@ public class VerifyPeerAccount {
if (blockChainFacade.verifyAccountRegistration()) {
if (blockChainFacade.isAccountBlackListed(peersAccountId, peersBankAccount)) {
log.error("Taker is blacklisted");
exceptionHandler.onError(new Exception("Taker is blacklisted"));
exceptionHandler.handleException(new Exception("Taker is blacklisted"));
}
else {
resultHandler.onResult();
resultHandler.handleResult();
}
}
else {
log.error("Account registration validation for peer faultHandler.onFault.");
exceptionHandler.onError(new Exception("Account registration validation for peer faultHandler.onFault."));
exceptionHandler.handleException(new Exception("Account registration validation for peer faultHandler" +
".onFault."));
}
}

View File

@ -58,7 +58,7 @@ public class CreateAndSignContract {
resultHandler.onResult(contract, contractAsJson, signature);
} catch (Throwable t) {
log.error("Exception at sign contract " + t);
exceptionHandler.onError(t);
exceptionHandler.handleException(t);
}
}

View File

@ -43,7 +43,7 @@ public class GetPeerAddress {
@Override
public void onFailed() {
log.error("Lookup for peer address faultHandler.onFault.");
exceptionHandler.onError(new Exception("Lookup for peer address faultHandler.onFault."));
exceptionHandler.handleException(new Exception("Lookup for peer address faultHandler.onFault."));
}
});
}

View File

@ -57,7 +57,7 @@ public class PayDeposit {
resultHandler.onResult(signedTakerDepositTx);
} catch (InsufficientMoneyException e) {
log.error("Pay deposit faultHandler.onFault due InsufficientMoneyException " + e);
exceptionHandler.onError(
exceptionHandler.handleException(
new Exception("Pay deposit faultHandler.onFault due InsufficientMoneyException " + e));
}
}

View File

@ -47,13 +47,13 @@ public class PayTakeOfferFee {
@Override
public void onFailure(@NotNull Throwable t) {
log.error("Take offer fee paid faultHandler.onFault with exception: " + t);
exceptionHandler.onError(
exceptionHandler.handleException(
new Exception("Take offer fee paid faultHandler.onFault with exception: " + t));
}
});
} catch (InsufficientMoneyException e) {
log.error("Take offer fee paid faultHandler.onFault due InsufficientMoneyException " + e);
exceptionHandler.onError(
exceptionHandler.handleException(
new Exception("Take offer fee paid faultHandler.onFault due to InsufficientMoneyException " + e));
}
}

View File

@ -38,13 +38,14 @@ public class RequestTakeOffer {
@Override
public void onResult() {
log.trace("RequestTakeOfferMessage successfully arrived at peer");
resultHandler.onResult();
resultHandler.handleResult();
}
@Override
public void onFailed() {
log.error("RequestTakeOfferMessage did not arrive at peer");
exceptionHandler.onError(new Exception("RequestTakeOfferMessage did not arrive at peer"));
exceptionHandler.handleException(new Exception("RequestTakeOfferMessage did not arrive at " +
"peer"));
}
});
}

View File

@ -38,13 +38,13 @@ public class SendPayoutTxToOfferer {
@Override
public void onResult() {
log.trace("PayoutTxPublishedMessage successfully arrived at peer");
resultHandler.onResult();
resultHandler.handleResult();
}
@Override
public void onFailed() {
log.error("PayoutTxPublishedMessage did not arrive at peer");
exceptionHandler.onError(new Exception("PayoutTxPublishedMessage did not arrive at peer"));
exceptionHandler.handleException(new Exception("PayoutTxPublishedMessage did not arrive at peer"));
}
});

View File

@ -72,13 +72,13 @@ public class SendSignedTakerDepositTxAsHex {
@Override
public void onResult() {
log.trace("RequestOffererDepositPublicationMessage successfully arrived at peer");
resultHandler.onResult();
resultHandler.handleResult();
}
@Override
public void onFailed() {
log.error("RequestOffererDepositPublicationMessage did not arrive at peer");
exceptionHandler.onError(
exceptionHandler.handleException(
new Exception("RequestOffererDepositPublicationMessage did not arrive at peer"));
}
});

View File

@ -48,13 +48,13 @@ public class SendTakeOfferFeePayedTxId {
@Override
public void onResult() {
log.trace("TakeOfferFeePayedMessage successfully arrived at peer");
resultHandler.onResult();
resultHandler.handleResult();
}
@Override
public void onFailed() {
log.error("TakeOfferFeePayedMessage did not arrive at peer");
exceptionHandler.onError(new Exception("TakeOfferFeePayedMessage did not arrive at peer"));
exceptionHandler.handleException(new Exception("TakeOfferFeePayedMessage did not arrive at peer"));
}
});
}

View File

@ -65,12 +65,12 @@ public class SignAndPublishPayoutTx {
@Override
public void onFailure(@NotNull Throwable t) {
log.error("Exception at takerSignsAndSendsTx " + t);
exceptionHandler.onError(t);
exceptionHandler.handleException(t);
}
});
} catch (Exception e) {
log.error("Exception at takerSignsAndSendsTx " + e);
exceptionHandler.onError(e);
exceptionHandler.handleException(e);
}
}

View File

@ -21,5 +21,5 @@ package io.bitsquare.util.task;
* For reporting error message only (UI)
*/
public interface ErrorMessageHandler {
void onFault(String errorMessage);
void handleErrorMessage(String errorMessage);
}

View File

@ -21,5 +21,5 @@ package io.bitsquare.util.task;
* For reporting throwables only
*/
public interface ExceptionHandler {
void onError(Throwable throwable);
void handleException(Throwable throwable);
}

View File

@ -21,5 +21,5 @@ package io.bitsquare.util.task;
* For reporting a description message and throwable
*/
public interface FaultHandler {
void onFault(String message, Throwable throwable);
void handleFault(String message, Throwable throwable);
}

View File

@ -18,5 +18,5 @@
package io.bitsquare.util.task;
public interface ResultHandler {
void onResult();
void handleResult();
}