com.linar.jintegra
Class Cleaner

java.lang.Object
  extended by com.linar.jintegra.Cleaner

public abstract class Cleaner
extends java.lang.Object

This class is used to programatically release references to COM objects.

References are normally released when the Java object is garbage collected. However, there are times when you want to force the release.

Consider the case where your object is a proxy to a Microsoft Excel application. The object may not be garbage collected for some time. Until it is, the Excel application holds onto any memory it has allocated, which is typically several megabytes.

By explicitly calling release, the Excel application will exit freeing the resources it was using. At some time later, the Java object will be garbage collected.

For more information, please see Garbage Collection: Releasing Java References to COM Objects.


Method Summary
static void addConnectionListener(com.linar.jintegra.ConnectionListener theListener)
          Adds a listener which is notified when new COM client connection comes in
static void addUnreferencedListener(Unreferenced listener)
          Adds a listener which is invoked when COM releases all references to a Java object.
static void clearCreatorThreadContextFor(java.lang.Object o)
          Clears the thread context for an object.
static void flushLog()
          Flushes the J-Integra® log.
static int getActiveObjectCount()
          Returns the number of active DCOM objects in the system.
static java.lang.String getReleaseStackTraceFor(java.lang.Object anObject)
          For internal use only - never call this method.
static void release(java.lang.Object anObject)
          Releases a specific reference to a COM object.
static void releaseAll()
          Releases all outstanding references to COM objects.
static void releaseAllInCurrentThread()
          Tells the runtime to release all objects used in the current thread since the last 'trackObjectsInCurrentThread' call.
static void removeConnectionListener(com.linar.jintegra.ConnectionListener theListener)
          Removes a listener which is notified when new COM client connection comes in
static void removeUnreferencedListener(Unreferenced listener)
          Removes a listener.
static void reset()
          For internal use only - never call this method.
static void setObjectExportListener(ObjectExportChecker listener)
          Sets a listener which is invoked when a Java object is about to be exported as a COM object
static java.lang.String sizes()
           
static void trackObjectsInCurrentThread()
          Tells the runtime to remember all objects used in the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

releaseAll

public static void releaseAll()
Releases all outstanding references to COM objects. This method must only be called just prior to the JVM terminating.


trackObjectsInCurrentThread

public static void trackObjectsInCurrentThread()
Tells the runtime to remember all objects used in the current thread. Garbage collection of these objects will no longer take place, since the runtime maintains a reference to them.
You must call com.linar.jintegra.Cleaner.releaseAllInCurrentThread to release these objects.

See Also:
releaseAllInCurrentThread()

releaseAllInCurrentThread

public static void releaseAllInCurrentThread()
Tells the runtime to release all objects used in the current thread since the last 'trackObjectsInCurrentThread' call.

See Also:
trackObjectsInCurrentThread()

flushLog

public static void flushLog()
Flushes the J-Integra® log.


getActiveObjectCount

public static int getActiveObjectCount()
Returns the number of active DCOM objects in the system. This is actually akin to the Server load of the system (not used in Client mode). Use this API to get a snapshot of server load in order to determine type of Server License needed.


reset

public static void reset()
For internal use only - never call this method.


release

public static void release(java.lang.Object anObject)
Releases a specific reference to a COM object.

Parameters:
anObject - the object to be released
Throws:
java.lang.IllegalArgumentException - if the object that is passed is not a reference to a COM object.

getReleaseStackTraceFor

public static java.lang.String getReleaseStackTraceFor(java.lang.Object anObject)
For internal use only - never call this method.


addUnreferencedListener

public static void addUnreferencedListener(Unreferenced listener)
Adds a listener which is invoked when COM releases all references to a Java object.

Parameters:
listener - a listener object which will handle the event
See Also:
Unreferenced

removeUnreferencedListener

public static void removeUnreferencedListener(Unreferenced listener)
Removes a listener.

Parameters:
listener - a listener object which will handle the event
See Also:
addUnreferencedListener(com.linar.jintegra.Unreferenced), Unreferenced

setObjectExportListener

public static void setObjectExportListener(ObjectExportChecker listener)
                                    throws java.lang.SecurityException
Sets a listener which is invoked when a Java object is about to be exported as a COM object

Parameters:
listener - a listener object which will handle the event
Throws:
java.lang.SecurityException - if a checker has already been installed
See Also:
ObjectExportChecker

clearCreatorThreadContextFor

public static void clearCreatorThreadContextFor(java.lang.Object o)
Clears the thread context for an object. Used in conjunction with the JINTEGRA_RUN_IN_PARENTS_CONTEXT property

Parameters:
o - the object

addConnectionListener

public static void addConnectionListener(com.linar.jintegra.ConnectionListener theListener)
Adds a listener which is notified when new COM client connection comes in

Parameters:
theListener - a listener object which will handle the event
See Also:
ConnectionListener

removeConnectionListener

public static void removeConnectionListener(com.linar.jintegra.ConnectionListener theListener)
Removes a listener which is notified when new COM client connection comes in

Parameters:
theListener - a listener object which will handle the event
See Also:
ConnectionListener

sizes

public static java.lang.String sizes()