Custom Application Management
 |
The Application Manager, is a mechanism that provides application specific information through the Application intrinsic object (class CSPApplication).
The CSP engine, besides the built-in Application Manager, it supports external or third party Application Managers. Although the way an Application Manager is implemented is up to the developer, there are a few implementation rules.
The Application Manager is a DLL that must implement and export a few functions:
- CSPERROR GetValue( const CSPString& strAppID [IN], const CSPString& strName [IN], CSPVariant& Value [OUT]);
This function is called by the CSP Engine to retrieve application information. The string strAppID contains the ID of the application that the requested .csp script belongs to, and the string strName contains the name of the information item to retrieve.
The function must search for the information item using the strAppID and strName as keys, and store the information in the Value object.
If the application information is found and successfully put in the Value object, the function should return CSP_OK. If not found, it should return CSP_APPLICATION_DATA_NOT_FOUND.
In case an unrecoverable error occurs during the execution, it must return CSP_ERROR_CANNOT_RETRIEVE_APPLICATION_DATA.
- CSPERROR SetValue( const CSPString& strAppID [IN], const CSPString& strName[IN], const Value& Value [IN]);
This function is called by the CSP Engine to save application information. The string strAppID contains the ID of the application that the requested .csp script belongs to, and the string strName contains the name of the information item to save.
The function must save the application information in any manner preferred, using strAppID and strName as keys for later retrieval.
If the application information is successfully saved, the function should return CSP_OK. In case an unrecoverable error occurs during the execution, it must return CSP_ERROR_CANNOT_SAVE_APPLICATION_DATA.
- bool Flush();
The implementation of this function is optional. It is periodically triggered by CSP Engine in order to perform maintenance tasks, cleanup or any other periodical process.
If successful, it should return true. If an unrecoverable error occurs, it should return false.
- bool Lock( const CSPString& strAppID );
Because the application information is shared among the scripts of a web application, there is a need for a method of exclusive use through locking.
This function increases the lock count of the application information bound to the application ID contained in strAppID, so that only the current thread can access the information.
It is important to notice that the Application Manager is responsible for handling any thread context related issues.
If successful, it should return true. If an unrecoverable error occurs, it should return false.
- bool UnlockLock( const CSPString& strAppID );
This function decreases the lock count of the information bound to the application ID contained in strAppID. If successful, it should return true.
Even if the lock count is zero, it should still return true. In case of an unrecoverable error, it should return false.
- bool FullUnlock(const CSPString& strAppID);
This function ensures that the application information bound to the application contained in strAppID will be completely unlocked setting the lock count to zero.
If successful, it should return true. If an unrecoverable error occurs, it should return false.
When implementing an Application Manager, you must include the files CSPVariant.h, CSPString.h, and CSPDefs.h. Also, you must link it to CSPLib.lib. These files are placed in the “include” and “lib” directories of the CSP Engine.
See Control Console for more information on these directories.
|
|