org.mmbase.servlet.rmi
Class RMIHandlerServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.mmbase.servlet.MMBaseServlet
org.mmbase.servlet.rmi.RMIHandlerServlet
- All Implemented Interfaces:
- org.mmbase.servlet.MMBaseStarter, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class RMIHandlerServlet
- extends MMBaseServlet
The default RMI socket factory contains several "fallback"
mechanisms which enable an RMI client to communicate with a remote
server. When an RMI client initiates contact with a remote server,
it attempts to establish a connection using each of the following
protocols in turn, until one succeeds:
1. Direct TCP connection.
2. Direct HTTP connection.
3. Proxy connection (SOCKS or HTTP).
4. Connection on port 80 over HTTP to a CGI script.
5. Proxy HTTP connection to CGI script on port 80.
The RMI ServletHandler can be used as replacement for the
java-rmi.cgi script that comes with the Java Development Kit (and
is invoked in protocols 4 and 5 above). The java-rmi.cgi script
and the ServletHandler both function as proxy applications that
forward remote calls embedded in HTTP to local RMI servers which
service these calls. The RMI ServletHandler enables RMI to tunnel
remote method calls over HTTP more efficiently than the existing
java-rmi.cgi script. The ServletHandler is only loaded once from
the servlet administration utility. The script, java-rmi.cgi, is
executed once every remote call.
The ServletHandler class contains methods for executing as a Java
servlet extension. Because the RMI protocol only makes use of the
HTTP post command, the ServletHandler only supports the
doPost HttpServlet method. The
doPost method of this class interprets a servlet
request's query string as a command of the form
"=". These commands are represented by the
abstract interface, RMICommandHandler. Once the
doPost method has parsed the requested command, it
calls the execute method on one of several command handlers in the
commands array.
The command that actually proxies remote calls is the
ServletForwardCommand. When the execute method is
invoked on the ServletForwardCommand, the command will open a
connection on a local port specified by its param
parameter and will proceed to write the body of the relevant post
request into this connection. It is assumed that an RMI server
(e.g. SampleRMIServer) is listening on the local port, "param."
The "forward" command will then read the RMI server's response and
send this information back to the RMI client as the body of the
response to the HTTP post method.
Because the ServletHandler uses a local socket to proxy remote
calls, the servlet has the ability to forward remote calls to local
RMI objects that reside in the ServletVM or outside of it.
Servlet documentation may be found at the following location:
http://jserv.javasoft.com/products/java-server/documentation/
webserver1.0.2/apidoc/Package-javax.servlet.http.html
- See Also:
- Serialized Form
|
Method Summary |
void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Provide more intelligible errors for methods that are likely to
be called. |
void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
|
void |
doPut(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
|
void |
forward(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
Execute the forward command. |
void |
getHostname(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
|
java.lang.String |
getServletInfo()
Returns information about this servlet. |
void |
hostname(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
|
void |
init(javax.servlet.ServletConfig config)
|
void |
ping(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
|
| Methods inherited from class org.mmbase.servlet.MMBaseServlet |
associateMapping, decRefCount, destroy, getAssociations, getMMBase, getRequestURL, getServletByAssociation, getServletByMapping, getServletMappings, getServletMappingsByAssociation, incRefCount, init, service, setInitException, setMMBase |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doTrace, getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, log, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RMIHandlerServlet
public RMIHandlerServlet()
init
public void init(javax.servlet.ServletConfig config)
throws javax.servlet.ServletException
- Throws:
javax.servlet.ServletException
doPost
public void doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException,
java.io.IOException
- Throws:
javax.servlet.ServletException
java.io.IOException
doGet
public void doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException,
java.io.IOException
- Provide more intelligible errors for methods that are likely to
be called. Let unsupported HTTP "do*" methods result in an
error generated by the super class.
- Overrides:
doGet in class MMBaseServlet
- Parameters:
req - http Servlet request, contains incoming command and
argumentsres - http Servlet response
- Throws:
javax.servlet.ServletException - and IOException when invoking
methods of req or res.
java.io.IOException
doPut
public void doPut(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException,
java.io.IOException
- Throws:
javax.servlet.ServletException
java.io.IOException
getServletInfo
public java.lang.String getServletInfo()
- Description copied from class:
MMBaseServlet
- Returns information about this servlet. Don't forget to override it.
- Specified by:
getServletInfo in interface javax.servlet.Servlet- Overrides:
getServletInfo in class MMBaseServlet
forward
public void forward(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
throws RMIHandlerServlet.ServletClientException,
RMIHandlerServlet.ServletServerException,
java.io.IOException
- Execute the forward command. Forwards data from incoming servlet
request to a port on the local machine. Presumably, an RMI server
will be reading the data that this method sends.
- Parameters:
req - The servlet request.res - The servlet response.param - Port to which data will be sent.
- Throws:
RMIHandlerServlet.ServletClientException
RMIHandlerServlet.ServletServerException
java.io.IOException
getHostname
public void getHostname(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
throws RMIHandlerServlet.ServletClientException,
RMIHandlerServlet.ServletServerException,
java.io.IOException
- Throws:
RMIHandlerServlet.ServletClientException
RMIHandlerServlet.ServletServerException
java.io.IOException
ping
public void ping(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
throws RMIHandlerServlet.ServletClientException,
RMIHandlerServlet.ServletServerException,
java.io.IOException
- Throws:
RMIHandlerServlet.ServletClientException
RMIHandlerServlet.ServletServerException
java.io.IOException
hostname
public void hostname(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String param)
throws RMIHandlerServlet.ServletClientException,
RMIHandlerServlet.ServletServerException,
java.io.IOException
- Throws:
RMIHandlerServlet.ServletClientException
RMIHandlerServlet.ServletServerException
java.io.IOException
MMBase build 1.7.1.20041002