in modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java [95:184]
protected Operation getTargetOperation(String operationName, javax.jms.Message jmsMsg) {
Operation operation = null;
if (serviceOperations.size() == 1) {
// SCA JMS Binding Specification - Rule 1.5.1 line 203
operation = serviceOperations.get(0);
} else if (operationName != null) {
// SCA JMS Binding Specification - Rule 1.5.1 line 205
for (Operation op : serviceOperations) {
if (op.getName().equals(operationName)) {
operation = op;
break;
} else {
String nativeName = jmsBinding.getNativeOperationName(op.getName());
if (( nativeName != null ) && ( nativeName.equals(operationName)) ) {
operation = op;
break;
}
}
}
} else if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault
|| jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML
|| jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytesXML) {
String operationFromPayload;
try {
if (jmsMsg instanceof TextMessage) {
String xmlPayload = ((TextMessage) jmsMsg).getText();
if (xmlPayload != null) {
Object rootElement = xmlHelper.load(xmlPayload);
operationFromPayload = xmlHelper.getOperationName(rootElement);
if (operationFromPayload != null) {
for (Operation op : serviceOperations) {
if (op.getName().equals(operationFromPayload)) {
operation = op;
break;
}
}
}
}
} else if (jmsMsg instanceof BytesMessage) {
long noOfBytes = ((BytesMessage) jmsMsg).getBodyLength();
byte[] bytes = new byte[(int) noOfBytes];
((BytesMessage) jmsMsg).readBytes(bytes);
((BytesMessage) jmsMsg).reset();
if (bytes != null) {
Object rootElement = xmlHelper.load(new String(bytes));
operationFromPayload = xmlHelper.getOperationName(rootElement);
if (operationFromPayload != null) {
for (Operation op : serviceOperations) {
if (op.getName().equals(operationFromPayload)) {
operation = op;
break;
}
}
}
}
}
} catch (IOException e) {
//let's ignore this in case the client doesn't want to use a wrapped xml message
} catch (JMSException e) {
throw new JMSBindingException(e);
}
// If operation is still null we attempt the last rule
if (operation == null) {
// SCA JMS Binding Specification - Rule 1.5.1 line 207
for (Operation op : serviceOperations) {
if (op.getName().equals(ON_MESSAGE_METHOD_NAME)) {
operation = op;
break;
}
}
}
}
if (operation == null) {
throw new JMSBindingException("Cannot determine service operation");
}
return operation;
}