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_FTABLERef.hpp"
00032 #include "OW_PerlMethodProviderProxy.hpp"
00033 #include "NPIExternal.hpp"
00034 #include "OW_CIMClass.hpp"
00035 #include "OW_CIMException.hpp"
00036 #include "OW_Format.hpp"
00037 #include "OW_NPIProviderIFCUtils.hpp"
00038 #include "OW_CIMValue.hpp"
00039 #include "OW_CIMObjectPath.hpp"
00040 #include "OW_Logger.hpp"
00041 #include "OW_CIMParamValue.hpp"
00042
00043 namespace OW_NAMESPACE
00044 {
00045
00046 namespace
00047 {
00048 const String COMPONENT_NAME("ow.provider.perlnpi.ifc");
00049 }
00050
00052 PerlMethodProviderProxy::~PerlMethodProviderProxy()
00053 {
00054 }
00056 CIMValue
00057 PerlMethodProviderProxy::invokeMethod(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), "PerlInstanceProviderProxy::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 _VectorAddTo(
00082 &_npiHandle, parm_in, static_cast<void *> (owpv) );
00083 }
00084 for (int i = 0, n = out.size(); i < n; i++)
00085 {
00086 CIMParamValue * owpv = new CIMParamValue(out[i]);
00087 _VectorAddTo(
00088 &_npiHandle, parm_out, static_cast<void *> (owpv) );
00089 }
00090
00091 ::CIMValue cv = m_ftable->fp_invokeMethod(
00092 &_npiHandle, _cop , methodName.c_str(), parm_in, parm_out);
00093 if (_npiHandle.errorOccurred)
00094 {
00095 OW_THROWCIMMSG(CIMException::FAILED,
00096 _npiHandle.providerError);
00097 }
00098 rval = * static_cast<CIMValue *> (cv.ptr);
00099
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