protected MessageExchange getExchange(byte[] data) throws AuditorException {
ExchangePacket packet = null;
try {
packet = ExchangePacket.readPacket(data);
} catch (Exception e) {
throw new AuditorException("Unable to reconstruct exchange", e);
}
URI mep = packet.getPattern();
if (MessageExchangeSupport.IN_ONLY.equals(mep)) {
return new InOnlyImpl(packet);
} else if (MessageExchangeSupport.IN_OPTIONAL_OUT.equals(mep)) {
return new InOptionalOutImpl(packet);
} else if (MessageExchangeSupport.IN_OUT.equals(mep)) {
return new InOutImpl(packet);
} else if (MessageExchangeSupport.ROBUST_IN_ONLY.equals(mep)) {
return new RobustInOnlyImpl(packet);
} else {
throw new AuditorException("Unhandled mep: " + mep);
}
}