org.isis.jaut
Class ApartmentObject

java.lang.Object
  extended byorg.isis.jaut.ApartmentObject
Direct Known Subclasses:
Dispatch, Variant

public abstract class ApartmentObject
extends java.lang.Object

The ApartmentObject allows derived objects to release their resources from the same Apartment when finalized. This class is abstract, derived classes must implement the release() method, and call #releaseInApartment from their finalize method if a resource cannot be freed from the current Thread.


Field Summary
protected  Apartment apartment
          Holds the Apartment this object was created in.
 
Constructor Summary
protected ApartmentObject()
          Creates an ApartmentObject in the current Apartment.
 
Method Summary
protected  void finalizeInApartment()
          Calls the release() method from a Thread that belongs to the Apartment of this object.
 Apartment getApartment()
          Retrives the Apartment in which this object was created in.
abstract  void release()
          This method is called from the Apartment.leave() when the last Thread leaves the Apartment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

apartment

protected Apartment apartment
Holds the Apartment this object was created in.

Constructor Detail

ApartmentObject

protected ApartmentObject()
Creates an ApartmentObject in the current Apartment.

Throws:
JAutException - if this Thread did not enter an Apartment. If you receive this exception, then probably you forgot to initialize COM by calling Apartment.enter(boolean).
See Also:
Apartment.currentApartment(), Apartment.enter(boolean)
Method Detail

getApartment

public Apartment getApartment()
Retrives the Apartment in which this object was created in.


release

public abstract void release()
This method is called from the Apartment.leave() when the last Thread leaves the Apartment. Derived classes must override this to release all Apartment specific resources (like interface pointers). It is guaranteed that this method will be called from a Thread that is part of the Apartment this object was created in.


finalizeInApartment

protected final void finalizeInApartment()
Calls the release() method from a Thread that belongs to the Apartment of this object. Call this method from the derived object finalizer. If the current Thread belongs to the Apartment of this object, then release() is called immediately, otherwise the release() will be called later.