The Provisioning Server
The Provisioning Server is implemented as a single class using the Singleton pattern. The main element is a list collection into which GUI orders are placed. In a production system, the server might be implemented as an RMI (or CORBA) endpoint. The implementation here is much simpler but allows for extension. The key element is the use of the Singleton pattern. The server class provides a private constructor and maintains a private static instance of itself. The server offers four public methods to clients:
The getInstance() method returns a reference to the Provisioning Server Singleton class. The client can use this to call the other public methods, as described next.
The executeCommand() method dispatches an order (formed via the GUI) to the server. This order takes the form of a textual message that includes the operation count, the user ID, and the order details. Orders are appended to an operations list object. The server could store these details in the database (via JDBC) and apply the required updates to the network routers (via SNMP or some other device access technology).
The undoCommand() reverses the most recent order submitted by the associated GUI client. An important part of this is that the orders from the user types are not mixed up. If the enterprise network manager decides to reverse an order, then it's essential that this have no effect on the home office user.
The toString() method returns a string representation of the operations list for a specific user. In this program, we have two possible users: "Home Office User" and "Enterprise User," respectively.