On Sun, Feb 13, 2011 at 8:39 PM, Seth <wbu...@gmail.com> wrote: > I have an application which contains a number of running threads, each > which has a state to it. A state is a single record. It contains some > random stuff, but most importantly it a has a :var slot which contains > a map in which the keys are vars and the values are whatever the vars > are (if they can be dynamically updated, they are atoms/refs types > otherwise they are simple constants). > > I have tried a simple print-dup method. This works fine when I dont > have java objects in it. But when i have things like DateTimes and > such, it doesnt work. On the other side of things, serializing wont > work for things like functions (i think) that are a value in the > map. When i print-dup, functions work fine , because they output > something like (find-symbol ....). So, i need a combination of print- > dup for clojure objects and serializing for java objects. > > Is there any solution out there that does this, saving it all to a > database? I was thinking that a special record could be produced > which wraps around the clojure objects when serializing and then when > deserializing, it could do what one does with print-dup method - and > for regular java objects, simple serialization could be used.
Is print-dup a multi-method or a protocol and your set of Java objects closed? If so, you can extend print-dup to the Java objects to output #=(JavaClass. constructor args) or whatnot; if the set of Java objects is open-ended you may have to resort to #=(.readObject (ObjectInputStream. (ByteArrayInputStream. (binhex/decode "4JK09bX38dQ1jl...")))). :) (Implementation of binhex/decode, and of the encoding half of all of this, is left as an exercise for the reader.) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en