The Hub is the equivalent of the ORB - a central context for everything in the distributed object system.
The Hub has a registry which can be as simple as a dictionary or as sophisticated as a CORBA NamingContext. It must provide the getitem and setitem methods to dereference and assign keys to objects.
def __clearContext(self):
def __connectionClosed(self, protoId, protoInfo):
Called when a connection is closed.
Internal method to return all Protocol objects
as a list.
Private version of getObject(), in which
splitKey is a list.
Creates lists of objects for the select lists.
parms:
[list<ProtocolServer>] list of servers
This is executed in a thread to begin servicing client connections for a
particular server.
This function reenters the message processing loop and waits for a particular
response.
If any response other that response should be received, a BadResponse exception will be raised.
Registers the object as a remote object under the name key (a
string). Any kind of object can be registered.
Note that a key consisting of name parts seperated by forward slashes can be
used, but it does not produce the results that one might expect after reading
the documentation on getObject() - i.e. the object is
not stored in a nested context.
This function should generally be called by the protocol constructor to
register itself with the hub.
Adds a new reactor object to the hub's internal list. This will cause the
reactor to be included in the select loop.
parms:
[ Reactor]
Registers server (an instance of ProtocolServer). In threaded
communication mode, the hub will begin handling connections on the server in
another thread.
Returns the current context object. This is only available from within a
remote method call. If it is called from somewhere other than a remotely
invoked method, None is returned.
Returns the object (the object that was added using addObject(), not
necessarily a RemoteObject) associated with
fullKey.
fullKey can resemble a UNIX path - that is, it can consist of name
components seperated by forward slashes. If it is, and there is nothing
matching the key in the registry, a recursive retrieval is performed.
This is used to get or create a protocol from its id. Returns the protocol
if it already exists, creates it if it doesn't.
Returns a remote object for an object that has been added to the current hub
identified by key.
parms:
[string] object key
[ RemoteObjectFactory or None] if
present, this is the remote object factory used to create the remote object. If
not, DynamicRemoteObjectFactory
is used.
Returns the hub's thread mode. Thread modes are:
no threading
run "select()" loop in a background thread
Like THRD_SELECT but also create new threads for method invocations
Create a listening thread for each Protocol and ServerProtocol and each
method invocation.
Returns true if the hub is threaded, false if not. The hub is threaded in
all threads modes except THRD_NONE
Makes object into an anonymous remote object. Returns an instance of
a RemoteObject derivative for the object.
Anonymous remote objects are remote objects that are registered without any
particular key - presumably for temporary use. Actually, the key is the
object's id - the address of the object.
If remoteFactory is supplied, it should be an instance of a class
derived from RemoteObjectFactory. If it
is not supplied,
DynamicRemoteObjectFactory is used to create and return a DynamicRemoteObject.
Returns a remote object for the given object id. An object id consists of a
protocol id followed by a colon and the object key.
If remoteFactory is supplied, it should be an instance of a class
derived from RemoteObjectFactory. If it
is not supplied,
DynamicRemoteObjectFactory is used to create and return a DynamicRemoteObject.
Processes a request (an instance of Request) and
returns the response (a Response).
Deregisters the object listed under the given key.
parms:
[string] object key.
__execInputLine(self)
def __execInputLine(self):
__getAllProtocols(self)
def __getAllProtocols(self):
__getObject(self, node, splitKey)
def __getObject(self, node, splitKey):
__getSelectors(self, servers, rd, wr, er)
def __getSelectors(self, servers, rd, wr, er):
__init__(self, registry, threadMode)
def __init__(self, registry,
threadMode = _haveThreads and THRD_FUNC or THRD_NONE
):
__needSelectThread(self)
def __needSelectThread(self):
__processRequest(self, request, protocol)
def __processRequest(self, request, protocol):
__selectLoop(self, msgId)
def __selectLoop(self, msgId = None):
__serviceClient(self, clientConnection)
def __serviceClient(self, clientConnection):
__serviceConnections(self, server)
def __serviceConnections(self, server):
__serviceFunction(self, clientConnection, request)
def __serviceFunction(self, clientConnection, request):
__setContext(self, context)
def __setContext(self, context):
_getResponse(self, responseId)
def _getResponse(self, responseId):
addObject(self, key, object)
def addObject(self, key, object):
addProtocol(self, proto)
def addProtocol(self, proto):
addReactor(self, reactor)
def addReactor(self, reactor):
addServer(self, server)
def addServer(self, server):
getContext(self)
def getContext(self):
getObject(self, fullKey)
def getObject(self, fullKey):
getProtocol(self, protoId)
def getProtocol(self, protoId):
getRemoteObject(self, key, remoteFactory)
def getRemoteObject(self, key, remoteFactory = None):
getThreadMode(self)
def getThreadMode(self):
isThreaded(self)
def isThreaded(self):
mainloop(self)
def mainloop(self):
makeAnonObject(self, object, remoteFactory)
def makeAnonObject(self, object, remoteFactory = None):
makeRemoteObject(self, objectId, remoteFactory)
def makeRemoteObject(self, objectId, remoteFactory = None):
processRequest(self, request)
def processRequest(self, request):
removeObject(self, key)
def removeObject(self, key):