public class JIObjectFactory extends Object
Sample Usage:-
//Assume comObject is the reference to IJIComObject, obtained earlier...
newComObject =
(IJIComObject)comObject.queryInterface("76A6415B-CB41-11d1-8B02-00600806D9B6");//ISWbemLocator
This will obtain the dispatch interface
dispatch =
(IJIDispatch)JIObjectFactory.narrowObject(newComObject.queryInterface(IJIDispatch.IID));
| Modifier and Type | Method and Description |
|---|---|
static String |
attachEventHandler(IJIComObject comObject,
String sourceUUID,
IJIComObject eventListener)
Attaches an event handler to
comObject for the source event
interface of COM , identified by the sourceUUID. |
static IJIComObject |
buildObject(JISession session,
byte[] rawBytes)
Returns a COM Object from raw bytes.
|
static IJIComObject |
buildObject(JISession session,
byte[] rawBytes,
String ipAddress)
Returns a COM Object from raw bytes.
|
static IJIComObject |
buildObject(JISession session,
JILocalCoClass javaComponent)
Returns a local COM Object representation for the Java component.
|
static void |
detachEventHandler(IJIComObject comObject,
String identifier)
Detaches the event handler identified by
identifier and
associated with this comObject. |
static IJIComObject |
narrowObject(IJIComObject comObject)
Narrows the
comObject into its right type based on
it's IID. |
static IJIComObject |
narrowObject(JISession session,
IJIComObject comObject)
Typically used in the Man-In-The-Middle scenario.
|
public static String attachEventHandler(IJIComObject comObject, String sourceUUID, IJIComObject eventListener) throws JIException
comObject for the source event
interface of COM , identified by the sourceUUID. The event
listener is itself identified by eventListener. An exception
will be raised if sourceUUID is not supported by the COM
Server.comObject - object to which the listener will be attached.sourceUUID - IID of the call back interface.eventListener - IJIComObject obtained using
buildObject(JISession, JILocalCoClass)detachEventHandler(IJIComObject, String)JIExceptionIllegalArgumentException - if any parameter is null or
sourceUUID is empty.public static void detachEventHandler(IJIComObject comObject, String identifier) throws JIException
identifier and
associated with this comObject. This method will raise an
exception if the identifier is invalid.comObject - identifier - JIExceptionpublic static IJIComObject narrowObject(IJIComObject comObject) throws JIException
comObject into its right type based on
it's IID. For example, passing a comObject
which is a COM IDispatch reference will return a reference
which can be safely casted to IJIDispatch interface.comObject - JIExceptionIllegalArgumentException - if comObject is
null or a local reference.public static IJIComObject buildObject(JISession session, JILocalCoClass javaComponent) throws JIException
IJIComObject.IsLocalReference() method will return
true for all objects built by this method. Another important
point to note is that a javaComponent can only export one
reference to itself. Reusing the same javaComponent in
another call to this method will raise an exception.session - session to attach comObject to.javaComponent - JIExceptionpublic static IJIComObject buildObject(JISession session, byte[] rawBytes) throws JIException
session - session to attach comObject to. If required
the framework will create a new session for this comObject
and link the session to the new one. This new session will
be destroyed when the parent session is destroyed.rawBytes - bytes representing the interface pointer.JIExceptionIllegalArgumentException - if rawBytes is an invalid
representation.public static IJIComObject buildObject(JISession session, byte[] rawBytes, String ipAddress) throws JIException
session - session to attach comObject to. If required
the framework will create a new session for this comObject
and link the session to the new one. This new session will
be destroyed when the parent session is destroyed.rawBytes - bytes representing the interface pointer.ipAddress - can be null. Sometimes there are many
adapters (virtual as well) on the Target machine to which this interface
pointer belongs, which may get sent as part of the interface pointer and
consequently this call will fail since it is a possibility that IP is not
reachable via this machine. The developer can send in the valid IP and if
found in the interface pointer list will be used to talk to the target
machine, overriding the other IP addresses present in the interface
pointer. If this IP is not found then the "machine name" binding will be
used. If this param is null then the first binding obtained
from the interface pointer is used.JIExceptionIllegalArgumentException - if rawBytes is an invalid
representation.public static IJIComObject narrowObject(JISession session, IJIComObject comObject) throws JIException
Some possible use-cases :-
IJIComObject is read from a database and is not
attached to a session.session - session to attach comObject to. If required
the framework will create a new session for this comObject
and link the session to the new one. This new session will
be destroyed when the parent session is destroyed.comObject - drifting object.JIExceptionIllegalArgumentException - if comObject is
null or a local reference.IJIComObject.isLocalReference()Copyright © 2022. All rights reserved.