talking about factories as convenient
generalizations of the idea of a naming service: a
factory is just a naming service that can launch
servers. Another way to think about the idea of a
factory server is that it’s really a
generalization of the idea of a class object. That
is, the factories we’ve been implementing are
objects with a set of constructors and maintain
information about all the instances of
Account, much the same
way that a class object can have static
information that is not specific to any particular
instance of the class.
We’ve already come close to this idea with
LockingFactory_Impl. It also allows a
client to lock a set of servers in a single method
call. The next step is to note that
also, should we so desire, control other aspects
of the server’s lifecycle.
Suppose, for example, we were to change the
serverNoLongerActive( ) to the
public void serverNoLongerActive(String accountName, Remote server) throws RemoteException;
The factory now gets both the name of the server and a stub to the server when the server is otherwise unreferenced. At which point, the factory can do things such as:
Implement a simple external persistence layer.
That is, the factory can query the server for state information, which the factory then stores in a relational database before the server is garbage collected.
Tell the server to persist itself.
This is a more object-oriented version ...