public final class ServletHelper extends java.lang.Object implements AjaxSwingServlet
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
APP_NAME |
FileUploadHandler |
fileUploadHandler |
static java.lang.String |
PROPS_FILE_NAME |
Modifier and Type | Method and Description |
---|---|
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() |
public FileUploadHandler fileUploadHandler
public static final java.lang.String APP_NAME
public static final java.lang.String PROPS_FILE_NAME
public java.lang.String getParameterValue(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws java.lang.Exception
request
- HttpServletRequestname
- parameter namejava.lang.Exception
public java.lang.String[] getParameterValues(javax.servlet.http.HttpServletRequest request, java.lang.String name) throws java.lang.Exception
request
- HttpServletRequestname
- parameter namejava.lang.Exception
public java.lang.String decodeValue(java.lang.String value) throws java.lang.Exception
value
- Stringjava.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
- HttpServletResponsejava.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 tojava.lang.NullPointerException
- if the input or output is nulljava.io.IOException
- if an I/O error occursjava.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
- HttpServletRequestjava.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
- HttpServletRequestjava.lang.Exception
public void processRequestData(AppDesc appDesc, javax.servlet.http.HttpServletRequest request, HttpRequestData requestData) throws java.lang.Exception
appDesc
- application descriptorrequest
- HttpServletRequestrequestData
- HttpRequestDatajava.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
- HttpServletResponsejava.lang.Exception
public ClientAgent createClientAgent(java.lang.String appName) throws java.lang.Exception
createClientAgent
in interface AjaxSwingServlet
appName
- application namejava.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
- HttpRequestDatajava.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
- HttpRequestDatajava.lang.Exception
public java.lang.Object getSessionAttribute(javax.servlet.http.HttpSession session, java.lang.String name) throws java.lang.Exception
session
- HttpSessionname
- attribute namejava.lang.Exception
public void setSessionAttribute(javax.servlet.http.HttpSession session, java.lang.String name, java.lang.Object value)
session
- HttpSessionname
- attribute namevalue
- attribute valuejava.lang.Exception
public void removeSessionAttribute(javax.servlet.http.HttpSession session, java.lang.String name) throws java.lang.Exception
session
- HttpSessionname
- attribute namejava.lang.Exception
public void setDataFromPath(HttpRequestData data, java.lang.String path) throws java.lang.Exception
data
- HttpRequestDatapath
- Stringjava.lang.Exception
public static java.lang.String getListenerName(java.lang.String appName)
appName
- Stringpublic RouterRequestFilter getRequestFilter()
public static ServletHelper getInstance(javax.servlet.ServletContext servletContext) throws java.lang.Exception
servletContext
- ServletContextsourceEncoding
- Stringjava.lang.Exception
Copyright © 2000-2012 CreamTec LLC. All Rights Reserved.