Modified the web server to allow connection related data to be stored in the connection's context by the application. This modifies the contract (interfaces) between the framework and application code, requiring changes to the application (breaks backward compatibility).

This commit is contained in:
wcrisman
2014-07-11 10:39:36 -07:00
parent bb9b1f550e
commit d2027e13f9
9 changed files with 83 additions and 16 deletions

View File

@@ -0,0 +1,21 @@
package com.foundation.web.interfaces;
/**
* The context object available to the web application where connection related data can be stored and released within the context of a single connection between the client and server.
* Used to store data related to a single socket between the web browser and web server, such as a socket to a service that the server needs in order to service the client's requests.
* The data will be given an opportunity to be cleaned up upon the socket's closure if it implements com.foundation.web.interfaces.ISessionLifecycleAware.
*/
public interface IConnectionContext {
/**
* Gets the application data in the connection context's application data map by the given key.
* @return The application specific data element.
*/
public Object getApplicationData(String key);
/**
* Stores the application data in the connection context's application data map by the given key.
* The application data may implement ISessionLifecycleAware if it should be called when the session is being released. This will only be called for a normal closing of the session. The session may still be restored at some time in the future.
* @param key The key for the data. If the key is logically equal (equivalent) to an existing key, then the existing data will be replaced and returned.
* @param applicationData The application specific data element.
*/
public void setApplicationData(String key, Object applicationData);
}//IConnectionContext//

View File

@@ -0,0 +1,11 @@
package com.foundation.web.interfaces;
/**
* An interface implemented by objects stored in the SessionData's application data mapping (as the value) when the object wants notification that the session has been released.
*/
public interface ISessionLifecycleAware {
/**
* Called when the session is released.
*/
public void release();
}//ISessionLifecycleAware//

View File

@@ -168,8 +168,9 @@ public void createSecureSession(ISession session);
* @param session The non-secure session. This may be null if the application does not use a session object.
* @param isSecure Whether the request was made over a secure connection and provided the correct secure id.
* @param clientHadBadSession Whether the client's request contained a session reference that could not be found on the server.
* @param connectionContext The context object for the connection (socket) between the client (web browser) and server (web server).
*/
public void processRequest(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession);
public void processRequest(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession, IConnectionContext connectionContext);
/**
* Releases any resources associated with the web server application.
*/