WebObjects 5.4.2

com.webobjects.foundation
Class NSDisposableRegistry

java.lang.Object
  extended by 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:
NSDisposableRegistry.addObject(com.webobjects.foundation.NSDisposable), NSDisposableRegistry.addObjectsFromRegistry(com.webobjects.foundation.NSDisposableRegistry), NSDisposableRegistry.removeObject(com.webobjects.foundation.NSDisposable), NSDisposableRegistry.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

removeObject

public void removeObject(NSDisposable object)
Removes object from the receiver.

Parameters:
object - input object that ill be removed from the receiver

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()

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

toString

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

Last updated June 2008

Copyright © 2000-2008 Apple Inc.