mini/zz_worker_thread.h

Go to the documentation of this file.
00001 /* libzzinet
00002  *
00003  * This program is distributed under the GNU General Public License, version 2.
00004  * A copy of this license is included with this source.
00005  *
00006  * Copyright 2004-2006, Toni Thomsson <toni@tonjac.org> 
00007 */
00008  
00015 #ifndef zz_worker_thread_h
00016 #define zz_worker_thread_h
00017 
00018 #include <zz_http_server.h>
00019 #include <zz_win_pool_thread.h>
00020 #include <zz_http_request.h>
00021 #include <zz_log.h>
00022 #include <zz_win_threadmutex.h>
00023 #include <zz_library.h>
00024 #include <map>
00025 #include <jni.h>
00026 #include <zz_cgi.h>
00027 
00028 class CzzWorkerThread : public CzzWinThread, CzzHTTPServer
00029 {
00030 public:
00031 
00032         //* Construction
00033         CzzWorkerThread( CzzAccessLog* log, JavaVM* jvm_instance, CzzHTTPRequest* req = NULL );
00034         virtual ~CzzWorkerThread();
00035 
00036         virtual void OnStart( void );
00037 
00038 
00039     void Queue( CzzHTTPRequest* req );
00040 
00041 protected:
00042 private:
00043 
00044         bool checkAuth( CzzHTTPRequest* req );
00045         bool checkLogout( CzzHTTPRequest* req );
00046 
00047     // Services
00048     int execute_cgi_script( CzzHTTPRequest* req, CzzString& script, CzzString& params );
00049         int execute_dll_script( CzzHTTPRequest* req, CzzString& script, CzzString& params );
00050         int execute_class_script( CzzHTTPRequest* req, CzzString& script, CzzString& params );
00051         int get_file( CzzHTTPRequest* req, CzzString& uri );
00052     
00053     // Errors
00054     int serviceNotFound( const char* msg );
00055     int internalError( const char* msg );
00056         void notAuthorized( void );
00057 
00058         // Helpers
00059         CzzString getDate( void );
00060         CzzString translateToLocal( CzzString& uri );
00061     CzzString urlDecode( const CzzString& url );
00062     CzzString toClassPath( const CzzString& name );
00063         CzzString trim( const CzzString& in );
00064 
00065         bool createChildProcess( char* env, const char* cmd, PROCESS_INFORMATION* pinfo, STARTUPINFO* sinfo );
00066 
00067     static CzzLibrary* getLibrary( const CzzString& name );
00068 
00069         int java_service( JNIEnv* env, MINI_SESSION* session, const CzzString& script, const CzzString& method, CzzCGI* cgi, char** buff, int* buff_size, char* errmsg, int size, int connect );
00070         void java_rollback( JNIEnv* env, jobject session, int connect );
00071         void java_commit( JNIEnv* env, jobject session, int connect );
00072 
00073         CzzLog m_Log;
00074         CzzString m_User;
00075         CzzString m_IP;
00076     JavaVM*   m_JvmInstance;
00077         CzzHTTPRequest* m_LastRequest;
00078         static map<CzzString, CzzLibrary* > m_LibraryMap;
00079 
00080         static CzzWinThreadMutex m_Mutex;
00081 };
00082 
00083 #endif // zz_worker_thread_h

Generated on Thu Sep 21 21:45:42 2006 for tonjac.org MINI/C++ library by  doxygen 1.4.6-NO