1 17 package org.apache.servicemix.components.wsif; 18 19 import java.util.HashMap ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 import java.util.Map ; 23 24 import javax.jbi.messaging.MessageExchange; 25 import javax.wsdl.Binding; 26 import javax.wsdl.BindingOperation; 27 import javax.wsdl.Operation; 28 import javax.xml.namespace.QName ; 29 30 import org.apache.servicemix.jbi.NoSuchOperationException; 31 import org.apache.wsif.WSIFException; 32 import org.apache.wsif.WSIFService; 33 34 39 public class WSIFOperationMap { 40 41 private WSIFService service; 42 private Map operationMap = new HashMap (); 43 private WSIFOperationInfo defaultOperation; 44 45 public WSIFOperationMap(WSIFService service) { 46 this.service = service; 47 } 48 49 56 public WSIFOperationInfo getOperationForExchange(MessageExchange exchange) throws NoSuchOperationException { 57 QName operationName = exchange.getOperation(); 58 WSIFOperationInfo operationInfo = getOperation(operationName); 59 if (operationInfo == null) { 60 throw new NoSuchOperationException(operationName); 61 } 62 return operationInfo; 63 } 64 65 71 public WSIFOperationInfo getOperation(QName operationName) { 72 if (operationName == null) { 73 return defaultOperation; 75 } 76 return (WSIFOperationInfo) operationMap.get(operationName); 77 } 78 79 public int getOperationCount() { 80 return operationMap.values().size(); 81 } 82 83 89 public WSIFOperationInfo getOperation(String operationName) { 90 return (WSIFOperationInfo) operationMap.get(operationName); 91 } 92 93 public void addBinding(Binding binding) throws WSIFException { 94 List list = binding.getBindingOperations(); 95 for (Iterator iter = list.iterator(); iter.hasNext();) { 96 BindingOperation bindingOperation = (BindingOperation) iter.next(); 97 addBindingOperation(binding, bindingOperation); 98 } 99 } 100 101 protected void addBindingOperation(Binding binding, BindingOperation bindingOperation) throws WSIFException { 102 Operation operation = bindingOperation.getOperation(); 103 String name = operation.getName(); 104 WSIFOperationInfo info = new WSIFOperationInfo(service.getPort(), name); 105 operationMap.put(name, info); 106 operationMap.put(new QName (name), info); 107 if (defaultOperation == null) { 108 defaultOperation = info; 109 } 110 } 111 112 } 113 | Popular Tags |