Search in sources :

Example 1 with OnmsWbemMethod

use of org.opennms.protocols.wmi.wbem.OnmsWbemMethod in project opennms by OpenNMS.

the class OnmsWbemMethodSetImpl method get.

/** {@inheritDoc} */
@Override
public OnmsWbemMethod get(final Integer idx) throws WmiException {
    try {
        final IJIComObject enumComObject = wbemMethodSetDispatch.get("_NewEnum").getObjectAsComObject();
        final IJIEnumVariant enumVariant = (IJIEnumVariant) JIObjectFactory.narrowObject(enumComObject.queryInterface(IJIEnumVariant.IID));
        OnmsWbemMethod wbemMethod;
        IJIDispatch wbemMethod_dispatch = null;
        for (int i = 0; i < (idx + 1); i++) {
            final Object[] values = enumVariant.next(1);
            final JIArray array = (JIArray) values[0];
            final Object[] arrayObj = (Object[]) array.getArrayInstance();
            for (int j = 0; j < arrayObj.length; j++) {
                wbemMethod_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(((JIVariant) arrayObj[j]).getObjectAsComObject());
            }
        }
        wbemMethod = new OnmsWbemMethodImpl(wbemMethod_dispatch);
        return wbemMethod;
    } catch (final JIException e) {
        throw new WmiException("Failed to enumerate WbemObject variant: " + e.getMessage(), e);
    }
}
Also used : JIArray(org.jinterop.dcom.core.JIArray) IJIComObject(org.jinterop.dcom.core.IJIComObject) OnmsWbemMethod(org.opennms.protocols.wmi.wbem.OnmsWbemMethod) IJIEnumVariant(org.jinterop.dcom.impls.automation.IJIEnumVariant) IJIDispatch(org.jinterop.dcom.impls.automation.IJIDispatch) IJIComObject(org.jinterop.dcom.core.IJIComObject) WmiException(org.opennms.protocols.wmi.WmiException) JIException(org.jinterop.dcom.common.JIException)

Aggregations

JIException (org.jinterop.dcom.common.JIException)1 IJIComObject (org.jinterop.dcom.core.IJIComObject)1 JIArray (org.jinterop.dcom.core.JIArray)1 IJIDispatch (org.jinterop.dcom.impls.automation.IJIDispatch)1 IJIEnumVariant (org.jinterop.dcom.impls.automation.IJIEnumVariant)1 WmiException (org.opennms.protocols.wmi.WmiException)1 OnmsWbemMethod (org.opennms.protocols.wmi.wbem.OnmsWbemMethod)1