OW_PerlProviderIFC.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 #include "OW_config.h"
00031 #include "OW_PerlProviderIFC.hpp"
00032 #include "OW_SharedLibraryException.hpp"
00033 #include "OW_SharedLibraryLoader.hpp"
00034 #include "OW_Format.hpp"
00035 #include "OW_SignalScope.hpp"
00036 #include "OW_ConfigOpts.hpp"
00037 #include "OW_FileSystem.hpp"
00038 #include "OW_NoSuchProviderException.hpp"
00039 #include "OW_PerlInstanceProviderProxy.hpp"
00040 #include "OW_PerlMethodProviderProxy.hpp"
00041 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00042 #include "OW_PerlAssociatorProviderProxy.hpp"
00043 #endif
00044 #include "OW_PerlIndicationProviderProxy.hpp"
00045 // BMMU
00046 #include <iostream>
00047 
00048 namespace OW_NAMESPACE
00049 {
00050 
00051 //typedef PerlProviderBaseIFC* (*ProviderCreationFunc)();
00052 // the closest approximation of PerlProviderBaseIFCRef is ::PerlFTABLE
00053 //  as defined in FTABLERef.hpp
00054 typedef FTABLERef* (*ProviderCreationFunc)();
00055 typedef const char* (*versionFunc_t)();
00056 const char* const PerlProviderIFC::CREATIONFUNC = "createProvider";
00057 namespace
00058 {
00059    const String COMPONENT_NAME("ow.provider.perlnpi.ifc");
00060 }
00061 
00063 PerlProviderIFC::PerlProviderIFC()
00064    : ProviderIFCBaseIFC()
00065    , m_provs()
00066    , m_guard()
00067    , m_noidProviders()
00068    , m_loadDone(false)
00069 {
00070 }
00072 PerlProviderIFC::~PerlProviderIFC()
00073 {
00074    try
00075    {
00076       ProviderMap::iterator it = m_provs.begin();
00077       //Reference<Perlenv> npiHandle(); // TODO: createEnv(...);
00078 
00079       while (it != m_provs.end())
00080       {
00081          ::NPIHandle _npiHandle = { 0, 0, 0, 0,
00082             it->second->npicontext};
00083          it->second->fp_cleanup(&_npiHandle);
00084          it->second.setNull();
00085          it++;
00086       }
00087    
00088       m_provs.clear();
00089    
00090       for (size_t i = 0; i < m_noidProviders.size(); i++)
00091       {
00092          ::NPIHandle _npiHandle = { 0, 0, 0, 0,
00093              m_noidProviders[i]->npicontext};
00094          m_noidProviders[i]->fp_cleanup(&_npiHandle);
00095          m_noidProviders[i].setNull();
00096       }
00097    
00098       m_noidProviders.clear();
00099    }
00100    catch (...)
00101    {
00102       // don't let exceptions escape
00103    }
00104 }
00106 void
00107 PerlProviderIFC::doInit(const ProviderEnvironmentIFCRef& env,
00108    InstanceProviderInfoArray& i,
00109    SecondaryInstanceProviderInfoArray& si,
00110 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00111    AssociatorProviderInfoArray& a,
00112 #endif
00113    MethodProviderInfoArray& m,
00114    IndicationProviderInfoArray& ind)
00115 {
00116    loadProviders(env, i, a, m,
00117       ind);
00118 }
00120 InstanceProviderIFCRef
00121 PerlProviderIFC::doGetInstanceProvider(const ProviderEnvironmentIFCRef& env,
00122    const char* provIdString)
00123 {
00124    FTABLERef pProv = getProvider(env, provIdString);
00125    if (pProv)
00126    {
00127       // if the createInstance pointer is set, then assume it's an instance
00128       // provider
00129       if (pProv->fp_createInstance)
00130       {
00131          OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("PerlProviderIFC found instance"
00132             " provider %1", provIdString));
00133          return InstanceProviderIFCRef(new PerlInstanceProviderProxy(
00134             pProv));
00135       }
00136       OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Provider %1 is not an instance provider",
00137          provIdString));
00138    }
00139    OW_THROW(NoSuchProviderException, provIdString);
00140 }
00142 IndicationExportProviderIFCRefArray
00143 PerlProviderIFC::doGetIndicationExportProviders(const ProviderEnvironmentIFCRef& env)
00144 {
00145    //loadNoIdProviders(env);
00146    IndicationExportProviderIFCRefArray rvra;
00147    //for (size_t i = 0; i < m_noidProviders.size(); i++)
00148    //{
00149    // CppProviderBaseIFCRef pProv = m_noidProviders[i];
00150    // if (pProv->isIndicationExportProvider())
00151    // {
00152    //    rvra.append(
00153    //       IndicationExportProviderIFCRef(new
00154    //          CppIndicationExportProviderProxy(
00155    //             pProv.cast_to<CppIndicationExportProviderIFC>())));
00156    // }
00157    //}
00158    return rvra;
00159 }
00161 PolledProviderIFCRefArray
00162 PerlProviderIFC::doGetPolledProviders(const ProviderEnvironmentIFCRef& env)
00163 {
00164    //loadNoIdProviders(env);
00165    PolledProviderIFCRefArray rvra;
00166    //for (size_t i = 0; i < m_noidProviders.size(); i++)
00167    //{
00168    // FTABLERef pProv = m_noidProviders[i];
00169    //
00170    // if (pProv->fp_activateFilter)
00171    // {
00172    //    rvra.append(
00173    //       PolledProviderIFCRef(new
00174    //          PerlPolledProviderProxy(pProv)));
00175    // }
00176    //}
00177    return rvra;
00178 }
00180 MethodProviderIFCRef
00181 PerlProviderIFC::doGetMethodProvider(const ProviderEnvironmentIFCRef& env,
00182    const char* provIdString)
00183 {
00184    FTABLERef pProv = getProvider(env, provIdString);
00185    if (pProv)
00186    {
00187       // it's a method provider if the invokeMethod function pointer is not
00188       // NULL
00189       if (pProv->fp_invokeMethod)
00190       {
00191          OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("PerlProviderIFC found method provider %1",
00192             provIdString));
00193          return MethodProviderIFCRef(
00194             new PerlMethodProviderProxy(pProv));
00195       }
00196       OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Provider %1 is not a method provider",
00197          provIdString));
00198    }
00199    OW_THROW(NoSuchProviderException, provIdString);
00200 }
00201 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00202 
00203 AssociatorProviderIFCRef
00204 PerlProviderIFC::doGetAssociatorProvider(const ProviderEnvironmentIFCRef& env,
00205    const char* provIdString)
00206 {
00207    FTABLERef pProv = getProvider(env, provIdString);
00208    if (pProv)
00209    {
00210       // if the associatorNames function pointer is not 0, we know it's an
00211       // associator provider
00212       if (pProv->fp_associatorNames)
00213       {
00214          OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("PerlProviderIFC found associator provider %1",
00215             provIdString));
00216          return AssociatorProviderIFCRef(new
00217             PerlAssociatorProviderProxy(pProv));
00218       }
00219       OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Provider %1 is not an associator provider",
00220          provIdString));
00221    }
00222    OW_THROW(NoSuchProviderException, provIdString);
00223 }
00224 #endif
00225 
00226 IndicationProviderIFCRef
00227 PerlProviderIFC::doGetIndicationProvider(const ProviderEnvironmentIFCRef& env,
00228    const char* provIdString)
00229 {
00230 // BMMU
00231    //std::cout << "Get IndicationProvider for Id " << provIdString << std::endl;
00232    FTABLERef pProv = getProvider(env, provIdString);
00233    if (pProv)
00234    {
00235       // if the indicationNames function pointer is not 0, we know it's an
00236       // indication provider
00237       if (pProv->fp_activateFilter)
00238       {
00239          OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("PerlProviderIFC found indication provider %1",
00240             provIdString));
00241          return IndicationProviderIFCRef(new
00242             PerlIndicationProviderProxy(pProv));
00243       }
00244       OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Provider %1 is not an indication provider",
00245          provIdString));
00246    }
00247    OW_THROW(NoSuchProviderException, provIdString);
00248 }
00250 void
00251 PerlProviderIFC::loadProviders(const ProviderEnvironmentIFCRef& env,
00252    InstanceProviderInfoArray& instanceProviderInfo,
00253 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00254    AssociatorProviderInfoArray& associatorProviderInfo,
00255 #endif
00256    MethodProviderInfoArray& methodProviderInfo,
00257    IndicationProviderInfoArray& indicationProviderInfo)
00258 {
00259    MutexLock ml(m_guard);
00260    if (m_loadDone)
00261    {
00262       return;
00263    }
00264    m_loadDone = true;
00265    
00266    SharedLibraryLoaderRef ldr =
00267        SharedLibraryLoader::createSharedLibraryLoader();
00268    if (!ldr)
00269    {
00270       OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), "Perl provider ifc failed to get shared lib loader");
00271       return;
00272    }
00273 
00274    const StringArray libPaths = env->getMultiConfigItem(
00275       ConfigOpts::PERLPROVIFC_PROV_LOCATION_opt, 
00276       String(OW_DEFAULT_PERLPROVIFC_PROV_LOCATION).tokenize(OW_PATHNAME_SEPARATOR),
00277       OW_PATHNAME_SEPARATOR);
00278 
00279    for (size_t libIdx = 0; libIdx < libPaths.size(); ++libIdx)
00280    {
00281       String libPath(libPaths[libIdx]);
00282       StringArray dirEntries;
00283       if (!FileSystem::getDirectoryContents(libPath, dirEntries))
00284       {
00285          OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc "
00286             "failed getting contents of directory: %1", libPath));
00287          return;
00288       }
00289       for (size_t i = 0; i < dirEntries.size(); i++)
00290       {
00291          if (!dirEntries[i].endsWith(".pl"))
00292          {
00293             continue;
00294          }
00295          String libName = libPath;
00296          libName += OW_FILENAME_SEPARATOR;
00297          libName += String("libperlProvider"OW_SHAREDLIB_EXTENSION);
00298          SharedLibraryRef theLib = ldr->loadSharedLibrary(libName,
00299             env->getLogger(COMPONENT_NAME));
00300          String guessProvId = dirEntries[i];
00301          if (!theLib)
00302          {
00303             OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider %1 "
00304                "failed to load library: %2",
00305                guessProvId, libName));
00306             continue;
00307          }
00308          NPIFP_INIT_FT createProvider;
00309          String creationFuncName = "perlProvider_initFunctionTable";
00310          if (!theLib->getFunctionPointer(creationFuncName, createProvider))
00311          {
00312             OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: "
00313                "Library %1 does not contain %2 function",
00314                libName, creationFuncName));
00315             continue;
00316          }
00317          NPIFTABLE fTable = (*createProvider)();
00318          fTable.npicontext = new NPIContext;
00319          fTable.npicontext->scriptName = guessProvId.allocateCString();
00320          if (!fTable.fp_initialize)
00321          {
00322             OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: "
00323             "Library %1 - initialize returned null", libName));
00324             delete (fTable.npicontext->scriptName);
00325             delete ((NPIContext *)fTable.npicontext);
00326             continue;
00327          }
00328    
00329          ::NPIHandle _npiHandle = { 0, 0, 0, 0, fTable.npicontext};
00330                //NPIHandleFreer nhf(_npiHandle);
00331          ::CIMOMHandle ch;
00332    
00333          //char * classList = (* (fTable.fp_initialize))(
00334          // &_npiHandle, ch);
00335          StringArray classList = String((* (fTable.fp_initialize))(
00336             &_npiHandle, ch)).tokenize(",");
00337    
00338          // now register the perl script for every type
00339          // without trying to call
00340          // TODO: implement check for perl subroutines
00341          InstanceProviderInfo inst_info;
00342          inst_info.setProviderName(guessProvId);
00343          instanceProviderInfo.push_back(inst_info);
00344    #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00345          AssociatorProviderInfo assoc_info;
00346          assoc_info.setProviderName(guessProvId);
00347          associatorProviderInfo.push_back(assoc_info);
00348    #endif
00349          MethodProviderInfo meth_info;
00350          meth_info.setProviderName(guessProvId);
00351          methodProviderInfo.push_back(meth_info);
00352    
00353          IndicationProviderInfo ind_info;
00354          if (! classList.empty())
00355          {
00356             IndicationProviderInfoEntry e("CIM_InstCreation");
00357             for (unsigned int cnt = 0; cnt < classList.size();
00358                cnt++)
00359             {
00360                e.classes.push_back(classList[cnt]);
00361             }
00362             ind_info.addInstrumentedClass(e);
00363             e.indicationName = "CIM_InstModification";
00364             ind_info.addInstrumentedClass(e);
00365             e.indicationName = "CIM_InstDeletion";
00366             ind_info.addInstrumentedClass(e);
00367             ind_info.setProviderName(guessProvId);
00368             indicationProviderInfo.push_back(ind_info);
00369          }
00370          continue;
00371       }
00372    }
00373 }
00375 void
00376 PerlProviderIFC::loadNoIdProviders(const ProviderEnvironmentIFCRef& env)
00377 {
00378 
00379    MutexLock ml(m_guard);
00380    if (m_loadDone)
00381    {
00382      return;
00383    }
00384    m_loadDone = true;
00385    SharedLibraryLoaderRef ldr =
00386      SharedLibraryLoader::createSharedLibraryLoader();
00387    if (!ldr)
00388    {
00389      OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), "Perl provider ifc failed to get shared lib loader");
00390      return;
00391    }
00392 
00393    const StringArray libPaths = env->getMultiConfigItem(
00394       ConfigOpts::PERLPROVIFC_PROV_LOCATION_opt, 
00395       String(OW_DEFAULT_PERLPROVIFC_PROV_LOCATION).tokenize(OW_PATHNAME_SEPARATOR),
00396       OW_PATHNAME_SEPARATOR);
00397 
00398    for (size_t libIdx = 0; libIdx < libPaths.size(); ++libIdx)
00399    {
00400       String libPath(libPaths[libIdx]);
00401       StringArray dirEntries;
00402       if (!FileSystem::getDirectoryContents(libPath, dirEntries))
00403       {
00404         OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc failed getting contents of "
00405           "directory: %1", libPath));
00406         return;
00407       }
00408       for (size_t i = 0; i < dirEntries.size(); i++)
00409       {
00410         if (!dirEntries[i].endsWith(".pl"))
00411         {
00412           continue;
00413         }
00414         String libName = libPath;
00415         libName += OW_FILENAME_SEPARATOR;
00416         //libName += dirEntries[i];
00417         libName += String("libperlProvider"OW_SHAREDLIB_EXTENSION);
00418         SharedLibraryRef theLib = ldr->loadSharedLibrary(libName,
00419             env->getLogger(COMPONENT_NAME));
00420         String guessProvId = dirEntries[i];
00421         if (!theLib)
00422         {
00423           OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider %1 ifc failed to load"
00424                   " library: %2", guessProvId, libName));
00425           continue;
00426         }
00427    #if 0
00428         versionFunc_t versFunc;
00429         if (!theLib->getFunctionPointer("getOWVersion",
00430              versFunc))
00431         {
00432           OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc failed getting"
00433                 " function pointer to \"getOWVersion\" from library: %1",
00434                 libName));
00435           continue;
00436         }
00437         const char* strVer = (*versFunc)();
00438         if (strcmp(strVer, VERSION))
00439         {
00440           OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc got invalid version from "
00441                 "provider: %1", strVer));
00442           continue;
00443         }
00444    #endif
00445       NPIFP_INIT_FT createProvider;
00446       //String creationFuncName = guessProvId + "_initFunctionTable";
00447       String creationFuncName = "perlProvider_initFunctionTable";
00448       if (!theLib->getFunctionPointer(creationFuncName, createProvider))
00449       {
00450          OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: Libary %1 does not contain"
00451             " %2 function", libName, creationFuncName));
00452          continue;
00453       }
00454       NPIFTABLE fTable = (*createProvider)();
00455       fTable.npicontext = new NPIContext;
00456       
00457       fTable.npicontext->scriptName = guessProvId.allocateCString();
00458       if ((!fTable.fp_initialize)||(!fTable.fp_activateFilter))
00459       {
00460          OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: Libary %1 - %2 returned null"
00461             " initialize function pointer in function table", libName, creationFuncName));
00462          delete (fTable.npicontext->scriptName);
00463             delete ((NPIContext *)fTable.npicontext);
00464          continue;
00465       }
00466          // only initialize polled and indicationexport providers
00467       // since Perl doesn't support indicationexport providers ....
00468          // else it must be a polled provider - initialize it
00469       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc loaded library %1. Calling initialize"
00470          " for provider %2", libName, guessProvId));
00471       ::CIMOMHandle ch = {0}; // CIMOMHandle parameter is meaningless, there is
00472       // nothing the provider can do with it, so we'll just pass in 0
00473       ::NPIHandle _npiHandle = { 0, 0, 0, 0, fTable.npicontext};
00474       fTable.fp_initialize(&_npiHandle, ch );   // Let provider initialize itself
00475          // take care of the errorOccurred field
00476          // that might indicate a buggy perl script
00477          if (_npiHandle.errorOccurred)
00478          {
00479              OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc loaded library %1. Initialize failed"
00480          " for provider %2", libName, guessProvId));
00481             delete ((NPIContext *)fTable.npicontext);
00482          continue;
00483          }
00484       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: provider %1 loaded and initialized",
00485          guessProvId));
00486          //m_noidProviders.append(FTABLERef(theLib, new ::FTABLE(fTable)));
00487          m_noidProviders.append(FTABLERef(theLib, new NPIFTABLE(fTable)));
00488       }
00489    }
00490 }
00492 FTABLERef
00493 PerlProviderIFC::getProvider(
00494    const ProviderEnvironmentIFCRef& env, const char* provIdString)
00495 {
00496    MutexLock ml(m_guard);
00497    String provId(provIdString);
00498    ProviderMap::iterator it = m_provs.find(provId);
00499    if (it != m_provs.end())
00500    {
00501       return it->second;
00502    }
00503    SharedLibraryLoaderRef ldr =
00504       SharedLibraryLoader::createSharedLibraryLoader();
00505    if (!ldr)
00506    {
00507       OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), "Perl: provider ifc failed to get shared lib loader");
00508       return FTABLERef();
00509    }
00510    const StringArray libPaths = env->getMultiConfigItem(
00511       ConfigOpts::PERLPROVIFC_PROV_LOCATION_opt, 
00512       String(OW_DEFAULT_PERLPROVIFC_PROV_LOCATION).tokenize(OW_PATHNAME_SEPARATOR),
00513       OW_PATHNAME_SEPARATOR);
00514 
00515    for (size_t libIdx = 0; libIdx < libPaths.size(); ++libIdx)
00516    {
00517       String libPath(libPaths[libIdx]);
00518       String libName(libPath);
00519       libName += OW_FILENAME_SEPARATOR;
00520       libName += "libperlProvider"OW_SHAREDLIB_EXTENSION;
00521       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("PerlProviderIFC::getProvider loading library: %1",
00522          libName));
00523 
00524       if (!FileSystem::exists(libName))
00525       {
00526          continue;
00527       }
00528 
00529       SharedLibraryRef theLib = ldr->loadSharedLibrary(libName,
00530          env->getLogger(COMPONENT_NAME));
00531       if (!theLib)
00532       {
00533          OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc failed to load library: %1 "
00534             "for provider id %2", libName, provId));
00535          return FTABLERef();
00536       }
00537       NPIFP_INIT_FT createProvider;
00538       String creationFuncName = "perlProvider_initFunctionTable";
00539       if (!theLib->getFunctionPointer(creationFuncName, createProvider))
00540       {
00541          OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: Libary %1 does not contain"
00542             " %2 function", libName, creationFuncName));
00543          return FTABLERef();
00544       }
00545       NPIFTABLE fTable = (*createProvider)();
00546       fTable.npicontext = new NPIContext;
00547       
00548       fTable.npicontext->scriptName = provId.allocateCString();
00549       if (!fTable.fp_initialize)
00550       {
00551          OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: Libary %1 - %2 returned null"
00552             " initialize function pointer in function table", libName, creationFuncName));
00553             delete ((NPIContext *)fTable.npicontext);
00554          return FTABLERef();
00555       }
00556       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc loaded library %1. Calling initialize"
00557          " for provider %2", libName, provId));
00558       ::CIMOMHandle ch = {0}; // CIMOMHandle parameter is meaningless, there is
00559       // nothing the provider can do with it, so we'll just pass in 0
00560       //Reference<PerlEnv> npiHandle(); // TODO: createEnv(...);
00561       ::NPIHandle _npiHandle = { 0, 0, 0, 0, fTable.npicontext};
00562       fTable.fp_initialize(&_npiHandle, ch );   // Let provider initialize itself
00563          // take care of the errorOccurred field
00564          // that might indicate a buggy perl script
00565          if (_npiHandle.errorOccurred)
00566          {
00567              OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc loaded library %1. Initialize failed"
00568          " for provider %2", libName, provId));
00569             delete ((NPIContext *)fTable.npicontext);
00570          return FTABLERef();
00571          }
00572       
00573       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("Perl provider ifc: provider %1 loaded and initialized (script %2)",
00574          provId, fTable.npicontext->scriptName));
00575       m_provs[provId] = FTABLERef(theLib, new NPIFTABLE(fTable));
00576       return m_provs[provId];
00577    }
00578    return FTABLERef();
00579 }
00580 
00581 } // end namespace OW_NAMESPACE
00582 
00583 OW_PROVIDERIFCFACTORY(OpenWBEM::PerlProviderIFC, perl)
00584 

Generated on Thu Feb 9 08:48:08 2006 for openwbem by  doxygen 1.4.6