OW_NPIMethodProviderProxy.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_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          //  may the arguments must be copied verbatim
00072          //  to avoid locking problems
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 } // end namespace OW_NAMESPACE
00112 

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