home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fnb101.zip / Lib / site-packages / Fnorb / orb / GIOPServerWorker.py < prev    next >
Text File  |  1999-06-28  |  4KB  |  123 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/orb/RCS/GIOPServerWorker.py,v $
  29. # Version:      @(#)$RCSfile: GIOPServerWorker.py,v $ $Revision: 1.4 $
  30. #
  31. #############################################################################
  32. """ GIOPServerWorker classes. """
  33.  
  34.  
  35. # Fnorb modules.
  36. import CORBA, Util
  37.  
  38.  
  39. #############################################################################
  40. # GIOPServerWorker factory.
  41. #############################################################################
  42.  
  43. def GIOPServerWorkerFactory_init():
  44.     """ Return the GIOPServerWorker factory. 
  45.  
  46.     This is a factory function for the GIOPServerWorkerFactory class
  47.     (the GIOPServerWorker factory is a singleton (ie. there can only be one
  48.     instance per process)).
  49.  
  50.     """
  51.     try:
  52.     factory = GIOPServerWorkerFactory()
  53.  
  54.     except GIOPServerWorkerFactory, factory:
  55.     pass
  56.  
  57.     return factory
  58.  
  59.  
  60. class GIOPServerWorkerFactory:
  61.     """ Factory for GIOPServerWorker instances. 
  62.  
  63.     The factory is a singleton (ie. there can only be one instance per
  64.     process).
  65.  
  66.     """
  67.     __instance = None
  68.  
  69.     def __init__(self):
  70.     """ Constructor. """
  71.  
  72.     # The factory is a singleton (ie. there can only be one instance per
  73.     # process).
  74.     if GIOPServerWorkerFactory.__instance is not None:
  75.         raise GIOPServerWorkerFactory.__instance
  76.  
  77.     GIOPServerWorkerFactory.__instance = self
  78.  
  79.     return
  80.  
  81.     #########################################################################
  82.     # GIOPServerWorkerFactory interface.
  83.     #########################################################################
  84.  
  85.     def create_worker(self, protocol, connection):
  86.     """ Create a new GIOP Server worker. """
  87.  
  88.     # Find out what threading-model we are using.
  89.     model = CORBA.ORB_init()._fnorb_threading_model()
  90.  
  91.     # Reactive.
  92.     if model == Util.REACTIVE:
  93.         from GIOPServerWorkerReactive import GIOPServerWorkerReactive
  94.         worker = GIOPServerWorkerReactive(protocol,    connection)
  95.  
  96.     # Multi-threaded.
  97.         else:
  98.         from GIOPServerWorkerThreaded import GIOPServerWorkerThreaded
  99.         worker = GIOPServerWorkerThreaded(protocol, connection)
  100.  
  101.     return worker
  102.  
  103.  
  104. class GIOPServerWorker:
  105.     """  Abstract base class for GIOPServer workers. """
  106.  
  107.     def send(self, message):
  108.     """ Send a message. """
  109.  
  110.     pass
  111.  
  112.     def close_connection(self):
  113.     """ Close down the server.
  114.  
  115.     Currently, Fnorb does not close down servers, so this is not used.
  116.  
  117.     """
  118.     pass
  119.  
  120. #############################################################################
  121.