52 | | |
| 52 | == The Provider 'Loader Library' == |
| 53 | |
| 54 | Here is example code on how the loader dll logic will operate. |
| 55 | |
| 56 | Windows: |
| 57 | |
| 58 | {{{ |
| 59 | |
| 60 | typedef FdoIConnection* (*CreateConnectionProc)(); |
| 61 | |
| 62 | #ifdef _WIN32 |
| 63 | |
| 64 | #ifdef ARCSDEPROVIDER_EXPORTS |
| 65 | #define FDOSDE_API __declspec(dllexport) |
| 66 | #else |
| 67 | #define FDOSDE_API __declspec(dllimport) |
| 68 | #endif |
| 69 | |
| 70 | class ArcSDELoaderLibrary |
| 71 | { |
| 72 | private: |
| 73 | HMODULE m_hArcSDE; |
| 74 | |
| 75 | public: |
| 76 | ArcSDELoaderLibrary() |
| 77 | { |
| 78 | m_hArcSDE = NULL; |
| 79 | try |
| 80 | { |
| 81 | HMODULE hmod = ::LoadLibraryW(L"sde.dll"); |
| 82 | if (hmod != NULL) |
| 83 | { |
| 84 | ::FreeLibrary(hmod); |
| 85 | m_hArcSDE = ::LoadLibraryW(L"ArcSDEProvider92.dll"); |
| 86 | // in case load ArcSDEProvider92.dll fails try to load 91 |
| 87 | if (m_hArcSDE == NULL) |
| 88 | m_hArcSDE = ::LoadLibraryW(L"ArcSDEProvider91.dll"); |
| 89 | } |
| 90 | else |
| 91 | m_hArcSDE = ::LoadLibraryW(L"ArcSDEProvider91.dll"); |
| 92 | } |
| 93 | catch(...){} |
| 94 | } |
| 95 | HMODULE GetLibraryHandle() |
| 96 | { |
| 97 | return m_hArcSDE; |
| 98 | } |
| 99 | ~ArcSDELoaderLibrary() |
| 100 | { |
| 101 | try |
| 102 | { |
| 103 | if (m_hArcSDE != NULL) |
| 104 | ::FreeLibrary(m_hArcSDE); |
| 105 | } |
| 106 | catch(...){} |
| 107 | } |
| 108 | }; |
| 109 | |
| 110 | static ArcSDELoaderLibrary arcSDEloader; |
| 111 | // external access to connection for client services |
| 112 | extern "C" FDOSDE_API FdoIConnection* CreateConnection () |
| 113 | { |
| 114 | CreateConnectionProc procCreateConn; |
| 115 | HMODULE hArc = arcSDEloader.GetLibraryHandle(); |
| 116 | |
| 117 | if (hArc != NULL) |
| 118 | { |
| 119 | procCreateConn = (CreateConnectionProc)::GetProcAddress (hArc, "CreateConnection"); |
| 120 | if (procCreateConn != NULL) |
| 121 | return procCreateConn(); |
| 122 | } |
| 123 | return NULL; |
| 124 | } |
| 125 | |
| 126 | |
| 127 | }}} |
| 128 | |
| 129 | Linux: |
| 130 | |
| 131 | {{{ |
| 132 | |
| 133 | class ArcSDELoaderLibrary |
| 134 | { |
| 135 | private: |
| 136 | void* m_hArcSDE; |
| 137 | |
| 138 | public: |
| 139 | ArcSDELoaderLibrary() |
| 140 | { |
| 141 | m_hArcSDE = NULL; |
| 142 | try |
| 143 | { |
| 144 | void* hmod = dlopen("libsde.so", RTLD_NOW); |
| 145 | if (hmod != NULL) |
| 146 | { |
| 147 | dlclose(hmod); |
| 148 | m_hArcSDE = dlopen("libArcSDEProvider92.so", RTLD_NOW); |
| 149 | // in case load libArcSDEProvider92.so fails try to load 91 |
| 150 | if (m_hArcSDE == NULL) |
| 151 | m_hArcSDE = dlopen("libArcSDEProvider91.so", RTLD_NOW); |
| 152 | } |
| 153 | else |
| 154 | m_hArcSDE = dlopen("libArcSDEProvider91.so", RTLD_NOW); |
| 155 | } |
| 156 | catch(...){} |
| 157 | } |
| 158 | void* GetLibraryHandle() |
| 159 | { |
| 160 | return m_hArcSDE; |
| 161 | } |
| 162 | ~ArcSDELoaderLibrary() |
| 163 | { |
| 164 | try |
| 165 | { |
| 166 | if (m_hArcSDE != NULL) |
| 167 | dlclose(m_hArcSDE); |
| 168 | } |
| 169 | catch(...){} |
| 170 | } |
| 171 | }; |
| 172 | |
| 173 | static ArcSDELoaderLibrary arcSDEloader; |
| 174 | |
| 175 | // external access to connection for client services |
| 176 | extern "C" FDOSDE_API FdoIConnection* CreateConnection () |
| 177 | { |
| 178 | CreateConnectionProc procCreateConn; |
| 179 | void* hArc = arcSDEloader.GetLibraryHandle(); |
| 180 | |
| 181 | if (hArc != NULL) |
| 182 | { |
| 183 | procCreateConn = (CreateConnectionProc)dlsym (hArc, "CreateConnection"); |
| 184 | if (procCreateConn != NULL) |
| 185 | return procCreateConn(); |
| 186 | } |
| 187 | return NULL; |
| 188 | } |
| 189 | |
| 190 | }}} |
| 191 | |
| 192 | === Build Script Changes === |
| 193 | |
| 194 | In order to support the above proposal, the ArcSDE build scripts must be modified. |
| 195 | |
| 196 | It is known the open source user can have ArcSDE 9.1 client, ArcSDE 9.2 client or both and the build scripts must handle this. |
| 197 | |
| 198 | If a user has both clients we must build both versions of provider, but if he has only one version we must detect at run time which one it is and build the right provider. |
| 199 | |
| 200 | The unit test can be based on ArcSDE 9.1 client or ArcSDE 9.2 client so here the user must decide which one to use. |
| 201 | In order to handle this, a new environment variable was created to specify the version used by the unit test, named SDEVER_ARCUNITTEST. |
| 202 | |
| 203 | Windows side: |
| 204 | |
| 205 | If a user has only one version of ArcSDE client he must set the environment variable SDEHOME to target the location of ArcSDE client SDK. |
| 206 | |
| 207 | If the user has both versions of ArcSDE clients he must copy/install ArcSDE 9.1 client to: |
| 208 | |
| 209 | %FDOTHIRDPARTY%\ESRI\ArcSDEClient91\Windows |
| 210 | |
| 211 | …and ArcSDE 9.2 client to |
| 212 | |
| 213 | %FDOTHIRDPARTY%\ESRI\ArcSDEClient92\Windows |
| 214 | |
| 215 | …to be able to build both versions of provider. |
| 216 | |
| 217 | Also he must set the environment variable %SDEHOME% to target the location of ArcSDE client version used in the unit test. |
| 218 | |
| 219 | The valid values for SDEVER_ARCUNITTEST will be 91 and 92. |
| 220 | |
| 221 | The ArcSDE Provider solution file, ArcSDE.sln, will be modified to include multiple configurations to allow user to build the provider depending of the ArcSDE clients installed. The configurations that will be supported are as follows: |
| 222 | |
| 223 | Debug |
| 224 | Debug91Only |
| 225 | Debug92Only |
| 226 | Release |
| 227 | Release91Only |
| 228 | Release92Only |
| 229 | |
| 230 | The following lines will be added to the Windows build scripts to detect the correct build configuration: |
| 231 | |
| 232 | {{{ |
| 233 | |
| 234 | SET ARCSDEVERSIONACTIVE=9 |
| 235 | |
| 236 | :start_exbuild |
| 237 | |
| 238 | if not ("%SDEVER_ARCUNITTEST%")==("") goto start_setbuild |
| 239 | if exist "%SDEHOME%\bin\sde.dll" SET SDEVER_ARCUNITTEST=92 |
| 240 | if exist "%SDEHOME%\bin\sde91.dll" SET SDEVER_ARCUNITTEST=91 |
| 241 | |
| 242 | :start_setbuild |
| 243 | |
| 244 | if exist "%FDOTHIRDPARTY%\ESRI\ArcSDEClient91\Windows\bin\sde91.dll" SET ARCSDEVERSIONACTIVE=%ARCSDEVERSIONACTIVE%1 |
| 245 | |
| 246 | if exist "%FDOTHIRDPARTY%\ESRI\ArcSDEClient92\Windows\bin\sde.dll" SET ARCSDEVERSIONACTIVE=%ARCSDEVERSIONACTIVE%2 |
| 247 | |
| 248 | if "%ARCSDEVERSIONACTIVE%"=="912" SET ARCSDEVERSIONACTIVE=%TYPEBUILDARCSDE% |
| 249 | if "%ARCSDEVERSIONACTIVE%"=="91" SET ARCSDEVERSIONACTIVE=%TYPEBUILDARCSDE%91Only |
| 250 | if "%ARCSDEVERSIONACTIVE%"=="92" SET ARCSDEVERSIONACTIVE=%TYPEBUILDARCSDE%92Only |
| 251 | |
| 252 | if "%TYPEACTIONARCSDE%"=="clean" SET MSACTIONARCSDE=Clean |
| 253 | if "%TYPEACTIONARCSDE%"=="install" goto install_files_ArcSDE |
| 254 | |
| 255 | echo %MSACTIONARCSDE% %TYPEBUILDARCSDE% ArcSDE provider dlls |
| 256 | SET FDOACTIVEBUILD=%cd%\Src\ArcSDE |
| 257 | cscript //Nologo //job:prepare preparebuilds.wsf |
| 258 | pushd Src |
| 259 | |
| 260 | msbuild ArcSDE_temp.sln /t:%MSACTIONARCSDE% /p:Configuration=%ARCSDEVERSIONACTIVE% /p:Platform="Win32" /nologo /consoleloggerparameters:NoSummary |
| 261 | |
| 262 | |
| 263 | }}} |
| 264 | |
| 265 | Linux side: |
| 266 | |
| 267 | The valid values for SDEVER_ARCUNITTEST will be 91 and empty. |
| 268 | |
| 269 | Building different versions of the provider will be done using an environment variable and an optional parameter in the configure script. |
| 270 | |
| 271 | If the user has only one version of ArcSDE client he must set the environment variable SDEHOME to target the location of ArcSDE client SDK. |
| 272 | |
| 273 | If the user has both versions of ArcSDE clients he must copy/install ArcSDE 9.1 client to |
| 274 | |
| 275 | $FDOTHIRDPARTY/ESRI/ArcSDEClient91/Linux |
| 276 | |
| 277 | … and ArcSDE 9.2 client to |
| 278 | |
| 279 | $FDOTHIRDPARTY/ESRI/ArcSDEClient92/Linux |
| 280 | |
| 281 | …to be able to build both versions of provider. |
| 282 | |
| 283 | Also, he must set the environment variable $SDEHOME to target the location of the ArcSDE client version used in the unit tests. |
| 284 | |
| 285 | === Issues === |
| 286 | |
| 287 | We are still working on finalizing the changes required to the Linux build scripts. |