This content has been marked as final. Show 5 replies
Hi,1 person found this helpful
To answer your question we need a little more information. If you created a PersistentProxy for CopyOnWriteArrayList and you registered it properly, then it should work in JE 3.3 and 4.0. Perhaps there is something you were doing wrong, but it just happened to work in 3.3, and it no longer works in 4.0.
Could you please post the details on what your proxy class looks like and how you are registering it?
In fact I have not created a proxy class.
In the object I want to save with BerkeleyDB, I used to have that attribute "ArrayList<String> myList = new ArrayList<String>(); "
Save was ok.
The issue came when I replaced ArrayList by CopyOnWriteArrayList, said everywhere to be equivalent but thread-safe.
"CopyOnWriteArrayList<String> myList = new CopyOnWriteArrayList<String>(); "
does not work
It seems that that class is nor really equivalent.
What shall I do?
Please see the javadoc for PersistentProxy. You will need to create one. There is a built in proxy for ArrayList, but not for the class you're using.1 person found this helpful
I'm curious about why you need thread safety. In general, persistent objects are only used by one thread at a time.
I will read the proxy doc.
My software has a graph of objects with mutual invocations.
The ArrayList is for the identifiers of the connected nodes.
Nodes are to be made persistent.
Several threads invoke nodes, which themselves invoke nodes etc. so I have the problem of making that thread-safe.
In addition to looking at the PersistentProxy javadoc, I strongly suggest looking at the source code for the built-in collection proxy objects:
This includes the implementation of the proxy for ArrayList.