}
public void handleMessage(Message message) {
try {
Operation operation = message.get(Operation.class);
MessageExchange exchange;
NormalizedMessage nm;
// Create message
if (server) {
exchange = createExchange(message);
if (operation != null) {
exchange.setOperation(operation.getName());
}
nm = exchange.createMessage();
exchange.setMessage(nm, "in");
message.setContent(MessageExchange.class, exchange);
} else {
exchange = message.getContent(MessageExchange.class);
if (exchange == null) {
throw new IllegalStateException("Content of type " + MessageExchange.class + " not found on message");
}
if (message.getContent(Exception.class) == null) {
nm = exchange.getMessage("out");
if (nm == null) {
nm = exchange.createMessage();
exchange.setMessage(nm, "out");
}
} else {
exchange.setFault(exchange.createFault());
nm = exchange.getFault();
}
}
// Put headers
toNMSHeaders(nm, message);
// Put attachments