WebObjects 5.2

com.webobjects.foundation
Class NSDisposableRegistry

java.lang.Object
  |
  +--com.webobjects.foundation.NSDisposableRegistry
All Implemented Interfaces:
NSDisposable

public class NSDisposableRegistry
extends Object
implements NSDisposable

A NSDisposableRegistry object is a registry of NSDisposable objects that should be disposed when the registry is disposed. Objects can be added to a registry with addObject and addObjectsFromRegistry, or removed with removeObject

There are two ways you may interact with a disposable registry: adding objects to another object's registry and creating a class whose instances manage their own disposable registries.

As an example of the former, consider the EOController class (defined in the eoapplication package and used in Direct to Java Client applications). EOController has a disposable registry, which you can access with the EOController method disposableRegistry. In EOController's dispose method, it disposes its disposable registry, which in turn disposes all its objects. You can get a Controller's registry and add objects to it; they will be disposed along with the EOController.

The second way to interact with a disposable registry is to create a class similar to EOController that uses a disposable registry to group objects that should be disposed of along with instances of class.

See Also:
addObject(com.webobjects.foundation.NSDisposable), addObjectsFromRegistry(com.webobjects.foundation.NSDisposableRegistry), removeObject(com.webobjects.foundation.NSDisposable), dispose(), NSDisposable

Constructor Summary
NSDisposableRegistry()
          Creates an empty disposable registry.
 
Method Summary
 void addObject(NSDisposable disposable)
          Adds disposable to the receiver so that disposable will be disposed when this registry is disposed.
 void addObjectsFromRegistry(NSDisposableRegistry registry)
          Adds the objects in registry to this registry, so that registry's objects will be disposed when this one is disposed.
 void dispose()
          Conformance to NSDisposable.
 void removeObject(NSDisposable object)
          Removes object from the receiver.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NSDisposableRegistry

public NSDisposableRegistry()
Creates an empty disposable registry.
Method Detail

addObject

public void addObject(NSDisposable disposable)
Adds disposable to the receiver so that disposable will be disposed when this registry is disposed.
Parameters:
disposable - input objects to be disposed

addObjectsFromRegistry

public void addObjectsFromRegistry(NSDisposableRegistry registry)
Adds the objects in registry to this registry, so that registry's objects will be disposed when this one is disposed.

Parameters:
registry - a collection of objects to be disposed

dispose

public void dispose()
Conformance to NSDisposable. NSDisposableRegistry's implementation simply sends dispose to all its objects.
Specified by:
dispose in interface NSDisposable
See Also:
NSDisposable.dispose()

removeObject

public void removeObject(NSDisposable object)
Removes object from the receiver.
Parameters:
object - input object that ill be removed from the receiver

toString

public String toString()
Overrides:
toString in class Object
Returns:
a string representation of this registry

Last updated Fri Feb 21 13:15:00 PST 2003.

Copyright © 2003 Apple Computer, Inc.