|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.proxy.SunProxy
public class SunProxy
Sun Specific implementation of a SocketFactory and proxy-decider that work together to decipher the specifics of the Sun Internet setup.
NOTE: The mechanism used by this class has been disabled; it is included here to illustrate how to write a custom proxy.
Field Summary |
---|
Fields inherited from interface sunlabs.brazil.util.SocketFactory |
---|
defaultFactory |
Constructor Summary | |
---|---|
SunProxy()
|
Method Summary | |
---|---|
boolean |
init(Server server,
java.lang.String prefix)
Called when the Server is being initialized to install
this object as the SocketFactory for the
HttpRequest . |
java.net.Socket |
newSocket(java.lang.String host,
int port)
Creates a new Socket that talks to the specified port
on the named host. |
boolean |
respond(Request request)
Handler http requests - doesn't do anything yet |
boolean |
useProxy(java.lang.String host,
int port)
Determines if the user should use an HTTP proxy when sending an HTTP request to the specified host and port. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SunProxy()
Method Detail |
---|
public boolean init(Server server, java.lang.String prefix)
Server
is being initialized to install
this object as the SocketFactory
for the
HttpRequest
.
This procedure is very specific and specialized to the Brazil server. This functionality should probably be moved into a separate "Init" class that:
SunProxy
class.
SocketFactory
.
As it stands now, the first time this method is called, the side
effect is to install itself as the SocketFactory
.
This method will also be called subsequently when instances of the
ProxyHandler
instantiate this object as a
UseProxy
decider, but in that case, no configuration
properties need to be examined.
init
in interface Handler
server
- The http server that owns this object. This object uses
Server.props
to obtain run time configuration
information.prefix
- A prefix to prepend to all of the keys that this object
uses to extract configuration information out of
Server.props
.
true
always, indicating success.public boolean respond(Request request)
respond
in interface Handler
request
- The Request
object that represents the HTTP
request.
true
if the request was handled. A request was
handled if a response was supplied to the client, typically
by calling Request.sendResponse()
or
Request.sendError
.public boolean useProxy(java.lang.String host, int port)
Whether or not to proxy may depend upon the HTTP proxy the caller is using. Currently, there is no way to capture and use this information.
The decision is different than deciding if the host is local, because
using the itelnet tunnelling trick we can reach some external hosts
from within the firewall. This routine is therefore in cohoots with
the itelnet behavior, and requires that the caller use this object
as the SocketFactory
if this method returns
true
.
Observed behavior:
false
.
false
.
true
.
useProxy
in interface UseProxy
host
- The host name.port
- The port number.
true
if the user should send the HTTP request
via an HTTP proxy, false
if the user can
send the HTTP request directly to the specified named host.public java.net.Socket newSocket(java.lang.String host, int port) throws java.io.IOException
SocketFactory
Socket
that talks to the specified port
on the named host.
The implementation may choose any way it wants to provide a
socket-like object (essentially any mechanism that supports
bidirectional communication). The returned Socket
(or
subclass of Socket
) might not be based on TCP/IP, or it
might involve running a TCP/IP stack over some other protocol, or it
might actually redirect all connections via some other proxy machine,
etc.
newSocket
in interface SocketFactory
host
- The host name.port
- The port number.
java.io.IOException
- If there is some problem establishing the socket to the
specified port on the named host.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |