Search in sources :

Example 6 with IJIDispatch

use of org.jinterop.dcom.impls.automation.IJIDispatch in project opennms by OpenNMS.

the class OnmsWbemObjectImpl method getWmiMethods.

/**
     * <p>getWmiMethods</p>
     *
     * @return a {@link org.opennms.protocols.wmi.wbem.OnmsWbemMethodSet} object.
     * @throws org.opennms.protocols.wmi.WmiException if any.
     */
@Override
public OnmsWbemMethodSet getWmiMethods() throws WmiException {
    try {
        // Get the WbemMethodSet dispatcher.
        final IJIComObject methodComObject = wbemObjectDispatch.get("Methods_").getObjectAsComObject();
        final IJIDispatch methodsSet_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(methodComObject);
        return new OnmsWbemMethodSetImpl(methodsSet_dispatch);
    } catch (final JIException e) {
        throw new WmiException("Failed to retrieve list of methods: " + e.getMessage(), e);
    }
}
Also used : IJIComObject(org.jinterop.dcom.core.IJIComObject) IJIDispatch(org.jinterop.dcom.impls.automation.IJIDispatch) WmiException(org.opennms.protocols.wmi.WmiException) JIException(org.jinterop.dcom.common.JIException)

Example 7 with IJIDispatch

use of org.jinterop.dcom.impls.automation.IJIDispatch in project opennms by OpenNMS.

the class OnmsWbemObjectImpl method getWmiPath.

/**
     * <p>getWmiPath</p>
     *
     * @return a {@link org.opennms.protocols.wmi.wbem.OnmsWbemObjectPath} object.
     * @throws org.opennms.protocols.wmi.WmiException if any.
     */
@Override
public OnmsWbemObjectPath getWmiPath() throws WmiException {
    try {
        // Get the WbemMethodSet dispatcher.
        final IJIComObject pathComObject = wbemObjectDispatch.get("Path_").getObjectAsComObject();
        final IJIDispatch path_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(pathComObject);
        return new OnmsWbemObjectPathImpl(path_dispatch);
    } catch (final JIException e) {
        throw new WmiException("Failed to retrieve object path: " + e.getMessage(), e);
    }
}
Also used : IJIComObject(org.jinterop.dcom.core.IJIComObject) IJIDispatch(org.jinterop.dcom.impls.automation.IJIDispatch) WmiException(org.opennms.protocols.wmi.WmiException) JIException(org.jinterop.dcom.common.JIException)

Example 8 with IJIDispatch

use of org.jinterop.dcom.impls.automation.IJIDispatch in project opennms by OpenNMS.

the class OnmsWbemObjectImpl method getWmiProperties.

/**
     * <p>getWmiProperties</p>
     *
     * @return a {@link org.opennms.protocols.wmi.wbem.OnmsWbemPropertySet} object.
     * @throws org.opennms.protocols.wmi.WmiException if any.
     */
@Override
public OnmsWbemPropertySet getWmiProperties() throws WmiException {
    try {
        // Get the WbemMethodSet dispatcher.
        final IJIComObject propsSetComObject = wbemObjectDispatch.get("Properties_").getObjectAsComObject();
        final IJIDispatch propSet_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(propsSetComObject);
        return new OnmsWbemPropertySetImpl(propSet_dispatch);
    } catch (final JIException e) {
        throw new WmiException("Failed to retrieve object property set: " + e.getMessage(), e);
    }
}
Also used : IJIComObject(org.jinterop.dcom.core.IJIComObject) IJIDispatch(org.jinterop.dcom.impls.automation.IJIDispatch) WmiException(org.opennms.protocols.wmi.WmiException) JIException(org.jinterop.dcom.common.JIException)

Example 9 with IJIDispatch

use of org.jinterop.dcom.impls.automation.IJIDispatch in project opennms by OpenNMS.

the class OnmsWbemPropertySetImpl method get.

/** {@inheritDoc} */
@Override
public OnmsWbemProperty get(final Integer idx) throws WmiException {
    try {
        final IJIComObject enumComObject = wbemPropertySetDispatch.get("_NewEnum").getObjectAsComObject();
        final IJIEnumVariant enumVariant = (IJIEnumVariant) JIObjectFactory.narrowObject(enumComObject.queryInterface(IJIEnumVariant.IID));
        OnmsWbemProperty wbemObj;
        IJIDispatch wbemProperty_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++) {
                wbemProperty_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(((JIVariant) arrayObj[j]).getObjectAsComObject());
            }
        }
        wbemObj = new OnmsWbemPropertyImpl(wbemProperty_dispatch);
        return wbemObj;
    } catch (final JIException e) {
        throw new WmiException("Failed to enumerate WbemProperty variant: " + e.getMessage(), e);
    }
}
Also used : JIArray(org.jinterop.dcom.core.JIArray) IJIComObject(org.jinterop.dcom.core.IJIComObject) IJIEnumVariant(org.jinterop.dcom.impls.automation.IJIEnumVariant) IJIDispatch(org.jinterop.dcom.impls.automation.IJIDispatch) IJIComObject(org.jinterop.dcom.core.IJIComObject) OnmsWbemProperty(org.opennms.protocols.wmi.wbem.OnmsWbemProperty) WmiException(org.opennms.protocols.wmi.WmiException) JIException(org.jinterop.dcom.common.JIException)

Example 10 with IJIDispatch

use of org.jinterop.dcom.impls.automation.IJIDispatch in project opennms by OpenNMS.

the class OnmsWbemObjectSetImpl method get.

/** {@inheritDoc} */
@Override
public OnmsWbemObject get(final Integer idx) throws WmiException {
    try {
        final IJIComObject enumComObject = wbemObjectSet.get("_NewEnum").getObjectAsComObject();
        final IJIEnumVariant enumVariant = (IJIEnumVariant) JIObjectFactory.narrowObject(enumComObject.queryInterface(IJIEnumVariant.IID));
        OnmsWbemObject wbemObj = null;
        IJIDispatch wbemObject_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++) {
                wbemObject_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(((JIVariant) arrayObj[j]).getObjectAsComObject());
            }
        }
        wbemObj = new OnmsWbemObjectImpl(wbemObject_dispatch);
        return wbemObj;
    } 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) IJIEnumVariant(org.jinterop.dcom.impls.automation.IJIEnumVariant) IJIDispatch(org.jinterop.dcom.impls.automation.IJIDispatch) IJIComObject(org.jinterop.dcom.core.IJIComObject) OnmsWbemObject(org.opennms.protocols.wmi.wbem.OnmsWbemObject) WmiException(org.opennms.protocols.wmi.WmiException) OnmsWbemObject(org.opennms.protocols.wmi.wbem.OnmsWbemObject) JIException(org.jinterop.dcom.common.JIException)

Aggregations

JIException (org.jinterop.dcom.common.JIException)13 IJIDispatch (org.jinterop.dcom.impls.automation.IJIDispatch)13 IJIComObject (org.jinterop.dcom.core.IJIComObject)8 JIVariant (org.jinterop.dcom.core.JIVariant)7 WmiException (org.opennms.protocols.wmi.WmiException)7 JIString (org.jinterop.dcom.core.JIString)5 JIArray (org.jinterop.dcom.core.JIArray)4 IJIEnumVariant (org.jinterop.dcom.impls.automation.IJIEnumVariant)4 OnmsWbemObjectSetImpl (org.opennms.protocols.wmi.wbem.jinterop.OnmsWbemObjectSetImpl)4 UnknownHostException (java.net.UnknownHostException)1 JIComServer (org.jinterop.dcom.core.JIComServer)1 OnmsWbemMethod (org.opennms.protocols.wmi.wbem.OnmsWbemMethod)1 OnmsWbemObject (org.opennms.protocols.wmi.wbem.OnmsWbemObject)1 OnmsWbemProperty (org.opennms.protocols.wmi.wbem.OnmsWbemProperty)1 OnmsWbemObjectImpl (org.opennms.protocols.wmi.wbem.jinterop.OnmsWbemObjectImpl)1