1 45 package org.exolab.jms.net.http; 46 47 import java.security.Principal ; 48 import java.util.Iterator ; 49 import java.util.List ; 50 51 import org.exolab.jms.net.connector.ConnectionRequestInfo; 52 import org.exolab.jms.net.connector.ManagedConnection; 53 import org.exolab.jms.net.connector.ManagedConnectionAcceptor; 54 import org.exolab.jms.net.connector.ManagedConnectionFactory; 55 import org.exolab.jms.net.connector.ResourceException; 56 import org.exolab.jms.net.socket.SocketManagedConnectionAcceptor; 57 import org.exolab.jms.net.socket.SocketRequestInfo; 58 import org.exolab.jms.net.uri.URI; 59 import org.exolab.jms.net.uri.URIHelper; 60 61 62 69 public abstract class AbstractHTTPManagedConnectionFactory 70 implements ManagedConnectionFactory { 71 72 82 public ManagedConnection matchManagedConnections(List connections, 83 Principal principal, 84 ConnectionRequestInfo info) 85 throws ResourceException { 86 ManagedConnection result = null; 87 88 if (info instanceof HTTPRequestInfo) { 89 HTTPRequestInfo requestInfo = (HTTPRequestInfo) info; 90 URI uri = URIHelper.convertHostToAddress(requestInfo.getURI()); 91 Iterator iterator = connections.iterator(); 92 while (iterator.hasNext()) { 93 AbstractHTTPManagedConnection connection = 94 (AbstractHTTPManagedConnection) iterator.next(); 95 if (connection.hasPrincipal(principal) 96 && (uri.equals(connection.getRemoteURI()) 97 || uri.equals(connection.getLocalURI()))) { 98 result = connection; 99 break; 100 } 101 } 102 } 103 return result; 104 } 105 106 116 public ManagedConnectionAcceptor matchManagedConnectionAcceptors( 117 List acceptors, ConnectionRequestInfo info) 118 throws ResourceException { 119 ManagedConnectionAcceptor result = null; 120 121 if (info instanceof SocketRequestInfo) { 122 Iterator iterator = acceptors.iterator(); 123 while (iterator.hasNext()) { 124 SocketManagedConnectionAcceptor acceptor = 125 (SocketManagedConnectionAcceptor) iterator.next(); 126 if (info.equals(acceptor.getRequestInfo())) { 127 result = acceptor; 128 break; 129 } 130 } 131 } 132 return result; 133 } 134 } 135 | Popular Tags |