1 10 11 package org.mule.providers.soap.glue; 12 13 import org.mule.providers.AbstractServiceEnabledConnector; 14 import org.mule.umo.UMOComponent; 15 import org.mule.umo.endpoint.UMOEndpoint; 16 import org.mule.umo.provider.UMOMessageReceiver; 17 18 import java.net.URI ; 19 import java.net.URISyntaxException ; 20 import java.util.ArrayList ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 import java.util.Map ; 24 25 32 33 public class GlueConnector extends AbstractServiceEnabledConnector 34 { 35 private List serverEndpoints = new ArrayList (); 36 private Map context; 37 38 public GlueConnector() 39 { 40 super(); 41 registerSupportedProtocol("http"); 42 } 43 44 public String getProtocol() 45 { 46 return "glue"; 47 } 48 49 public UMOMessageReceiver createReceiver(UMOComponent component, UMOEndpoint endpoint) throws Exception 50 { 51 boolean createServer = shouldCreateServer(endpoint.getEndpointURI().getAddress()); 52 53 UMOMessageReceiver receiver = serviceDescriptor.createMessageReceiver(this, component, endpoint, 54 new Object []{Boolean.valueOf(createServer)}); 55 56 if (createServer) 57 { 58 serverEndpoints.add(endpoint.getEndpointURI().getAddress()); 59 } 60 return receiver; 61 } 62 63 protected Object getReceiverKey(UMOComponent component, UMOEndpoint endpoint) 64 { 65 return endpoint.getEndpointURI().getAddress() + "/" + component.getDescriptor().getName(); 66 } 67 68 private boolean shouldCreateServer(String endpoint) throws URISyntaxException 69 { 70 URI uri = new URI (endpoint); 71 String ep = uri.getScheme() + "://" + uri.getHost(); 72 if (uri.getPort() != -1) 73 { 74 ep += ":" + uri.getPort(); 75 } 76 77 for (Iterator iterator = serverEndpoints.iterator(); iterator.hasNext();) 78 { 79 String s = (String )iterator.next(); 80 if (s.startsWith(ep)) 81 { 82 return false; 83 } 84 } 85 return true; 86 } 87 88 public Map getContext() 89 { 90 return context; 91 } 92 93 public void setContext(Map context) 94 { 95 this.context = context; 96 } 97 98 public boolean supportsProtocol(String protocol) 99 { 100 return super.supportsProtocol(protocol) || protocol.toLowerCase().equals("glue:http"); 101 } 102 } 103 | Popular Tags |