Search in sources :

Example 1 with IJIUnreferenced

use of org.jinterop.dcom.common.IJIUnreferenced in project Payara by payara.

the class WindowsWmi method setInfo.

/**
 * not strictly necessary but it was so difficult to write the code that I can't
 * bear to throw it away!
 * @throws WindowsException
 */
private void setInfo() throws WindowsException {
    try {
        processInfo = new String[count];
        IJIComObject comObj = variant.getObjectAsComObject();
        // todo is this needed?
        comObj.registerUnreferencedHandler(new IJIUnreferenced() {

            public void unReferenced() {
            }
        });
        IJIEnumVariant enumVARIANT = (IJIEnumVariant) JIObjectFactory.narrowObject(comObj.queryInterface(IJIEnumVariant.IID));
        for (int i = 0; i < count; i++) {
            Object[] values = enumVARIANT.next(1);
            JIArray array = (JIArray) values[0];
            Object[] arrayObj = (Object[]) array.getArrayInstance();
            for (int j = 0; j < arrayObj.length; j++) {
                IJIDispatch wbemObject_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(((JIVariant) arrayObj[j]).getObjectAsComObject());
                JIVariant variant2 = (JIVariant) (wbemObject_dispatch.callMethodA("GetObjectText_", new Object[] { Integer.valueOf(1) }))[0];
                // normally arrayObj.length is 1
                if (j == 0)
                    processInfo[i] = variant2.getObjectAsString().getString();
            }
        }
    } catch (Exception e) {
        throw new WindowsException(e);
    }
}
Also used : JIArray(org.jinterop.dcom.core.JIArray) IJIComObject(org.jinterop.dcom.core.IJIComObject) JIVariant(org.jinterop.dcom.core.JIVariant) IJIEnumVariant(org.jinterop.dcom.impls.automation.IJIEnumVariant) IJIComObject(org.jinterop.dcom.core.IJIComObject) IJIDispatch(org.jinterop.dcom.impls.automation.IJIDispatch) IJIUnreferenced(org.jinterop.dcom.common.IJIUnreferenced) JIException(org.jinterop.dcom.common.JIException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 IJIUnreferenced (org.jinterop.dcom.common.IJIUnreferenced)1 JIException (org.jinterop.dcom.common.JIException)1 IJIComObject (org.jinterop.dcom.core.IJIComObject)1 JIArray (org.jinterop.dcom.core.JIArray)1 JIVariant (org.jinterop.dcom.core.JIVariant)1 IJIDispatch (org.jinterop.dcom.impls.automation.IJIDispatch)1 IJIEnumVariant (org.jinterop.dcom.impls.automation.IJIEnumVariant)1