1 45 package org.exolab.jms.net.http; 46 47 import java.io.DataInputStream ; 48 import java.io.DataOutputStream ; 49 import java.io.IOException ; 50 import java.security.Principal ; 51 52 import EDU.oswego.cs.dl.util.concurrent.PooledExecutor; 53 54 import org.exolab.jms.net.connector.*; 55 import org.exolab.jms.net.connector.SecurityException; 56 import org.exolab.jms.net.multiplexer.Endpoint; 57 import org.exolab.jms.net.multiplexer.Multiplexer; 58 import org.exolab.jms.net.multiplexer.MultiplexerListener; 59 import org.exolab.jms.net.uri.URI; 60 import org.exolab.jms.net.uri.URIHelper; 61 62 63 69 class HTTPMultiplexer extends Multiplexer { 70 71 74 private URI _clientURI; 75 76 77 88 public HTTPMultiplexer(MultiplexerListener listener, Endpoint endpoint, 89 URI clientURI, Principal principal, 90 PooledExecutor pool) 91 throws IOException , SecurityException { 92 if (clientURI == null) { 93 throw new IllegalArgumentException ("Argument 'clientURI' is null"); 94 } 95 _clientURI = clientURI; 96 initialise(listener, endpoint, pool, true); 97 authenticate(principal); 98 } 99 100 110 public HTTPMultiplexer(MultiplexerListener listener, Endpoint endpoint, 111 Authenticator authenticator, PooledExecutor pool) 112 throws IOException , ResourceException { 113 super(listener, endpoint, authenticator, pool); 114 } 115 116 121 public URI getClientURI() { 122 return _clientURI; 123 } 124 125 133 protected void handshake(DataOutputStream out, DataInputStream in) 134 throws IOException { 135 super.handshake(out, in); 136 if (isClient()) { 137 out.writeUTF(_clientURI.toString()); 138 } else { 139 String uri = in.readUTF(); 140 _clientURI = URIHelper.parse(uri); 141 } 142 } 143 144 } 145 | Popular Tags |