i think Factory is not to the point,just concerned with its concept,factory <br>should only take care of producing proper protocol instance.i can't see any clue <br>of protocol context in the defintion of factory.so the boudary of factory is loom,i don't
<br>like it.or on other hand,we can it can be categoried into abstract factroy,then i proprose<br>following refraction.<br><br>class ProtoAbsFactory:<br> implements(interfaces.IProtocolFactory)<br> <br> protocol=None
<br> context=None<br> <br> numProtos=0<br> <br> def buildProtocol(self):<br> pass<br> def buildContext(self):<br> pass<br> <br>class ProtoContext:<br> def doStart(self):<br> pass
<br> def doStop(self):<br> pass<br> <br>class ClientProtoContext(ProtoContext):<br> def startedCnnecting(self):<br> pass<br> def clientConnectionFailed(self):<br> pass<br> def clientConnectionLost(self):
<br> pass<br><br>class ReconnectingClientProtoContext(ClientProtoContext):<br> def clientConnectoionFailed(self,connector,reason):<br> self.connector=connector<br> self.retry()<br> def clientConnectionLost(self,connector,reason):
<br> self.connector=connector<br> self.retry()<br> def retry(self):<br> self.connector.connect()<br><br> by introducing context,we make solution for some situation <br>very simple,just like http,since it is a stateless ,we have to bring
<br>in session to store state information during the communication,here by<br>refining the context ,we can easily achieve it