|
From: John S. <jo...@we...> - 2007-01-27 19:58:44
|
Alan,
I may not be reading it right, but you seem to have redesigned the entire
package rather than documenting the package as it is. The system is rather
simple, perhaps too much so, but I don't want to deviate from that simple
design unless absolutely positively necessary. We currently have a system
that is designed thusly, forgive my use of English rather than uml to
describe this, I do not speak fluent uml and so I think better in English ;)
1. we have a Proxy object that opens a port and behaves as an http proxy,
accepting connections on whatever port specified ie:
Proxy p = new Proxy( new InetAddress(), 8080, 50);
Then to manipulate requests and responses we have objects which implement
the HttpMessageProcessor interface. This would be how a user would, for
instance, change the HttpMessage as appropriate to support some special use
case, ie passing everything to yet another proxy via something like:
public class ProxyMessageProcessor implements HttpMessageProcessor {
private com.wpg.Util.Proxy proxy = null;
public ProxyMessageProcessor( com.wpg.Util.Proxy proxy ) {
this.proxy=proxy; }
private Logger logger =
Logger.getLogger(ProxyMessageProcessor.class);
public boolean doContinue(HttpMessage input) { return true; }
public boolean doSend(HttpMessage input) { return true; }
public HttpMessage process( HttpMessage input ) {
logger.debug("Start Line: "+ input.getStartLine() );
HttpMessageRequest message = (HttpMessageRequest) input;
logger.debug("Trying converting tohost to proxy");
int port = message.getToPort();
String newURI = (port==443?"https://":"http://") +
message.getToHost() +(port==80 || port==443?"":":"+ message.getToPort()) +
message.getUri();
try{
message.setUri(newURI);
} catch( java.net.URISyntaxException e ) {
logger.error("Error setting uri to: "+ newURI +"
Exception: "+ e, e);
}
message.setToHost(proxy.host);
message.setToPort(proxy.port);
if( !proxy.user.equals("") ) {
HashMap headers = (HashMap) message.getHeaders();
Vector header = new Vector();
header.addElement( proxy.getEncodedAuthorization()
);
headers.put("proxy-authorization", header);
}
return message;
}
}
Then when a user wants to do something special with the requests or
responses, as in log them or record them somehow they would implement the
HttpMessageListener interface and have at it.
The HttpMessageListener is defined at:
http://wpg-proxy.sourceforge.net/com/wpg/proxy/HttpMessageListener.html
The idea is to register these listeners and processors then for each
connection run through them in the order registered. This allows the proxy
to be a filter, logger, protocol translator, anything. As needed by the
project/programmer. I see several seperations of functionality in your
model that I don't quite understand why you want to remove the HttpMessage
and the HttpMessageRequest and HttpMessageResponse extended from it, that
solves so many issues in such an elegant way for me as a programmer. I
would entertain adding or changing some of the calls in the listener and
processor since that makes the most sense to me with the design in place,
however I don't think we can simplify it to "init", "handle", and "abort"
since under certain situations some data is available and some is not, we
could reduce the listerner interface from currently three separate "failed"
methods with different arguments to simple one with null arguments when
unavailable, for instance just this:
failed(HttpMessageResponse response, HttpMessageRequest request,
java.lang.Exception exception)
However the logic for the two received methods I still prefer, one is called
when a request is received, the other when a response is received, perhaps
we could rename them to "requestReceived" and "responseReceived" in that
order?
As far as the way the proxy handles connections I do preffer the single
Proxy class looping through a NIO handler, and would like to stay with that
design. I am not 100% sure from the uml what is meant by a
"ProxyConnection" object or the "ProxyServer" being initialized with arrays
of requestHandlers (which I translate to the current processors) and an
array of responseHandlers (which we currently call listeners). I would be
willing to refactor those names into something more appropriate if they are
confusing, but redesigning the way the system is called or used seems
unnecissary.
Am I off the mark with any of this? Does it make sense? Do you see any way
of adding SSL support without rewriting the entire library?
Should we discuss via skype? I have the client installed and registered a
user JohnSoutherland5.
Thanks, John
-----Original Message-----
From: wpg...@li...
[mailto:wpg...@li...] On Behalf Of
Alan Moran
Sent: Saturday, January 27, 2007 1:54 PM
To: wpg...@li...
Subject: Re: [Wpg-proxy-development] draft uml design
John,
Thanks for the reminder ! I have added a PNG to the
SVN.
BTW: citing design is not my way of claiming that it
is currently defective :) Just want to get ideas
straight before we jump into more complicated issues
and to make it easy for the unit testing etc. I am
adding to this design so will checkin more again
tomorrow if I am ready by then.
Thanks,
A.
--- John Southerland <jo...@we...>
schrieb:
> Alan,
> Can you create a pretty picture and send that out to
> us UML challenged
> people?
> Also please note that you can fire up a proxy by
> running the main method of
> the Proxy class, I am currently using the version of
> this code we are
> dealing with in another program with 98%
> reliability.
> I'm very interested in seeing this UML design.
> Thanks, John
>
---------------------------------------------------
You can find my GPG key (a_j...@ya...) at
ETH PGP Keyserver: http://www.tik.ee.ethz.ch/~pgp/
---------------------------------------------------
___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wpg-proxy-development mailing list
Wpg...@li...
https://lists.sourceforge.net/lists/listinfo/wpg-proxy-development
|