|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.creamtec.ajaxswing.ServletHelper
public final class ServletHelper
Provides implementation for most of the logic of processing an incoming HTTP servlet request and forwarding it to a client agent.
Nested Class Summary | |
---|---|
class |
ServletHelper.InProcessAppDesc
Declare this class to resolve classpath to the application classes. |
static class |
ServletHelper.InProcessClientAgent
Declare this class to resolve classpath to the application classes. |
Field Summary | |
---|---|
static java.lang.String |
APP_NAME
|
FileUploadHandler |
fileUploadHandler
|
static java.lang.String |
PROPS_FILE_NAME
|
Method Summary | |
---|---|
static long |
copyInputToOutput(java.io.InputStream input,
java.io.OutputStream output)
Copy bytes from an InputStream to an
OutputStream . |
ClientAgent |
createClientAgent(java.lang.String appName)
Creates a new client agent. |
java.lang.String |
decodeValue(java.lang.String value)
Decode value from the source encoding into internal UTF8 encoding |
AgentInitData |
getAgentInitData(AppDesc appDesc,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
AppDesc |
getAppDesc(javax.servlet.http.HttpServletRequest request,
java.lang.String appName)
Returns the application descriptor for a given request |
ClientAgentRemote |
getClientAgent(AppDesc appDesc,
javax.servlet.http.HttpServletRequest request,
HttpRequestData requestData,
javax.servlet.http.HttpServletResponse response)
Returns a client agent that should process the given request. |
static int |
getClientId(ClientAgentRemote agent)
We have to use Object's implementation of hashCode() because RemoteObject always return the same value for all out-of-process agents |
java.lang.String |
getDocsRealPath(AppDesc appDesc,
javax.servlet.http.HttpServletRequest request)
Real path is disk path such as C:\Java\AjaxSwing and it's needed for SnapshotRenderer temp directory |
static ServletHelper |
getInstance(javax.servlet.ServletContext servletContext)
Returns the instance of the servlet helper |
static java.lang.String |
getListenerName(java.lang.String appName)
Helper method to return the listener name for a given application name |
java.lang.String |
getParameterValue(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Returns the value of the given request parameter |
java.lang.String[] |
getParameterValues(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Returns all values of a HTTP request parameter. |
RouterRequestFilter |
getRequestFilter()
Returns the request filter instance |
static java.lang.String |
getServerURL(javax.servlet.http.HttpServletRequest request)
Obtains the web server URL based on the scheme, port and web app context. |
java.lang.Object |
getSessionAttribute(javax.servlet.http.HttpSession session,
java.lang.String name)
Version-safe way of getting a value from a session |
java.lang.String |
getSubmitURL(AppDesc appDesc,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Obtains the submit URL based on the application configuration or the request URL |
void |
parseAppNameAndAction(javax.servlet.http.HttpServletRequest request,
HttpRequestData data)
Obtain application name and the requested action from HTTP parameters and query string |
void |
processHttpRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Extracts parameters from HttpServletRequest, finds (creates) a client agent and delegates to it for processing and HTML generation. |
void |
processRequestData(AppDesc appDesc,
javax.servlet.http.HttpServletRequest request,
HttpRequestData requestData)
Extracts and processes the request data |
boolean |
processRouterMode(javax.servlet.http.HttpServletRequest request,
HttpRequestData data)
Sets the servlet parameters such as the application name and action based on the deployment method |
void |
removeSessionAttribute(javax.servlet.http.HttpSession session,
java.lang.String name)
Version-safe way of removing a value from a session |
void |
setDataFromPath(HttpRequestData data,
java.lang.String path)
Extracts the servlet parameters such as the application name and action from the given string |
void |
setSessionAttribute(javax.servlet.http.HttpSession session,
java.lang.String name,
java.lang.Object value)
Version-safe way of storing a value in a session |
void |
shutdown()
Shuts down agents and all running external JVMs |
static void |
shutdownAgent(AppDesc appDesc,
java.lang.Integer sessionId,
ClientAgentRemote agent)
Shuts down the client agent |
void |
shutdownAllAgents()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public FileUploadHandler fileUploadHandler
public static final java.lang.String APP_NAME
public static final java.lang.String PROPS_FILE_NAME
Method Detail |
---|
public java.lang.String getParameterValue(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws java.lang.Exception
request
- HttpServletRequestname
- parameter name
java.lang.Exception
public java.lang.String[] getParameterValues(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws java.lang.Exception
request
- HttpServletRequestname
- parameter name
java.lang.Exception
public java.lang.String decodeValue(java.lang.String value) throws java.lang.Exception
value
- String
java.lang.Exception
public void shutdown()
public void shutdownAllAgents()
public void processHttpRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
request
- HttpServletRequestresponse
- HttpServletResponse
java.io.IOException
public static long copyInputToOutput(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
InputStream
to an
OutputStream
.
This method buffers the input internally, so there is no need to use a
BufferedInputStream
.
Large streams (over 2GB) will return a bytes copied value of
-1
after the copy has completed since the correct
number of bytes cannot be returned as an int. For large streams
use the copyLarge(InputStream, OutputStream)
method.
input
- the InputStream
to read fromoutput
- the OutputStream
to write to
java.lang.NullPointerException
- if the input or output is null
java.io.IOException
- if an I/O error occurs
java.lang.ArithmeticException
- if the byte count is too largepublic java.lang.String getSubmitURL(AppDesc appDesc, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
appDesc
- application descriptorrequest
- HttpServletRequest
java.lang.Exception
public java.lang.String getDocsRealPath(AppDesc appDesc, javax.servlet.http.HttpServletRequest request) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getServerURL(javax.servlet.http.HttpServletRequest request)
appDesc
- AppDescrequest
- HttpServletRequest
java.lang.Exception
public void processRequestData(AppDesc appDesc, javax.servlet.http.HttpServletRequest request, HttpRequestData requestData) throws java.lang.Exception
appDesc
- application descriptorrequest
- HttpServletRequestrequestData
- HttpRequestData
java.lang.Exception
public ClientAgentRemote getClientAgent(AppDesc appDesc, javax.servlet.http.HttpServletRequest request, HttpRequestData requestData, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
appDesc
- application descriptorrequest
- HttpServletRequestrequestData
- HttpRequestDataresponse
- HttpServletResponse
java.lang.Exception
public ClientAgent createClientAgent(java.lang.String appName) throws java.lang.Exception
createClientAgent
in interface AjaxSwingServlet
appName
- application name
java.lang.Exception
public static void shutdownAgent(AppDesc appDesc, java.lang.Integer sessionId, ClientAgentRemote agent)
appDesc
- application descriptorsessionId
- AjaxSwing internal session identificationagent
- ClientAgentRemotepublic AgentInitData getAgentInitData(AppDesc appDesc, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
public static int getClientId(ClientAgentRemote agent)
agent
-
public AppDesc getAppDesc(javax.servlet.http.HttpServletRequest request, java.lang.String appName) throws java.lang.Exception
request
- HttpServletRequestdata
- HttpRequestData
java.lang.Exception
public void parseAppNameAndAction(javax.servlet.http.HttpServletRequest request, HttpRequestData data) throws java.lang.Exception
java.lang.Exception
public boolean processRouterMode(javax.servlet.http.HttpServletRequest request, HttpRequestData data) throws java.lang.Exception
request
- HttpServletRequestdata
- HttpRequestData
java.lang.Exception
public java.lang.Object getSessionAttribute(javax.servlet.http.HttpSession session, java.lang.String name) throws java.lang.Exception
session
- HttpSessionname
- attribute name
java.lang.Exception
public void setSessionAttribute(javax.servlet.http.HttpSession session, java.lang.String name, java.lang.Object value)
session
- HttpSessionname
- attribute namevalue
- attribute value
java.lang.Exception
public void removeSessionAttribute(javax.servlet.http.HttpSession session, java.lang.String name) throws java.lang.Exception
session
- HttpSessionname
- attribute name
java.lang.Exception
public void setDataFromPath(HttpRequestData data, java.lang.String path) throws java.lang.Exception
data
- HttpRequestDatapath
- String
java.lang.Exception
public static java.lang.String getListenerName(java.lang.String appName)
appName
- String
public RouterRequestFilter getRequestFilter()
public static ServletHelper getInstance(javax.servlet.ServletContext servletContext) throws java.lang.Exception
servletContext
- ServletContextsourceEncoding
- String
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |