public void handleSend(boolean sync) throws MessagingException {
// Check if send / sendSync is legal
if (sync) {
if (!can(CAN_SEND_SYNC)) {
throw new MessagingException("illegal call to sendSync");
}
} else {
if (!can(CAN_SEND)) {
throw new MessagingException("illegal call to send");
}
}
this.syncState = sync ? SYNC_STATE_SYNC_SENT : SYNC_STATE_ASYNC;
// Check status
ExchangeStatus status = getStatus();
if (status == ExchangeStatus.ACTIVE && !can(CAN_STATUS_ACTIVE)) {
throw new MessagingException("illegal exchange status: active");
}
if (status == ExchangeStatus.DONE && !can(CAN_STATUS_DONE)) {
throw new MessagingException("illegal exchange status: done");
}
if (status == ExchangeStatus.ERROR && !can(CAN_STATUS_ERROR)) {
throw new MessagingException("illegal exchange status: error");
}
// Check message
// Change state
if (status == ExchangeStatus.ACTIVE) {
this.state = this.states[this.state][STATES_NEXT_MSG];