org.jinterop.dcom.core
Class JIComObjectImplWrapper

java.lang.Object
  extended by org.jinterop.dcom.core.JIComObjectImplWrapper
All Implemented Interfaces:
java.io.Serializable, IJIComObject

public class JIComObjectImplWrapper
extends java.lang.Object
implements IJIComObject

Internal Framework class.

Since:
1.0
See Also:
Serialized Form

Field Summary
protected  IJIComObject comObject
           
 
Fields inherited from interface org.jinterop.dcom.core.IJIComObject
IID
 
Constructor Summary
protected JIComObjectImplWrapper(IJIComObject comObject)
           
 
Method Summary
 void addRef()
          Increases the reference count on the COM server by 5 (currently hard coded).
 java.lang.Object[] call(JICallBuilder obj)
          Executes a method call on the actual COM object represented by this interface.
 java.lang.Object[] call(JICallBuilder obj, int timeout)
           Refer IJIComObject.call(JICallBuilder) for details on this method.
 JISession getAssociatedSession()
          Returns session associated with this object.
 int getInstanceLevelSocketTimeout()
          Returns the socket timeout set at the instance level.
 java.lang.String getInterfaceIdentifier()
          Returns the IID of this object
 java.lang.String getIpid()
          Unique 128 bit uuid representing the interface on the COM server.
 IJIUnreferenced getUnreferencedHandler()
          Returns the IJIUnreferenced handler associated with this object.
 java.lang.Object[] internal_getConnectionInfo(java.lang.String identifier)
          Framework Internal Returns the ConnectionPoint (IJIComObject) and it's Cookie.
 org.jinterop.dcom.core.JIInterfacePointer internal_getInterfacePointer()
          Framework Internal Returns self Interface pointer.
 java.lang.Object[] internal_removeConnectionInfo(java.lang.String identifier)
          Framework Internal Returns and Removes the connection info from the internal map.
 java.lang.String internal_setConnectionInfo(IJIComObject connectionPoint, java.lang.Integer cookie)
          Adds a connection point information and it's cookie to the connectionPointMap internally.
 void internal_setDeffered(boolean deffered)
          Framework Internal
 boolean isDispatchSupported()
          Returns true if IDispatch interface is supported by this object.
 boolean isLocalReference()
          Returns true if this COM object represents a local Java reference obtained by JIObjectFactory.buildObject(JISession, JILocalCoClass).
 IJIComObject queryInterface(java.lang.String iid)
          Retrieve interface references based on iid.
 void registerUnreferencedHandler(IJIUnreferenced unreferenced)
          Adds a IJIUnreferenced handler.
 void release()
           Decreases the reference count on the COM server by 5 (currently hard coded).
 void setInstanceLevelSocketTimeout(int timeout)
          Sets a timeout for all socket level operations done on this object.
 java.lang.String toString()
           
 void unregisterUnreferencedHandler()
          Removes the IJIUnreferenced handler associated with this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

comObject

protected final IJIComObject comObject
Constructor Detail

JIComObjectImplWrapper

protected JIComObjectImplWrapper(IJIComObject comObject)
Method Detail

queryInterface

public IJIComObject queryInterface(java.lang.String iid)
                            throws JIException
Description copied from interface: IJIComObject

Retrieve interface references based on iid. Make sure to narrow before casting to the expected type.

For example when expecting an IJIEnumVariant :-

IJIComObject object2 = variant.getObjectAsComObject();
IJIEnumVariant enumVariant = (IJIEnumVariant)JIObjectFactory.narrowObject(object2.queryInterface(IJIEnumVariant.IID));

Throws IllegalStateException if IJIComObject.isLocalReference() returns true.

Specified by:
queryInterface in interface IJIComObject
Parameters:
iid - string representation of the IID.
Returns:
reference to the requested unknown.
Throws:
JIException
See Also:
JIObjectFactory.narrowObject(IJIComObject)

addRef

public void addRef()
            throws JIException
Description copied from interface: IJIComObject

Increases the reference count on the COM server by 5 (currently hard coded). The developer should refrain from calling this API, as referencing is maintained internally by the system though he is not obligated to do so. If the IJIComObject.release() is not called in conjunction with addRef then the COM Instance will not get garbage collected at the server.

Specified by:
addRef in interface IJIComObject
Throws:
JIException

release

public void release()
             throws JIException
Description copied from interface: IJIComObject

Decreases the reference count on the COM server by 5 (currently hard coded). The developer should refrain from calling this API, as referencing is maintained internally by the system though he is not obligated to do so. If the release is not called in conjunction with IJIComObject.addRef() then the COM Instance will not get garbage collected at the server.

Specified by:
release in interface IJIComObject
Throws:
JIException

getIpid

public java.lang.String getIpid()
Description copied from interface: IJIComObject
Unique 128 bit uuid representing the interface on the COM server. This value can and should be used to map an IJIUnreferenced handler implementation to this COM Object.

Under NO circumstances should a reference to this COM object be stored any where for only purposes of "unreferenced" handling. This would hinder the way in which objects are garbage collected by the framework and this object would be forever "live".

Specified by:
getIpid in interface IJIComObject
Returns:
string representation of ipid.

call

public java.lang.Object[] call(JICallBuilder obj)
                        throws JIException
Description copied from interface: IJIComObject

Executes a method call on the actual COM object represented by this interface. All the data like parameter information, operation number etc. are prepared and sent via the JICallBuilder.

JICallBuilder obj = new JICallBuilder();
obj.reInit();
obj.setOpnum(0); //methods are sequentially indexed from 0 in the IDL
obj.addInParamAsString(new JIString("j-Interop Rocks",JIFlags.FLAG_REPRESENTATION_STRING_LPCTSTR), JIFlags.FLAG_NULL);
obj.addInParamAsPointer(new JIPointer(new JIString("Pretty simple ;)",JIFlags.FLAG_REPRESENTATION_STRING_LPCTSTR)), JIFlags.FLAG_NULL);

Object[] result = comObject.call(obj);

If return values are expected then set up the Out Params also in the JICallBuilder.

The call timeout used here , by default is the instance level timeout. If no instance level timeout has been specified(or is 0) then the global timeout set in JISession will be used.

Specified by:
call in interface IJIComObject
Parameters:
obj - call builder carrying all information necessary to make the call successfully.
Returns:
Object[] array representing the results in the order expected or set in JICallBuilder.
Throws:
JIException
See Also:
IJIComObject.setInstanceLevelSocketTimeout(int), JISession.setGlobalSocketTimeout(int)

internal_getInterfacePointer

public org.jinterop.dcom.core.JIInterfacePointer internal_getInterfacePointer()
Description copied from interface: IJIComObject
Framework Internal Returns self Interface pointer.

Specified by:
internal_getInterfacePointer in interface IJIComObject

getAssociatedSession

public JISession getAssociatedSession()
Description copied from interface: IJIComObject
Returns session associated with this object.

Specified by:
getAssociatedSession in interface IJIComObject
Returns:
JISession

getInterfaceIdentifier

public java.lang.String getInterfaceIdentifier()
Returns the IID of this object

Specified by:
getInterfaceIdentifier in interface IJIComObject
Returns:
String representation of 128 bit uuid.

isDispatchSupported

public boolean isDispatchSupported()
Description copied from interface: IJIComObject
Returns true if IDispatch interface is supported by this object.

Specified by:
isDispatchSupported in interface IJIComObject
Returns:
true if IDispatch is supported, false otherwise.
See Also:
IJIDispatch

internal_setConnectionInfo

public java.lang.String internal_setConnectionInfo(IJIComObject connectionPoint,
                                                   java.lang.Integer cookie)
Description copied from interface: IJIComObject
Adds a connection point information and it's cookie to the connectionPointMap internally. To be called only by the framework.

Specified by:
internal_setConnectionInfo in interface IJIComObject
Returns:
unique identifier for the combination.

internal_getConnectionInfo

public java.lang.Object[] internal_getConnectionInfo(java.lang.String identifier)
Description copied from interface: IJIComObject
Framework Internal Returns the ConnectionPoint (IJIComObject) and it's Cookie.

Specified by:
internal_getConnectionInfo in interface IJIComObject
Returns:

internal_removeConnectionInfo

public java.lang.Object[] internal_removeConnectionInfo(java.lang.String identifier)
Description copied from interface: IJIComObject
Framework Internal Returns and Removes the connection info from the internal map.

Specified by:
internal_removeConnectionInfo in interface IJIComObject
Returns:

getUnreferencedHandler

public IJIUnreferenced getUnreferencedHandler()
Description copied from interface: IJIComObject
Returns the IJIUnreferenced handler associated with this object.

Specified by:
getUnreferencedHandler in interface IJIComObject
Returns:
null if no handler is associated with this object.

registerUnreferencedHandler

public void registerUnreferencedHandler(IJIUnreferenced unreferenced)
Description copied from interface: IJIComObject
Adds a IJIUnreferenced handler. The handler will be invoked when this comObject goes out of reference and is removed from it's session by the library. Only a single handler can be added for each object. If a handler for this object already exists , it would be replaced by this call.

Specified by:
registerUnreferencedHandler in interface IJIComObject
Parameters:
unreferenced - handler to get notification when reference count for this object hits 0 and is garbage collected by the library's runtime.

unregisterUnreferencedHandler

public void unregisterUnreferencedHandler()
Description copied from interface: IJIComObject
Removes the IJIUnreferenced handler associated with this object. No exception will be thrown if one does not exist for this object.

Specified by:
unregisterUnreferencedHandler in interface IJIComObject

call

public java.lang.Object[] call(JICallBuilder obj,
                               int timeout)
                        throws JIException
Description copied from interface: IJIComObject

Refer IJIComObject.call(JICallBuilder) for details on this method.

Specified by:
call in interface IJIComObject
Parameters:
obj - call builder carrying all information necessary to make the call successfully.
timeout - timeout for this call in milliseconds, overrides the instance level timeout. Passing 0 here will use the global socket timeout.
Returns:
Object[] array representing the results in the order expected or set in JICallBuilder.
Throws:
JIException
See Also:
JISession.setGlobalSocketTimeout(int)

getInstanceLevelSocketTimeout

public int getInstanceLevelSocketTimeout()
Description copied from interface: IJIComObject
Returns the socket timeout set at the instance level. This timeout value is used during all socket level operations such as IJIComObject.call(JICallBuilder) , IJIComObject.queryInterface(String) etc.

Specified by:
getInstanceLevelSocketTimeout in interface IJIComObject
Returns:
timeout set on this object in milliseconds.

setInstanceLevelSocketTimeout

public void setInstanceLevelSocketTimeout(int timeout)
Description copied from interface: IJIComObject

Sets a timeout for all socket level operations done on this object. Calling this overrides the global socket timeout at the JISession level. To unset a previous timeout, pass 0 as a parameter.

Specified by:
setInstanceLevelSocketTimeout in interface IJIComObject
Parameters:
timeout - timeout for this call in milliseconds
See Also:
JISession.setGlobalSocketTimeout(int)

internal_setDeffered

public void internal_setDeffered(boolean deffered)
Description copied from interface: IJIComObject
Framework Internal

Specified by:
internal_setDeffered in interface IJIComObject

isLocalReference

public boolean isLocalReference()
Description copied from interface: IJIComObject
Returns true if this COM object represents a local Java reference obtained by JIObjectFactory.buildObject(JISession, JILocalCoClass).

Specified by:
isLocalReference in interface IJIComObject
Returns:
true if this is a local reference , false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object