From: R. Giuly
Subject: Serializing objects in java?
Date: 
Message-ID: <3AB5D3C3.AEB9F758@hotmail.com>
I'm using CAPI in lispworks and I want to serialize a graphic object so
I can save it in a file. Can I serialize a "capi:pinboard-layout" or any
object for that matter?

thanks 

-- 
Richard Giuly

(remove animal from email address)

From: Craig Brozefsky
Subject: Re: Serializing objects in java?
Date: 
Message-ID: <87g0g990th.fsf@piracy.red-bean.com>
"R. Giuly" <·········@hotmail.com> writes:

> I'm using CAPI in lispworks and I want to serialize a graphic object so
> I can save it in a file. Can I serialize a "capi:pinboard-layout" or any
> object for that matter?

See the java-io directory in the IMHO web app toolkit at
http://alpha.onshored.com/lisp-software

We developed this so that we could have a java applet communicate with
our application server via  lightweight HTTP-based RPC mechanism.  It
submits normal HTTP requests to a the backend which are mapped to a
"transponder" object.  This transponder then gives it back the objects
it wants, as Java serialized objects.

It's all Free Software.  Regretably the Transponder example is still
in part of the code base that has not been fully liberated, but we can
work on moving it into IMHO soon.  You should have all you need in the
IMHO package.

IMHO has been at least partially ported to Lispworks, so it's possible
that little to nkow wor would be needed to get all the java
serialization stuff working under LW.


-- 
Craig Brozefsky                             <·····@red-bean.com>
In the rich man's house there is nowhere to spit but in his face
					             -- Diogenes
From: Kent M Pitman
Subject: Re: Serializing objects in java?
Date: 
Message-ID: <sfwu24qhwp0.fsf@world.std.com>
"R. Giuly" <·········@hotmail.com> writes:

> I'm using CAPI in lispworks and I want to serialize a graphic object so
> I can save it in a file. Can I serialize a "capi:pinboard-layout" or any
> object for that matter?

Your subject line says "in java".  Do you mean, as it would suggest,
"can I serialize a capi object so that I can pull it back out in Java?"
Or do you instead mean, "as in Java, can I seralize so I can pull it back
out in Lisp?"  And, further, do you want to get it back out in the same
vendor's Lisp or are you asking about moving it cross-platform?

There's no way that I know of to move an object to Java.

There's no way, other than PRINT (for those kinds of objects that have
re-readable print-object methods), of moving an object cross-vendor.
The variable *PRINT-READABLY* sometimes encourages PRINT to try harder to
do the right thing, but for lots of objects that's not enough.
CAPI is a vendor-specific tool, and I doubt it has a print method that
is re-readable, but in any case there wouldn't be anything in another 
vendor's implementation to receive it.

Ordinarily, the way you'd do this would be to remember the source spec of
things you plan to reconstruct.  Or else figure out what its salient aspects
are and write your own methods for doing this.  e.g., see MAKE-LOAD-FORM
in the CL HyperSpec.  But basically, instead of doign

 (setq x (capi:some-graphic-object-constructor ...parameters...))

you would do

 (defclass thing-to-reconstruct () (... relevant features as slots ...))

 (defmethod make-capi-object ((thing thing-to-reconstruct))
   ;; call this method from you capi code
   (with-slots (... relevant features as slots...) thing
     (capi:some-graphic-object-constructor ...)))

 (defmethod make-load-form ((thing thing-to-reconstruct))
   ... code to construct your thing when you load it again ...))

The Lisp Machines used to have a cool operation that had a name like
dump-forms-to-file which took a list of objects and put out a binary
file that would reconstruct the objects--vaguely similar to
serialization.  You can simulate such a thing in Common Lisp by a
technique like the following.  No, I didn't test this; it's up to you
to go that last mile.  It's a darned shame this kind of interface is
not standard in CL because it is the kind of thing that's hard to just
"think up"--it requires just a little more cleverness than I thin
people should ordinarily have to do.  But it's now a standard
technique most programmers are aware of.

 (defvar *objects-in-file* nil)

 (defvar *awaiting-objects* (list '*awaiting-objects*)) ;unique object

 (defun save-forms-to-file (object-list file)
   (let ((source-file (make-temp-source-file file))
	 (compiled-file file))
     (with-open-file (stream source-file)
       (print `(progn
	         (unless (eq *objects-in-file* *awaiting-objects*)
                   (error "Use ~S to reload." 'load-forms-from-file))
                 (setq *objects-in-file* ',object-list))
               stream))
     (compile-file source-file :output-file compiled-file)))

 (defun load-forms-from-file (file)
   (let ((*objects-in-file* *awaiting-objects*))
     (load file)
     (when (eq *objects-in-file* *awaiting-objects*)
       (error "The file ~A did not contain any forms." file))
     *objects-in-file*))
      
This will cause the objects to get compiled as quoted constants if they
can be externalized to a file.  (See the CL HyperSpec, compilation chapter,
on the concepts of compiling and particularly file compilation.  Lots of
details there you need to know.)
From: Friedrich Dominicus
Subject: Re: Serializing objects in java?
Date: 
Message-ID: <87k85llxjw.fsf@frown.here>
Kent M Pitman <······@world.std.com> writes:

> 
>  (defvar *objects-in-file* nil)
> 
>  (defvar *awaiting-objects* (list '*awaiting-objects*)) ;unique object
> 
>  (defun save-forms-to-file (object-list file)
>    (let ((source-file (make-temp-source-file file))
> 	 (compiled-file file))
>      (with-open-file (stream source-file)
>        (print `(progn
> 	         (unless (eq *objects-in-file* *awaiting-objects*)
>                    (error "Use ~S to reload." 'load-forms-from-file))
>                  (setq *objects-in-file* ',object-list))
>                stream))
>      (compile-file source-file :output-file compiled-file)))
> 
>  (defun load-forms-from-file (file)
>    (let ((*objects-in-file* *awaiting-objects*))
>      (load file)
>      (when (eq *objects-in-file* *awaiting-objects*)
>        (error "The file ~A did not contain any forms." file))
>      *objects-in-file*))
>       
> This will cause the objects to get compiled as quoted constants if they
> can be externalized to a file.  (See the CL HyperSpec, compilation chapter,
> on the concepts of compiling and particularly file compilation.  Lots of
> details there you need to know.)

Could it bee that PLOB does the job?
http://www.lisp.de/software/plob/list.html

Regards
Friedrich
From: Heiko Kirschke
Subject: Re: Serializing objects in java?
Date: 
Message-ID: <ud7bb9zoo.fsf@ovivo.de>
Friedrich Dominicus <·····@q-software-solutions.com> writes:

> [Serializing a LISP object]
> Could it bee that PLOB does the job?
> http://www.lisp.de/software/plob/list.html

Not really. Although Plob serializes objects for transmitting them
between the client and the server, it is more a quick-and-dirty
serialization using pretty old RPC standards like xdr. Also, Plob
doesn't send the objects' state `in one piece' over the socket, but
does this more on a slot-by-slot basis. Serialization was seen only as
a mean of communication between Plob's server and client; it was not
intended to use serialization as a mean of communication with other
systems.

Although, Plob can be abused for exchanging objects between LISP
processes. Each LISP process can connect to a Plob server and can bind
objects e.g. to a persistent symbol, which can then be retrieved by
another LISP process. Please note that this solution ignores all usual
aspects of good interprocess communication (therefore I called this
`abuse').

-- 
Viele Gruesse,
Heiko Kirschke
From: Paolo Amoroso
Subject: Re: Serializing objects in java?
Date: 
Message-ID: <hzi2OondOdqHIFMveNmx8eeS3pPS@4ax.com>
On Mon, 19 Mar 2001 10:36:43 GMT, Kent M Pitman <······@world.std.com>
wrote:

> There's no way that I know of to move an object to Java.

LIJOS is a Lisp implementation of the Java serialization protocol:

  http://www.pointandclicksolutions.com/lijos/index.html

Similar functionality is provided by the DATE system (see the
documentation):

  DATE - Design Artifact Tracking and Evolution
  http://www.ai.mit.edu/people/cvince/date/


Paolo
-- 
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/
From: Frode Vatvedt Fjeld
Subject: Re: Serializing objects in java?
Date: 
Message-ID: <2hbsqvfl1a.fsf@dslab7.cs.uit.no>
"R. Giuly" <·········@hotmail.com> writes:

> I'm using CAPI in lispworks and I want to serialize a graphic object
> so I can save it in a file. Can I serialize a "capi:pinboard-layout"
> or any object for that matter?

There's a slight chance that my binary-types package does what you
want. This package enables you to declare the binary
layout/serialization of i.e. defstructs or defclasses for reading and
writing to non-textual files (or any other kind of stream I guess).

<URL:http://www.cs.uit.no/~frodef/sw/binary-types/>

-- 
Frode Vatvedt Fjeld