de.intarsys.tools.component
Interface IReferenceCounter
public interface IReferenceCounter
An object that is aware of its referents.
The object implements a reference counting mechanism that should behave like
this:
- the object should keep a counter that increments when acquired and
decrements when released
- upon creation the object should be acquired by the constructor or
factory method.
- if the client code is not aware if a new object is created (or taken
from a registry for example), the object published by the factory method
should always be acquired.
- the object should not accept method calls before it is acquired
- when the counter is zero after release, the object should no longer
accept any calls
If combined with the INotificationSupport
, the object MAY trigger an
AttributeChangedEvent
upon acquire/release. In this case the
ATTR_REFERENCECOUNT
should be used to indicate the attribute.
If combined with the INotificationSupport
, the object MAY trigger a
DestroyedEvent
when the reference count reaches 0.
ATTR_REFERENCECOUNT
static final Attribute ATTR_REFERENCECOUNT
acquire
void acquire()
getReferenceCount
int getReferenceCount()
release
void release()
Copyright © 2008 intarsys consulting GmbH. All Rights Reserved.