Regarding Matt's suggestion: this could work under some
circumstancces. You might even be able to use PipedInputStream and
PipedOutputStream to make the connection without explicitly moving the
data from the writing stage to the reading stage.

This does, though, have some problems. readObject/writeObject must
discard everything not serializable which includes, unfortunately,
readers and writers; so this clone would discard all I/O routers. It
would also lose all registered event handlers, and it would make
duplicates of any definstanced beans. In a situation like Willie's
where the Rete object is likely connected rather densely to a GUI
interface, this could make a big mess.

That's the problem with implementing a generic method like clone() for
a very complex object like Rete: subtleties in the definition can't
be satisfactorily resoved for everyone at once. In this case there's
no good middle ground, really, so I'd prefer to simply let people use
ad-hoc solutions like the one presented here.

Future restructuring (Rete has already been radically restructured in
the latest release, and there may be more to come) might improve
matters somewhat.



I think Matt Bishop wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
>  One way you could clone is to serialize the Rete object to an in-memory
> array, then deserialize from that array as needed.  It would be as fast as a
> deep clone, maybe faster.
> 
> The trick is determining how big of an array you'd need, but that can be
> determined by serializing to a file and counting the bytes.  Add a few K
> just for safety's sake.
> 
> The relevant classes are java.io.ByteArrayInputStream and
> java.io.ByteArrayOutputStream.
> 
> 
> -Matt Bishop
> 
> 
> -----Original Message-----
> From: Willie Wheeler
> To: [EMAIL PROTECTED]
> Sent: 02/27/2001 2:02 PM
> Subject: JESS: Question about cloning Rete
> 
> Hi Ernest, or anyone who knows the answer, :-)
> 
>       Earlier this month (2/8/01) a user asked how to clone a Rete
> instance, and the answer was to bsave and bload.  While this works for
> my
> application, it is a little slow.  Ernest said that there is no
> Rete.clone() and that he has no plans to support it.  I am curious as to
> the reason--is it that performance would be no better than bload/bsave,
> is
> it that there is insufficient user interest, etc.?
>       Maybe there is a better way to do what I'm trying to do.  
> Basically I need to perform revert() operations on the Rete instance
> from
> time to time.  To accomplish this I have been cloning the Rete instance
> before performing operations that end in a revert.
> 
>       Thanks,
>       Willie
> 
> 
> 

---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to