Now we will define some utilities for communicating an object reference from the server to the client by converting the object reference into a string using ORB-supplied functions and writing it to a shared file. The client can then read the string from the shared file and convert it back into an object reference. Note that a real application would probably use a higher level service such as a Name Service for passing object references between applications.
(in-package "CL-USER")
(defparameter *hello-world-ior-file*
#+mswindows "c:/temp/hello.ior"
#-mswindows "/tmp/hello.ior")
(defun object-to-file (orb object)
(with-open-file (st *hello-world-ior-file* :direction :output
:if-exists :supersede)
(prin1 (op:object_to_string orb object) st)))
(defun file-to-object (orb)
(with-open-file (st *hello-world-ior-file*)
(op:string_to_object orb (read st))))
object-to-file
opens the shared file and uses the
op:object_to_string
function to convert the object reference into a string, which is then written into the file
file-to-object
performs the inverse operation: it reads the string from the file and uses
op:string_to_object
to convert the string back into a client-side proxy object
shared.lisp
file.
shared.lisp
to the defsystem by adding one line of code to the
defsys.lisp
file, which should then look like this:
(in-package "CL-USER")
(require "corba-orb")
(defsystem hello-world-corba-object ()
:members (
("hello-world" :type :idl-file)
"shared"
))
:rules ((:in-order-to :compile :all
(:requires (:load :previous)))))