org.restafarian.core.servlets
Class SelectListServletBase

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.restafarian.core.servlets.RestServletBase
              extended by org.restafarian.core.servlets.SelectListServletBase
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class SelectListServletBase
extends RestServletBase

This abstract class is the base code for select list servlets.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.restafarian.core.servlets.RestServletBase
context, log
 
Constructor Summary
SelectListServletBase()
           
 
Method Summary
 void doDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The Servlet "doDelete()" method.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The Servlet "doGet()" method.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The Servlet "doPost()" method.
 void doPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The Servlet "doPut()" method.
protected  java.util.List fetchOptions(javax.servlet.http.HttpServletRequest req, java.lang.String startsWith, java.lang.String contains, java.lang.String orderBy)
          This method obtains the requested options from the data source.
protected  java.lang.String formatOptions(javax.servlet.http.HttpServletRequest req, java.util.List options)
          This method formats the options.
protected  java.lang.String getCacheKeyQualifier(javax.servlet.http.HttpServletRequest req)
          This method returns any additional qualifiers for the key to the query cache.
 java.lang.String getContextKey()
           
protected  java.util.Map getCurrentDataFields(javax.servlet.http.HttpServletRequest req)
          This method returns the current map of data fields.
 java.util.Map getDataFields()
           
protected  javax.sql.DataSource getDataSource()
          This method is used to look up the DataSource by name.
 java.lang.String getDataSourceName()
           
 java.lang.String getDefaultContains()
           
 java.lang.String getDefaultOrderBy()
           
 java.lang.String getDefaultStartsWith()
           
protected  java.util.List getOptions(javax.servlet.http.HttpServletRequest req)
          This method retrieves the requested options from the session.
protected static java.util.Map getQueryCache(javax.servlet.http.HttpServletRequest req, java.lang.String contextKey)
          Fetch the query cache from the servlet context, or creates a new one.
protected  java.lang.String getQueryStatement(javax.servlet.http.HttpServletRequest req, java.lang.String startsWith, java.lang.String contains, java.lang.String orderBy)
          This method creates the SQL statement.
protected abstract  java.lang.String getQueryStatement(java.lang.String startsWith, java.lang.String contains, java.lang.String orderBy)
          This method creates the SQL statement.
protected static java.util.Date getReviewCompareDate()
          Fetch the query cache from the servlet context, or creates a new one.
protected static void reviewQueryCache(java.util.Map queryCache)
          Review the query cache and remove expired items.
 void setContextKey(java.lang.String contextKey)
           
 void setDataFields(java.util.Map dataFields)
           
 void setDataSourceName(java.lang.String dataSourceName)
           
 void setDefaultContains(java.lang.String defaultContains)
           
 void setDefaultOrderBy(java.lang.String defaultOrderBy)
           
 void setDefaultStartsWith(java.lang.String defaultStartsWith)
           
 
Methods inherited from class org.restafarian.core.servlets.RestServletBase
destroy, filter, getIdFromUrl, getNameSpaceUrl, getNumericIdFromUrl, init, sendError, sendError, service
 
Methods inherited from class javax.servlet.http.HttpServlet
doHead, doOptions, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectListServletBase

public SelectListServletBase()
Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  java.io.IOException

The Servlet "doGet()" method.

Specified by:
doGet in class RestServletBase
Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   java.io.IOException

The Servlet "doPost()" method.

Specified by:
doPost in class RestServletBase
Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
Throws:
javax.servlet.ServletException
java.io.IOException

doPut

public void doPut(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  java.io.IOException

The Servlet "doPut()" method.

Specified by:
doPut in class RestServletBase
Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
Throws:
javax.servlet.ServletException
java.io.IOException

doDelete

public void doDelete(javax.servlet.http.HttpServletRequest req,
                     javax.servlet.http.HttpServletResponse res)
              throws javax.servlet.ServletException,
                     java.io.IOException

The Servlet "doDelete()" method.

Specified by:
doDelete in class RestServletBase
Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
Throws:
javax.servlet.ServletException
java.io.IOException

getCurrentDataFields

protected java.util.Map getCurrentDataFields(javax.servlet.http.HttpServletRequest req)

This method returns the current map of data fields.

Parameters:
req - the HttpServletRequest object
Returns:
the current map of data fields

formatOptions

protected java.lang.String formatOptions(javax.servlet.http.HttpServletRequest req,
                                         java.util.List options)

This method formats the options.

Parameters:
req - the HttpServletRequest object
options - the List of options
Returns:
the formatted options

getOptions

protected java.util.List getOptions(javax.servlet.http.HttpServletRequest req)

This method retrieves the requested options from the session.

Parameters:
req - the HttpServletRequest object
Returns:
the options

getCacheKeyQualifier

protected java.lang.String getCacheKeyQualifier(javax.servlet.http.HttpServletRequest req)

This method returns any additional qualifiers for the key to the query cache.

Parameters:
req - the HttpServletRequest object
Returns:
the cache key qualifier

fetchOptions

protected java.util.List fetchOptions(javax.servlet.http.HttpServletRequest req,
                                      java.lang.String startsWith,
                                      java.lang.String contains,
                                      java.lang.String orderBy)

This method obtains the requested options from the data source.

Parameters:
req - the HttpServletRequest object
startsWith - the "starts with" query parameter
contains - the "contains" query parameter
orderBy - the sort order
Returns:
the options

getQueryStatement

protected java.lang.String getQueryStatement(javax.servlet.http.HttpServletRequest req,
                                             java.lang.String startsWith,
                                             java.lang.String contains,
                                             java.lang.String orderBy)

This method creates the SQL statement.

Parameters:
req - the HttpServletRequest object
startsWith - the "starts with" query parameter
contains - the "contains" query parameter
orderBy - the sort order
Returns:
the SQL statement

getQueryStatement

protected abstract java.lang.String getQueryStatement(java.lang.String startsWith,
                                                      java.lang.String contains,
                                                      java.lang.String orderBy)

This method creates the SQL statement.

Parameters:
startsWith - the "starts with" query parameter
contains - the "contains" query parameter
orderBy - the sort order
Returns:
the SQL statement

getQueryCache

protected static java.util.Map getQueryCache(javax.servlet.http.HttpServletRequest req,
                                             java.lang.String contextKey)

Fetch the query cache from the servlet context, or creates a new one.

Parameters:
req - the HttpServletRequest object
contextKey - the servlet context key

reviewQueryCache

protected static void reviewQueryCache(java.util.Map queryCache)

Review the query cache and remove expired items.


getReviewCompareDate

protected static java.util.Date getReviewCompareDate()

Fetch the query cache from the servlet context, or creates a new one.


getDataSource

protected javax.sql.DataSource getDataSource()

This method is used to look up the DataSource by name.

Returns:
dataSource - the DataSource

getContextKey

public java.lang.String getContextKey()
Returns:
Returns the contextKey.

setContextKey

public void setContextKey(java.lang.String contextKey)
Parameters:
contextKey - The contextKey to set.

getDataFields

public java.util.Map getDataFields()
Returns:
Returns the dataFields.

setDataFields

public void setDataFields(java.util.Map dataFields)
Parameters:
dataFields - The dataFields to set.

getDataSourceName

public java.lang.String getDataSourceName()
Returns:
Returns the dataSourceName.

setDataSourceName

public void setDataSourceName(java.lang.String dataSourceName)
Parameters:
dataSourceName - The dataSourceName to set.

getDefaultContains

public java.lang.String getDefaultContains()
Returns:
Returns the defaultContains.

setDefaultContains

public void setDefaultContains(java.lang.String defaultContains)
Parameters:
defaultContains - The defaultContains to set.

getDefaultOrderBy

public java.lang.String getDefaultOrderBy()
Returns:
Returns the defaultOrderBy.

setDefaultOrderBy

public void setDefaultOrderBy(java.lang.String defaultOrderBy)
Parameters:
defaultOrderBy - The defaultOrderBy to set.

getDefaultStartsWith

public java.lang.String getDefaultStartsWith()
Returns:
Returns the defaultStartsWith.

setDefaultStartsWith

public void setDefaultStartsWith(java.lang.String defaultStartsWith)
Parameters:
defaultStartsWith - The defaultStartsWith to set.


Copyright © 2008. All Rights Reserved.