Check if reference to object has been disposed??
I have an interesting little problem. I have created an objectMapHelper class that will grab controls dynimically rather than using the object map.
I now am trying to make it work a little faster and my attempt to do this is to create an ObjectCache. The way it works is everytime my ControlFactory successfully finds and creates a TestObject, it adds it to the Cache. The next time that object is searched for, I look in the cache first, and if found, return the object.
The problem I have occurrs when a control is found in the cache that has been disposed of already. An example is a dailog box that appears, then is dismissed. The next time the control is searched for, it has been disposed of so therefore even though the TestObject is still alive, the reference to the control on screen is dead.
Does anyone know of a way to check a TestObject to see if the reference to the target object has been disposed of?
Here is the find method out of the ObjectCache:
<font class="small">Code:</font><hr /><pre>
public static CControlBase find(String screenName, String reference)
if (screenName != null && screenName.length() > 0 &&
reference != null && reference.length() > 0)
CControlBase hashObject = (CControlBase)m_objectHash.get(getKey(screenName, reference));
if (hashObject != null)
TestObject to = hashObject.getTestObject();
if (to != null)
ITestObjectReference toRef = to.getObjectReference();
Object target = toRef.getTarget();
if (target != null)
// return (CControlBase)m_objectHash.get(getKey(screenName, reference));
Any help would be greatly appreciated.