|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jinterop.dcom.impls.JIObjectFactory
public class JIObjectFactory
Factory class for creating COM objects.
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));
Constructor Summary | |
---|---|
JIObjectFactory()
|
Method Summary | |
---|---|
static java.lang.String |
attachEventHandler(IJIComObject comObject,
java.lang.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,
java.lang.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,
java.lang.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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JIObjectFactory()
Method Detail |
---|
public static java.lang.String attachEventHandler(IJIComObject comObject, java.lang.String sourceUUID, IJIComObject eventListener) throws JIException
Attaches an event handler to 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)
JIException
java.lang.IllegalArgumentException
- if any parameter is null
or sourceUUID
is empty.public static void detachEventHandler(IJIComObject comObject, java.lang.String identifier) throws JIException
identifier
and associated with this comObject
. This method
will raise an exception if the identifier
is invalid.
comObject
- identifier
-
JIException
public 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
-
JIException
java.lang.IllegalArgumentException
- 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
-
JIException
public 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.
JIException
java.lang.IllegalArgumentException
- if rawBytes
is an invalid representation.public static IJIComObject buildObject(JISession session, byte[] rawBytes, java.lang.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.
JIException
java.lang.IllegalArgumentException
- 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.
JIException
java.lang.IllegalArgumentException
- if comObject
is null
or a local reference.IJIComObject.isLocalReference()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |