本文整理汇总了Java中org.jinterop.dcom.impls.automation.IJIDispatch类的典型用法代码示例。如果您正苦于以下问题:Java IJIDispatch类的具体用法?Java IJIDispatch怎么用?Java IJIDispatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IJIDispatch类属于org.jinterop.dcom.impls.automation包,在下文中一共展示了IJIDispatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isConnected
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* Verify if the connection is living.
* @return true if living, false if dead.
*/
public boolean isConnected() {
if(services == null || servicesDispatch == null) {
return false;
}
try {
servicesDispatch.queryInterface(IJIDispatch.IID);
return true;
} catch (JIException e) {
if(e.getErrorCode() == 0x8001FFFF) {
logger.debug("Connection has been disconnected.");
return false;
} else {
throw new IllegalStateException();
}
}
}
示例2: AbstractScriptingObject
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
AbstractScriptingObject(final IJIDispatch dispatch) {
this.dispatch = dispatch;
this.dispatch.registerUnreferencedHandler(new IJIUnreferenced() {
@Override
public void unReferenced() {
try {
dispatch.addRef();
logger.debug("Add reference to {}", dispatch);
} catch (JIException e) {
logger.warn("Exception occurred when add reference to dispatch.", e);
}
}
});
}
示例3: execute
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
public void execute() throws JIException
{
unknown = comStub.createInstance();
//CLSID of IITestCOMServer
IJIComObject comObject = (IJIComObject)unknown.queryInterface("4AE62432-FD04-4BF9-B8AC-56AA12A47FF9");
dispatch = (IJIDispatch)JIObjectFactory.narrowObject(comObject.queryInterface(IJIDispatch.IID));
//Now call via automation
Object results[] = dispatch.callMethodA("Add",new Object[]{new Integer(1), new Integer(2), new JIVariant(0,true)});
System.out.println(results[1]);
//now without automation
JICallBuilder callObject = new JICallBuilder();
callObject.setOpnum(1);//obtained from the IDL or TypeLib.
callObject.addInParamAsInt(1,JIFlags.FLAG_NULL);
callObject.addInParamAsInt(2,JIFlags.FLAG_NULL);
callObject.addInParamAsPointer(new JIPointer(new Integer(0)),JIFlags.FLAG_NULL);
//Since the retval is a top level pointer , it will get replaced with it's base type.
callObject.addOutParamAsObject(Integer.class,JIFlags.FLAG_NULL);
results = comObject.call(callObject);
System.out.println(results[0]);
JISession.destroySession(dispatch.getAssociatedSession());
}
示例4: getLengthInBytes
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
static int getLengthInBytes(Class c,Object obj, int FLAG)
{
if(obj != null && obj.getClass().equals(JIArray.class))
{
return ((JIArray)obj).getSizeOfAllElementsInBytes();
}
else
{
if ((c != IJIComObject.class || c != IJIDispatch.class) && obj instanceof IJIComObject)
{
c = IJIComObject.class;
}
if (((SerializerDeserializer)mapOfSerializers.get(c)) == null)
{
throw new IllegalStateException(MessageFormat.format(JISystem.getLocalizedMessage(JIErrorCodes.JI_UTIL_SERDESER_NOT_FOUND),new String[]{c.toString()}));
}
return ((SerializerDeserializer)mapOfSerializers.get(c)).getLengthInBytes(obj,FLAG);
}
}
示例5: getSupportedType
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
static Integer getSupportedType(Object o, int defaultType)
{
Class c = o.getClass();
Integer retval = (Integer)supportedTypes.get(c);
// Order is important since IJIDispatch derieves from IJIComObject
if(retval == null && o instanceof IJIDispatch)
{
retval = new Integer(VT_DISPATCH);
}
if(retval == null && o instanceof IJIComObject)
{
retval = new Integer(VT_UNKNOWN);
}
return retval;
}
示例6: connect
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* Create a new session.
*
* @throws KettleException
*/
public void connect() throws KettleException {
try {
JISystem.getLogger().setLevel(Level.OFF);
JISystem.setAutoRegisteration(true);
if(Const.isEmpty(getHost())) {
this.session = JISession.createSession();
}else {
this.session = JISession.createSession(getDomain(), getUserName(), this.password);
}
this.session.useSessionSecurity(true);
if(log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "WMIQuery.SessionCreated", this.session.getSessionIdentifier()));
}
this.comServer = new JIComServer(valueOf("WbemScripting.SWbemLocator"), this.hostName , this.session);
this.wbemLocator = (IJIDispatch) narrowObject(this.comServer.createInstance().queryInterface(IID));
}catch(Exception e) {
throw new KettleException(e);
}
}
示例7: getNextRow
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* Returns next row data
* returns null where there is no more row
* use getNextRow to get next row
*
* @return next row
* @throws KettleException
*/
public Object[] getNextRow() throws KettleException {
if(this.rowsCount==0) return null;
this.rowProcessed++;
if(this.rowProcessed>=this.rowsCount) return null;
try {
Object[] values = enumVARIANT.next(1);
JIArray array = (JIArray)values[0];
Object[] arrayObj = (Object[])array.getArrayInstance();
IJIDispatch wbemObject_dispatch = (IJIDispatch) narrowObject(((JIVariant)arrayObj[0]).getObjectAsComObject());
JIVariant variant2 = (JIVariant)(wbemObject_dispatch.callMethodA("GetObjectText_",new Object[]{new Integer(1)}))[0];
return getRowData(variant2.getObjectAsString().getString());
}catch(Exception e) {
throw new KettleException(e);
}
}
示例8: getSecurity
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* The security property is used to read, or set the security settings.
* This property is an {@link SWbemSecurity} object. The security settings in this object do not indicate the authentication,
* impersonation, or privilege settings made on a connection to Windows Management Instrumentation (WMI),
* or the security in effect for the proxy when an object is delivered to a sink in an asynchronous call.
* <p><strong>Note: </strong> Setting the Security_ property of an SWbemObject object to NULL grants unlimited access to everyone all the time.
* For more information, see {@link SWbemSecurity}.</p>
* @return The security settings of this WMI object.
* @throws WMIException
*/
public SWbemSecurity getSecurity() throws WMIException {
try {
JIVariant result = dispatch.get("Security_");
IJIComObject comObject = result.getObjectAsComObject();
IJIDispatch securityDispatch = (IJIDispatch) JIObjectFactory.narrowObject(comObject);
return new SWbemSecurity(securityDispatch);
} catch (JIException e) {
throw new WMIException(e);
}
}
示例9: getSWbemObjectValue
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
public SWbemObject getSWbemObjectValue() throws WMIException {
try {
IJIDispatch dispatch = (IJIDispatch) JIObjectFactory.narrowObject(variant.getObjectAsComObject());
return new SWbemObject(dispatch);
} catch (JIException e) {
throw new WMIException(e);
}
}
示例10: performInstanceOf
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/** {@inheritDoc} */
public OnmsWbemObjectSet performInstanceOf(final String wmiClass) throws WmiException {
try {
// Execute the InstancesOf method on the remote SWbemServices object.
final JIVariant results[] = m_WbemServices.callMethodA("InstancesOf", new Object[]{new JIString(wmiClass), 0, JIVariant.OPTIONAL_PARAM()});
final IJIDispatch wOSd = (IJIDispatch) JIObjectFactory.narrowObject((results[0]).getObjectAsComObject());
return new OnmsWbemObjectSetImpl(wOSd);
} catch (final JIException e) {
throw new WmiException("Failed to perform WMI operation (\\\\" + wmiClass + ") : " + e.getMessage(), e);
}
}
示例11: performExecQuery
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/** {@inheritDoc} */
public OnmsWbemObjectSet performExecQuery (final String strQuery, final String strQueryLanguage, final Integer flags) throws WmiException {
try {
final JIVariant results[] = m_WbemServices.callMethodA("ExecQuery", new Object[]{new JIString(strQuery), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
final IJIDispatch wOSd = (IJIDispatch)JIObjectFactory.narrowObject((results[0]).getObjectAsComObject());
return new OnmsWbemObjectSetImpl(wOSd);
} catch(final JIException e) {
throw new WmiException("Failed to execute query '" + strQuery + "': " + e.getMessage(), e);
}
}
示例12: performWmiGet
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* <p>performWmiGet</p>
*
* @param strObjectPath a {@link java.lang.String} object.
* @return a {@link org.opennms.protocols.wmi.wbem.OnmsWbemObject} object.
* @throws org.opennms.protocols.wmi.WmiException if any.
*/
public OnmsWbemObject performWmiGet(final String strObjectPath) throws WmiException {
try {
final JIVariant results[] = m_WbemServices.callMethodA("Get", new Object[]{new JIString(strObjectPath), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM()});
final IJIDispatch obj_dsp = (IJIDispatch) JIObjectFactory.narrowObject((results[0]).getObjectAsComObject());
return new OnmsWbemObjectImpl(obj_dsp);
} catch (final JIException e) {
throw new WmiException("Failed to perform get '" + strObjectPath + "': " + e.getMessage(), e);
}
}
示例13: performSubclassOf
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* <p>performSubclassOf</p>
*
* @param strSuperClass a {@link java.lang.String} object.
* @return a {@link org.opennms.protocols.wmi.wbem.OnmsWbemObjectSet} object.
* @throws org.opennms.protocols.wmi.WmiException if any.
*/
public OnmsWbemObjectSet performSubclassOf(final String strSuperClass) throws WmiException {
try {
final JIVariant results[] = m_WbemServices.callMethodA("SubclassesOf", new Object[]{new JIString(strSuperClass), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM()});
final IJIDispatch objset_dsp = (IJIDispatch) JIObjectFactory.narrowObject((results[0]).getObjectAsComObject());
return new OnmsWbemObjectSetImpl(objset_dsp);
} catch (final JIException e) {
throw new WmiException("Failed to perform SubclassesOf '" + strSuperClass + "': " + e.getMessage(), e);
}
}
示例14: getWmiMethods
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* <p>getWmiMethods</p>
*
* @return a {@link org.opennms.protocols.wmi.wbem.OnmsWbemMethodSet} object.
* @throws org.opennms.protocols.wmi.WmiException if any.
*/
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);
}
}
示例15: getWmiPath
import org.jinterop.dcom.impls.automation.IJIDispatch; //导入依赖的package包/类
/**
* <p>getWmiPath</p>
*
* @return a {@link org.opennms.protocols.wmi.wbem.OnmsWbemObjectPath} object.
* @throws org.opennms.protocols.wmi.WmiException if any.
*/
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);
}
}