Top Description Fields Constructors Methods
com.sun.star.lib.uno.helper

public Class WeakAdapter

extends Object
implements com.sun.star.uno.XAdapter
Class Inheritance
Imports
java.lang.ref.WeakReference, com.sun.star.uno.XAdapter, com.sun.star.uno.XReference, java.util.List, .Collections, .LinkedList

An XAdapter implementation that holds a weak reference (java.lang.ref.WeakReference) to an object. Clients can register listener (com.sun.star.lang.XReference) which are notified when the object (the one which is kept weak) is being finalized. That is, that object is being destroyed because there are not any hard references to it.

Field Summary

Modifier and TypeField and Description
private final WeakReference<Object>
private final List<com.sun.star.uno.XReference>

Constructor Summary

AccessConstructor and Description
public
WeakAdapter(Object
the object that is to be held weak
component
)

Method Summary

Modifier and TypeMethod and Description
public void
addReference(com.sun.star.uno.XReference
listener
xReference
)

Method of com.sun.star.uno.XAdapter.

public Object

Returns:

hard reference to the object
queryAdapted
()

Method of com.sun.star.uno.XAdapter.

pack-priv void
referentDying()

Called by the XWeak implementation (WeakBase) when it is being finalized.

public void
removeReference(com.sun.star.uno.XReference
a listener
xReference
)

Method of com.sun.star.uno.XAdapter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_weakRefback to summary
private final WeakReference<Object> m_weakRef
m_xreferenceListback to summary
private final List<com.sun.star.uno.XReference> m_xreferenceList

Constructor Detail

WeakAdapterback to summary
public WeakAdapter(Object component)
Parameters
component:Object

the object that is to be held weak

Method Detail

addReferenceback to summary
public void addReference(com.sun.star.uno.XReference xReference)

Method of com.sun.star.uno.XAdapter. Called by clients to unregister listeners.

Parameters
xReference:com.sun.star.uno.XReference

listener

queryAdaptedback to summary
public Object queryAdapted()

Method of com.sun.star.uno.XAdapter. It is called to obtain a hard reference to the object which is kept weak by this instance.

Returns:Object

hard reference to the object

referentDyingback to summary
pack-priv void referentDying()

Called by the XWeak implementation (WeakBase) when it is being finalized. It is only being called once. The registered XReference listeners are notified. On notification they are to unregister themselves. The notification is thread-safe. However, it is possible to add a listener during the notification process, which will never receive a notification. To prevent this, one would have to synchronize this method with the addReference method. But this can result in deadlocks in a multi-threaded environment.

removeReferenceback to summary
public void removeReference(com.sun.star.uno.XReference xReference)

Method of com.sun.star.uno.XAdapter. Called by clients to register listener which are notified when the weak object is dying.

Parameters
xReference:com.sun.star.uno.XReference

a listener