OW_PerlMethodProviderProxy.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_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          //  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             _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          // cleanup output parameters
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:08 2006 for openwbem by  doxygen 1.4.6