/* * 功能:静态初始化设置 * 编写:Rocky 2009-09-23 14:14:55 * 返回:正确返回>=0值,出错返<0值; */ int Page::init() { FUNCTION_TRACK(); // 函数轨迹跟踪 int ret; static Page page; page.m_bParent = true; Page *obj = Page::instance( &page ); if(NULL == obj) { LOG_ERROR("Page::instance() error"); return ERR; } // 动态库文件目录 const string &path = GlobalConfig::instance()->CgiDir(); // 取出目录下所有动态库 GetFileList dll( path ); GetFileList::file_iterator file(dll); // 注册处理页面到队列 while( file.next() ) { DllLoad::Ptr dll; // 打开动态库 if( dll->Open(file.name()) < 0 ) { LOG_ERROR("加载动态库出错:[%s]", file.name()); continue; } typedef void (*FuncPtr)(void *); // 取执行对象 const string sym = "DllEnter"; FuncPtr pSym = (FuncPtr)dll->GetSymbol(sym); if(NULL == pSym) { LOG_ERROR("取执行对象出错:[%s]", sym.c_str()); continue; } // 执行(传入当前进程环境,即主模块的信息) (*pSym)( Environment::instance() ); LOG_INFO("Loaded: [%s]", file.name()); } // 初始化 Factory::iterator it; for(it = Page::instance()->m_Factory.begin(); Page::instance()->m_Factory.end()!= it; it++) { const string &name = it->first; Page *&page = it->second; int ret = page->DoInit(); if( ret < 0 ) { LOG_ERROR("page->DoInit() error, name=[%s]", name.c_str()); Page::instance()->UnRegister( name ); continue; } LOG_DEBUG("Init page obj[%s] OK", name.c_str()); } return OK; }