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);
}
}
Aggregations