Package 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 anAttributeChangedEvent
upon acquire/release. In this case theATTR_REFERENCECOUNT
should be used to indicate the attribute.If combined with the
INotificationSupport
, the object MAY trigger aDestroyedEvent
when the reference count reaches 0.
-
-
Field Summary
Fields Modifier and Type Field Description static Attribute
ATTR_REFERENCECOUNT
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
acquire()
int
getReferenceCount()
void
release()
-
-
-
Field Detail
-
ATTR_REFERENCECOUNT
static final Attribute ATTR_REFERENCECOUNT
-
-