[rules-dev] Today's Eleusinian mystery: deserializing a package forchange set monitoring

Joe White Joe.White at recondotech.com
Fri Jun 17 11:22:45 EDT 2011


Ah makes sense. Got it. Thanks

 

From: rules-dev-bounces at lists.jboss.org
[mailto:rules-dev-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: Friday, June 17, 2011 9:14 AM
To: Rules Dev List
Subject: Re: [rules-dev] Today's Eleusinian mystery: deserializing a
package forchange set monitoring

 

It does write to a file. You can read it back in, using an
ObjectInputStream

But the KnowledgeAgent uses a DroolsObjectOutputStream for reading.

read/writeExternal of Package behave differently, depending on the 1st
arg being a DroolsObjectInput/OutputStream or an
ObjectInput/OutputStream. The latter reads/writes a byte[]; the former
the members of Package.

The byte[] is a byte stream created from serializing the members of
Package.

Google subject for further insight ;-)

-W



On 17 June 2011 17:06, Joe White <Joe.White at recondotech.com> wrote:

I'm confused (not surprising) This code worked in 5.0.1 but Lisa
indicates that it didn't work for her on 5.2 (I haven't tried it).

 

                    FileOutputStream fos = new
FileOutputStream(drlcFile);

                    ObjectOutputStream oos = new
ObjectOutputStream(fos);

                    oos.writeObject(pkg);

                    oos.close();

 

 

And that code does write to a file. Should this work in 5.2 or shouldn't
it?

 

From: rules-dev-bounces at lists.jboss.org
[mailto:rules-dev-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: Friday, June 17, 2011 8:59 AM
To: Rules Dev List
Subject: Re: [rules-dev] Today's Eleusinian mystery: deserializing a
package forchange set monitoring

 

 

On 17 June 2011 16:34, Joe White <Joe.White at recondotech.com> wrote:

Not that it necessarily needs to be fixed but in 5.0.1 you could
serialize a package just using a regular ObjectOutputStream.


No - the code was not writing anything to a file.

 

	Also the guy


|| Lisa!

                Good point. My bad.


-W
 

	on the user mailing list was getting an exception using the
DroolsObjectOutputStream.

	 

	From: rules-dev-bounces at lists.jboss.org
[mailto:rules-dev-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
	Sent: Friday, June 17, 2011 2:54 AM
	To: Rules Dev List
	Subject: [rules-dev] Today's Eleusinian mystery: deserializing a
package forchange set monitoring

	 

	Serializing a compiled package seems a rational thing to do -
after all, there is: <resource source="..." type="PKG" /> and it is
recognized by the monitor.
	
	However, you can't simply serialize an
org.drools.definition.KnowledgePackage as it is usually done by writing
it to an ObjectOutputStream: deserialization in the KnowledgeAgent
throws a CCE exception.  To make it work, you must use a
DroolsObjectOutputStream, which is nothing but a rename of
ObjectOutputStream. So I have use DroolsObjectOutputStream, but it is
not part of the public API.
	
	-W

	
	_______________________________________________
	rules-dev mailing list
	rules-dev at lists.jboss.org
	https://lists.jboss.org/mailman/listinfo/rules-dev

 


_______________________________________________
rules-dev mailing list
rules-dev at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20110617/26a7a02a/attachment.html 


More information about the rules-dev mailing list