public abstract class DirectServlet
extends javax.servlet.http.HttpServlet
| Modifier and Type | Field and Description |
|---|---|
protected EntityRequestHandler |
entityRequestHandler |
| Constructor and Description |
|---|
DirectServlet()
Default constructor
|
DirectServlet(EntityRequestHandler entityRequestHandler)
Allow the request handler to be set on this servlet,
probably best to only use this for testing
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispatch(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
handle all communication from the user not related to login
|
protected abstract String |
getCurrentLoggedInUserId()
This should return the userId for the currently logged in user if there is one,
if not user is logged in then this should return null
|
protected void |
handleRequest(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Handle the incoming request (get and post handled in the same way), passes control to the
dispatch method or calls the login helper, override this to control it
|
protected abstract void |
handleUserLogin(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
String path)
Handle the user authentication (login) in a system specific way,
by default this will simply fail as entity-broker has no way to authenticate
|
void |
init() |
protected void |
initialize()
Initializes the servlet, executed automatically by the servlet container
This basically just calls the initializeEntityRequestHandler() method and throws exceptions
if something is missing |
protected abstract EntityRequestHandler |
initializeEntityRequestHandler()
This runs on servlet initialization (it is the first thing to run)
This must be implemented to provide the entity request handler itself
This needs to at least load up the entityRequestHandler service (from the entity broker core) in order for things to work, if that service is not loaded then nothing will work, this can be done using a service manager of some kind or by loading it up manually, the default is to create and load it manually by calling this method with the service Can also call the servlet constructor to set this value but that is really for testing |
protected void |
sendError(javax.servlet.http.HttpServletResponse res,
int code,
String message)
handles sending back servlet errors to the client,
feel free to override this if you like to handle errors in a particular way
|
protected void |
service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
void |
setEntityRequestHandler(EntityRequestHandler entityRequestHandler) |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, serviceprotected transient EntityRequestHandler entityRequestHandler
public DirectServlet()
public DirectServlet(EntityRequestHandler entityRequestHandler)
entityRequestHandler - the entity request handler service objectpublic void setEntityRequestHandler(EntityRequestHandler entityRequestHandler)
protected abstract EntityRequestHandler initializeEntityRequestHandler()
protected abstract String getCurrentLoggedInUserId()
protected abstract void handleUserLogin(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
String path)
req - the http request (from the client)res - the http response (back to the client)path - current request path, set ONLY if we want this to be where to redirect the user after a successful loginpublic void init()
throws javax.servlet.ServletException
init in class javax.servlet.GenericServletjavax.servlet.ServletExceptionprotected void initialize()
initializeEntityRequestHandler() method and throws exceptions
if something is missingprotected void service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException,
IOException
service in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionIOExceptionprotected void handleRequest(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException,
IOException
req - (from the client)res - (back to the client)javax.servlet.ServletExceptionIOExceptionpublic void dispatch(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws javax.servlet.ServletException
req - (from the client)res - (back to the client)javax.servlet.ServletExceptionprotected void sendError(javax.servlet.http.HttpServletResponse res,
int code,
String message)
res - the http servlet response (back to the client)code - servlet error response codemessage - extra info about the errorCopyright © 2003–2020 Sakai Project. All rights reserved.