The complete source code for the Hello World application is included here for your convenience. It can also be found in the corba/hello-world
subdirectory of the standard examples directory.
The complete code for the Hello World interface (the hello-world.idl
file), written in IDL, is:
module HelloWorld {
interface world {
string hello();
};
};
The complete code for the Hello World defsystem (the defsys.lisp
file) is:
(in-package "CL-USER")
(require "corba-orb")
(defsystem hello-world-corba-object ()
:members (
("hello-world" :type :idl-file)
"shared"
"hello-world-server"
"hello-world-client"
)
:rules ((:in-order-to :compile :all
(:requires (:load :previous)))))
The complete code for the Interoperable Object Reference (IOR) file transfer (the shared.lisp
file) is:
(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))))
The complete code for the Hello World client (the hello-world-client.lisp
file) is:
(in-package "CL-USER")
(defun run-client ()
(let ((orb (op:orb_init nil "LispWorks ORB")))
(let ((world (op:narrow 'HelloWorld:world (file-to-object
orb))))
(format t "~S~%" (op:hello world)))))
The complete code for the Hello World server (the hello-world-server.lisp
file) is:
(in-package "CL-USER")
(defclass world-implementation (HelloWorld:world-servant) ())
(corba:define-method op:hello ((self world-implementation))
(declare (ignore self))
"Hello World!")
(defun server-startup ()
(let* ((orb (op:orb_init nil "LispWorks ORB"))
(poa (op:resolve_initial_references orb "RootPOA"))
(impl (make-instance 'world-implementation))
(world (op:narrow 'HelloWorld:world
(op:servant_to_reference poa impl))))
(object-to-file orb world)
(let ((manager (op:the_poamanager poa)))
(op:activate manager))))
Developing Component Software with CORBA - 7 Aug 2017