Package omero :: Package util :: Class ServerContext
[hide private]
[frames] | no frames]

Class ServerContext

source code


Context passed to all servants.

server_id, communicator, and stop_event will be constructed by the top-level Server instance.

A context instance may also be configured to hold on to an internal session (ServiceFactoryPrx) and keep it alive.

This instance obeys the Resources API and calls sf.keepAlive(None) on every check call, but does nothing on cleanup. The sf instance must be manually cleaned as the final operation of a servant.

(Note: cleanup of the server context indicates server shutdown, so should be infrequent)

Instance Methods [hide private]
 
__init__(self, server_id, communicator, stop_event, on_newsession=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
add_servant(self, adapter_or_current, servant, ice_identity=None) source code
 
newSession(self) source code
 
hasSession(self) source code
 
getSession(self, recreate=True)
Returns the ServiceFactoryPrx configured for the context if available.
source code
 
check(self)
Calls getSession() but always returns True.
source code
 
cleanup(self)
Does nothing.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, server_id, communicator, stop_event, on_newsession=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

add_servant(self, adapter_or_current, servant, ice_identity=None)

source code 
Decorators:
  • @locked

getSession(self, recreate=True)

source code 

Returns the ServiceFactoryPrx configured for the context if available. If the context was not configured for sessions, an ApiUsageException will be thrown: servants should know whether or not they were configured for sessions. See Servant(..., needs_session = True)

Otherwise, if there is no ServiceFactoryPrx, an attempt will be made to create one if recreate == True. If the value is None or non can be recreated, an InternalException will be thrown.

TODO : currently no arguments are provided for re-creating these, but also not in Servant.__init__

Decorators:
  • @locked

check(self)

source code 

Calls getSession() but always returns True. This keeps the context available in the resources for later uses, and tries to re-establish a connection in case Blitz goes down.

cleanup(self)

source code 

Does nothing. Context clean up must happen manually since later activities may want to reuse it. Servants using a server connection should cleanup the instance *after* Resources is cleaned up