Package org.fbsql.servlet
Class DbServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.fbsql.servlet.DbServlet
-
- All Implemented Interfaces:
java.io.Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
@WebServlet(asyncSupported=true) public class DbServlet extends javax.servlet.http.HttpServlet
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classDbServlet.SharedCoderTransfer encoding/decoding functionality to request processor Instances of Base64.Encoder/Base64.Decoder class are safe for use by multiple concurrent threads.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,ParseStmtConnectTo.StmtConnectTo>connectionInfoMapprivate java.util.Map<java.lang.String,java.sql.Connection>connectionMapprivate java.util.Map<java.lang.String,ConnectionPoolManager>connectionPoolManagerMapstatic java.lang.StringCORS_ALLOW_ORIGINstatic java.lang.StringCUSTOM_HTTP_HEADER_CLIENT_INFOCustom HTTP header to send SQL statement with GET method WARNING! This constant used also in JavaScript partstatic java.lang.StringCUSTOM_HTTP_HEADER_ROLECustom HTTP header to send user role WARNING! This constant used also in JavaScript partstatic java.lang.StringCUSTOM_HTTP_HEADER_STATEMENTCustom HTTP header to send SQL statement with GET method WARNING! This constant used also in JavaScript partstatic booleanDEBUGDebug mode flag true in debug mode false in production modeprivate java.lang.Stringfbsql_home_dirstatic java.lang.StringFBSQL_HOME_DIR_ENV_NAMEprivate static java.lang.StringHTTP_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALSprivate static java.lang.StringHTTP_HEADER_ACCESS_CONTROL_ALLOW_HEADERSprivate static java.lang.StringHTTP_HEADER_ACCESS_CONTROL_ALLOW_METHODSprivate static java.lang.StringHTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGINprivate static java.lang.StringHTTP_HEADER_AUTHORIZATIONprivate static java.lang.StringHTTP_HEADER_CACHE_CONTROLprivate static java.lang.StringHTTP_HEADER_ORIGINprivate java.util.Collection<java.lang.String>instancesprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,ParseStmtDeclareStatement.StmtDeclareStatement>>instancesDeclaredStatementsMapprivate java.util.Map<java.lang.String,java.lang.String>instancesDirectoryMapprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,org.mozilla.javascript.Function>>>instancesFunctionsMapprivate java.util.Map<java.lang.String,ParseNativeStmt>instancesParseNativeStmtMapprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,NonNativeProcedure>>instancesProceduresMapprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,org.mozilla.javascript.Scriptable>>instancesScopesMapprivate java.util.ServiceLoader<java.sql.Driver>loadedDriversprivate java.util.Map<java.lang.String,java.util.Queue<javax.servlet.AsyncContext>>ongoingRequestsMapstatic java.lang.StringREQUEST_ATTRIBUTE_SESSION_IDCustom HttpServletRequest attribute name to store session IDstatic java.lang.StringREQUEST_ATTRIBUTE_USERCustom HttpServletRequest attribute name to store user nameprivate static longserialVersionUIDserialVersionUIDprivate javax.servlet.ServletConfigservletConfigprivate DbServlet.SharedCodersharedCoderprivate java.util.Map<java.lang.String,java.util.Map<StaticStatement,ReadyResult>>staticJsonsMap
-
Constructor Summary
Constructors Constructor Description DbServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidauthorizationError(javax.servlet.http.HttpServletResponse response, java.lang.String message)voiddestroy()Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.private voiddoDbRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected voiddoOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)private static java.lang.String[]getInstanceAndOperation(javax.servlet.http.HttpServletRequest request)Extract instance name from requestvoidinit(javax.servlet.ServletConfig servletConfig)Called by the servlet container to indicate to a servlet that the servlet is being placed into service.private voidopenInstance(java.lang.String instanceName, java.util.List<java.lang.String> initList)Open database connection instanceprotected voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doPut, doTrace, getLastModified, service
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
serialVersionUID- See Also:
- Constant Field Values
-
DEBUG
public static final boolean DEBUG
Debug mode flag true in debug mode false in production mode- See Also:
- Constant Field Values
-
HTTP_HEADER_CACHE_CONTROL
private static final java.lang.String HTTP_HEADER_CACHE_CONTROL
- See Also:
- Constant Field Values
-
HTTP_HEADER_AUTHORIZATION
private static final java.lang.String HTTP_HEADER_AUTHORIZATION
- See Also:
- Constant Field Values
-
HTTP_HEADER_ORIGIN
private static final java.lang.String HTTP_HEADER_ORIGIN
- See Also:
- Constant Field Values
-
HTTP_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
private static final java.lang.String HTTP_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
- See Also:
- Constant Field Values
-
HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN
private static final java.lang.String HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN
- See Also:
- Constant Field Values
-
HTTP_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS
private static final java.lang.String HTTP_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS
- See Also:
- Constant Field Values
-
HTTP_HEADER_ACCESS_CONTROL_ALLOW_METHODS
private static final java.lang.String HTTP_HEADER_ACCESS_CONTROL_ALLOW_METHODS
- See Also:
- Constant Field Values
-
CUSTOM_HTTP_HEADER_CLIENT_INFO
public static final java.lang.String CUSTOM_HTTP_HEADER_CLIENT_INFO
Custom HTTP header to send SQL statement with GET method WARNING! This constant used also in JavaScript part- See Also:
- Constant Field Values
-
CUSTOM_HTTP_HEADER_STATEMENT
public static final java.lang.String CUSTOM_HTTP_HEADER_STATEMENT
Custom HTTP header to send SQL statement with GET method WARNING! This constant used also in JavaScript part- See Also:
- Constant Field Values
-
CUSTOM_HTTP_HEADER_ROLE
public static final java.lang.String CUSTOM_HTTP_HEADER_ROLE
Custom HTTP header to send user role WARNING! This constant used also in JavaScript part- See Also:
- Constant Field Values
-
REQUEST_ATTRIBUTE_USER
public static final java.lang.String REQUEST_ATTRIBUTE_USER
Custom HttpServletRequest attribute name to store user name- See Also:
- Constant Field Values
-
REQUEST_ATTRIBUTE_SESSION_ID
public static final java.lang.String REQUEST_ATTRIBUTE_SESSION_ID
Custom HttpServletRequest attribute name to store session ID- See Also:
- Constant Field Values
-
CORS_ALLOW_ORIGIN
public static final java.lang.String CORS_ALLOW_ORIGIN
- See Also:
- Constant Field Values
-
FBSQL_HOME_DIR_ENV_NAME
public static final java.lang.String FBSQL_HOME_DIR_ENV_NAME
- See Also:
- Constant Field Values
-
fbsql_home_dir
private java.lang.String fbsql_home_dir
-
connectionInfoMap
private java.util.Map<java.lang.String,ParseStmtConnectTo.StmtConnectTo> connectionInfoMap
-
connectionPoolManagerMap
private java.util.Map<java.lang.String,ConnectionPoolManager> connectionPoolManagerMap
-
instancesDeclaredStatementsMap
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,ParseStmtDeclareStatement.StmtDeclareStatement>> instancesDeclaredStatementsMap
-
staticJsonsMap
private java.util.Map<java.lang.String,java.util.Map<StaticStatement,ReadyResult>> staticJsonsMap
-
ongoingRequestsMap
private java.util.Map<java.lang.String,java.util.Queue<javax.servlet.AsyncContext>> ongoingRequestsMap
-
connectionMap
private java.util.Map<java.lang.String,java.sql.Connection> connectionMap
-
instancesProceduresMap
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,NonNativeProcedure>> instancesProceduresMap
-
instancesScopesMap
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,org.mozilla.javascript.Scriptable>> instancesScopesMap
-
instancesFunctionsMap
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,org.mozilla.javascript.Function>>> instancesFunctionsMap
-
instancesParseNativeStmtMap
private java.util.Map<java.lang.String,ParseNativeStmt> instancesParseNativeStmtMap
-
instancesDirectoryMap
private java.util.Map<java.lang.String,java.lang.String> instancesDirectoryMap
-
instances
private java.util.Collection<java.lang.String> instances
-
servletConfig
private javax.servlet.ServletConfig servletConfig
-
sharedCoder
private DbServlet.SharedCoder sharedCoder
-
loadedDrivers
private java.util.ServiceLoader<java.sql.Driver> loadedDrivers
-
-
Constructor Detail
-
DbServlet
public DbServlet()
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig servletConfig) throws javax.servlet.ServletException
Called by the servlet container to indicate to a servlet that the servlet is being placed into service. The servlet container calls the init method exactly once after instantiating the servlet. The init method must complete successfully before the servlet can receive any requests. The servlet container cannot place the servlet into service if the init method- Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Parameters:
servletConfig- a servlet configuration object used by a servlet container to pass information to a servlet during initialization. Throws a ServletException Does not return within a time period defined by the Web server- Throws:
javax.servlet.ServletException
-
openInstance
private void openInstance(java.lang.String instanceName, java.util.List<java.lang.String> initList) throws java.lang.Exception
Open database connection instance- Parameters:
instanceDir-- Throws:
java.lang.Exception
-
destroy
public void destroy()
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed. After the servlet container calls this method, it will not call the service method again on this servlet. This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's current state in memory.- Specified by:
destroyin interfacejavax.servlet.Servlet- Overrides:
destroyin classjavax.servlet.GenericServlet
-
service
protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
servicein classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
doOptions
protected void doOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
doOptionsin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
doPost
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
doPostin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
doDbRequest
private void doDbRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
getInstanceAndOperation
private static java.lang.String[] getInstanceAndOperation(javax.servlet.http.HttpServletRequest request)
Extract instance name from request- Parameters:
request- - HttpServletRequest request- Returns:
- - empty array if instance was not specified in URL - array with single element (instance name) if operation was not specified in URL - array with two elements (instance name and operation) if instance name and operation was specified in URL
-
authorizationError
private static void authorizationError(javax.servlet.http.HttpServletResponse response, java.lang.String message) throws java.io.IOException
- Parameters:
response-message-- Throws:
java.io.IOException
-
-