home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
fnd101.zip
/
Add-Ons
/
Fnorb
/
examples
/
hello-world
/
server.py
< prev
Wrap
Text File
|
1999-06-28
|
3KB
|
105 lines
#!/usr/bin/env python
#############################################################################
# Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1997, 1998, 1999
# All Rights Reserved.
#
# The software contained on this media is the property of the DSTC Pty
# Ltd. Use of this software is strictly in accordance with the
# license agreement in the accompanying LICENSE.HTML file. If your
# distribution of this software does not contain a LICENSE.HTML file
# then you have no rights to use this software in any manner and
# should contact DSTC at the address below to determine an appropriate
# licensing arrangement.
#
# DSTC Pty Ltd
# Level 7, GP South
# Staff House Road
# University of Queensland
# St Lucia, 4072
# Australia
# Tel: +61 7 3365 4310
# Fax: +61 7 3365 4311
# Email: enquiries@dstc.edu.au
#
# This software is being provided "AS IS" without warranty of any
# kind. In no event shall DSTC Pty Ltd be liable for damage of any
# kind arising out of or in connection with the use or performance of
# this software.
#
# Project: Fnorb
# File: $Source: /units/arch/src/Fnorb/examples/hello-world/RCS/server.py,v $
# Version: @(#)$RCSfile: server.py,v $ $Revision: 1.4 $
#
#############################################################################
""" Implementation of the HelloWorldIF interface. """
# Standard/built-in modules.
import sys
# Fnorb modules.
from Fnorb.orb import BOA, CORBA
# Stubs and skeletons generated by 'fnidl'.
import HelloWorld, HelloWorld_skel
class HelloWorldServer(HelloWorld_skel.HelloWorldIF_skel):
""" Implementation of the 'HelloWorldIF' interface. """
def hello_world(self):
print HelloWorld.Message
return HelloWorld.Message
#############################################################################
def main(argv):
""" Do it! """
print 'Initialising the ORB...'
# Initialise the ORB.
orb = CORBA.ORB_init(argv, CORBA.ORB_ID)
print 'Initialising the BOA...'
# Initialise the BOA.
boa = BOA.BOA_init(argv, BOA.BOA_ID)
print 'Creating object reference...'
# Create an object reference ('fred' is the object key).
obj = boa.create('fred', HelloWorldServer._FNORB_ID)
print 'Creating implementation...'
# Create an instance of the implementation class.
impl = HelloWorldServer()
print 'Activating the implementation...'
# Activate the implementation (ie. connect the generated object reference
# to the implementation). Note that the implementation will not receive
# any operation requests until we start the event loop (see below).
boa.obj_is_ready(obj, impl)
# Write the stringified object reference to a file (this is just a 'cheap
# and cheerful' way of making the object reference available to the
# client!).
open('server.ref', 'w').write(orb.object_to_string(obj))
print 'Server created and accepting requests...'
# Start the event loop.
boa._fnorb_mainloop()
return 0
#############################################################################
if __name__ == '__main__':
# Do it!
sys.exit(main(sys.argv))
#############################################################################