00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #include "OW_config.h"
00031 #include "OW_NPIMethodProviderProxy.hpp"
00032 #include "NPIExternal.hpp"
00033 #include "OW_CIMClass.hpp"
00034 #include "OW_CIMException.hpp"
00035 #include "OW_Format.hpp"
00036 #include "OW_NPIProviderIFCUtils.hpp"
00037 #include "OW_CIMValue.hpp"
00038 #include "OW_CIMObjectPath.hpp"
00039 #include "OW_CIMParamValue.hpp"
00040 #include "OW_Logger.hpp"
00041 
00042 namespace OW_NAMESPACE
00043 {
00044 
00045 namespace
00046 {
00047    const String COMPONENT_NAME("ow.provider.npi.ifc");
00048 }
00049 
00051 NPIMethodProviderProxy::~NPIMethodProviderProxy()
00052 {
00053 }
00055 CIMValue
00056 NPIMethodProviderProxy::invokeMethod(
00057    const ProviderEnvironmentIFCRef &env,
00058    const String& ns,
00059    const CIMObjectPath& path,
00060    const String &methodName,
00061    const CIMParamValueArray &in, CIMParamValueArray &out)
00062 {
00063       CIMValue rval(CIMNULL);
00064       OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), "NPIInstanceProviderProxy::invokeMethod()");
00065       if (m_ftable->fp_invokeMethod != NULL)
00066       {
00067       ::NPIHandle _npiHandle = { 0, 0, 0, 0, m_ftable->npicontext};
00068          NPIHandleFreer nhf(_npiHandle);
00069          ProviderEnvironmentIFCRef env2(env);
00070          _npiHandle.thisObject = static_cast<void *>(&env2);
00071          
00072          
00073          CIMObjectPath owcop = path;
00074          owcop.setNameSpace(ns);
00075          ::CIMObjectPath _cop= {static_cast<void *> (&owcop)};
00076          ::Vector parm_in = VectorNew(&_npiHandle);
00077          ::Vector parm_out = VectorNew(&_npiHandle);
00078          for (int i = 0, n = in.size(); i < n; i++)
00079          {
00080             CIMParamValue * owpv = new CIMParamValue(in[i]);
00081       _NPIGarbageCan(&_npiHandle, owpv, CIM_PARAMVALUE);
00082             _VectorAddTo(
00083                &_npiHandle, parm_in, static_cast<void *> (owpv) );
00084          }
00085          for (int i = 0, n = out.size(); i < n; i++)
00086          {
00087             CIMParamValue * owpv = new CIMParamValue(out[i]);
00088       _NPIGarbageCan(&_npiHandle, owpv, CIM_PARAMVALUE);
00089             _VectorAddTo(
00090                &_npiHandle, parm_out, static_cast<void *> (owpv) );
00091          }
00092          ::CIMValue cv = m_ftable->fp_invokeMethod(
00093             &_npiHandle, _cop , methodName.c_str(), parm_in, parm_out);
00094          if (_npiHandle.errorOccurred)
00095          {
00096             OW_THROWCIMMSG(CIMException::FAILED,
00097                _npiHandle.providerError);
00098          }
00099          rval = * static_cast<CIMValue *> (cv.ptr);
00100          out.clear();
00101          for (int i = 0, n = VectorSize(&_npiHandle, parm_out); i < n; i++)
00102          {
00103             CIMParamValue owpv = * static_cast<CIMParamValue *>
00104                (_VectorGet(&_npiHandle, parm_out, i));
00105             out.append(owpv);
00106          }
00107       }
00108       return rval;
00109 }
00110 
00111 } 
00112