private void setTerminateSequence(Message msg, Identifier identifier, ProtocolVariation protocol)
throws RMException {
TerminateSequenceType ts = new TerminateSequenceType();
ts.setIdentifier(identifier);
MessageContentsList contents =
new MessageContentsList(new Object[]{protocol.getCodec().convertToSend(ts)});
msg.setContent(List.class, contents);
Exchange newex = new ExchangeImpl();
Exchange oldex = msg.getExchange();
newex.put(Bus.class, oldex.getBus());
newex.put(Endpoint.class, oldex.getEndpoint());
newex.put(Service.class, oldex.getEndpoint().getService());
newex.put(Binding.class, oldex.getEndpoint().getBinding());
newex.setConduit(oldex.getConduit(msg));
newex.setDestination(oldex.getDestination());
RMEndpoint rmep = getManager().getReliableEndpoint(msg);
OperationInfo oi = rmep.getEndpoint(protocol).getEndpointInfo().getService().getInterface()
.getOperation(protocol.getConstants().getTerminateSequenceAnonymousOperationName());
BindingInfo bi = rmep.getBindingInfo(protocol);
BindingOperationInfo boi = bi.getOperation(oi);
newex.put(BindingInfo.class, bi);
newex.put(BindingOperationInfo.class, boi);
msg.setExchange(newex);
newex.setOutMessage(msg);
}