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   
Text File  |  1999-06-28  |  3KB  |  105 lines

  1. #!/usr/bin/env python
  2. #############################################################################
  3. # Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1997, 1998, 1999
  4. # All Rights Reserved.
  5. #
  6. # The software contained on this media is the property of the DSTC Pty
  7. # Ltd.  Use of this software is strictly in accordance with the
  8. # license agreement in the accompanying LICENSE.HTML file.  If your
  9. # distribution of this software does not contain a LICENSE.HTML file
  10. # then you have no rights to use this software in any manner and
  11. # should contact DSTC at the address below to determine an appropriate
  12. # licensing arrangement.
  13. #      DSTC Pty Ltd
  14. #      Level 7, GP South
  15. #      Staff House Road
  16. #      University of Queensland
  17. #      St Lucia, 4072
  18. #      Australia
  19. #      Tel: +61 7 3365 4310
  20. #      Fax: +61 7 3365 4311
  21. #      Email: enquiries@dstc.edu.au
  22. # This software is being provided "AS IS" without warranty of any
  23. # kind.  In no event shall DSTC Pty Ltd be liable for damage of any
  24. # kind arising out of or in connection with the use or performance of
  25. # this software.
  26. #
  27. # Project:      Fnorb
  28. # File:         $Source: /units/arch/src/Fnorb/examples/hello-world/RCS/server.py,v $
  29. # Version:      @(#)$RCSfile: server.py,v $ $Revision: 1.4 $
  30. #
  31. #############################################################################
  32. """ Implementation of the HelloWorldIF interface. """
  33.  
  34.  
  35. # Standard/built-in modules.
  36. import sys
  37.  
  38. # Fnorb modules.
  39. from Fnorb.orb import BOA, CORBA
  40.  
  41. # Stubs and skeletons generated by 'fnidl'.
  42. import HelloWorld, HelloWorld_skel
  43.  
  44.  
  45. class HelloWorldServer(HelloWorld_skel.HelloWorldIF_skel):
  46.     """ Implementation of the 'HelloWorldIF' interface. """
  47.  
  48.     def hello_world(self):
  49.     print HelloWorld.Message
  50.     return HelloWorld.Message
  51.  
  52. #############################################################################
  53.  
  54. def main(argv):
  55.     """ Do it! """
  56.  
  57.     print 'Initialising the ORB...'
  58.  
  59.     # Initialise the ORB.
  60.     orb = CORBA.ORB_init(argv, CORBA.ORB_ID)
  61.  
  62.     print 'Initialising the BOA...'
  63.  
  64.     # Initialise the BOA.
  65.     boa = BOA.BOA_init(argv, BOA.BOA_ID)
  66.  
  67.     print 'Creating object reference...'
  68.  
  69.     # Create an object reference ('fred' is the object key).
  70.     obj = boa.create('fred', HelloWorldServer._FNORB_ID)
  71.  
  72.     print 'Creating implementation...'
  73.  
  74.     # Create an instance of the implementation class.
  75.     impl = HelloWorldServer()
  76.  
  77.     print 'Activating the implementation...'
  78.  
  79.     # Activate the implementation (ie. connect the generated object reference
  80.     # to the implementation).  Note that the implementation will not receive
  81.     # any operation requests until we start the event loop (see below).
  82.     boa.obj_is_ready(obj, impl)
  83.  
  84.     # Write the stringified object reference to a file (this is just a 'cheap
  85.     # and cheerful' way of making the object reference available to the
  86.     # client!).
  87.     open('server.ref', 'w').write(orb.object_to_string(obj))
  88.  
  89.     print 'Server created and accepting requests...'
  90.  
  91.     # Start the event loop.
  92.     boa._fnorb_mainloop()
  93.  
  94.     return 0
  95.  
  96. #############################################################################
  97.  
  98. if __name__ == '__main__':
  99.     # Do it!
  100.     sys.exit(main(sys.argv))
  101.  
  102. #############################################################################
  103.