Before commenting on the Factory pattern, I see some problem with your code. I guess this BrokerToolFactory resides on the client side because I see you are doing a Naming.lookup() in the code. With that assumption,
you should not create the instance of a class which extends UnicastRemoteObject unless you are creating a remote object on the client side which I think is unnecessary.
When you need to get an instance of any remote object, you have two options:
1) Use the RMI Registry to lookup for the instance which implements the java.rmi.Remote interface. What you get on the client side is the _Stub instance and never the remote object instance.
2) You can return the remote object when the client invokes a method on another remote object.
Here is my comment about the Factory pattern. Factory pattern is normally used for creating instances without hardcoding the class name in any part of the code other than the Factory class.
The factory class usually takes a name or have specific methods to distinguish the *kind* of objects need to be created.
Usually
polymorphism is used when there is only one method in the Factory and you ask for an instance by specifying the name. For example, you can ask for an Apple instance by calling the method below in the FruitFactory:
The above method can return an Apple or Orange depending on the name which is usually defined as constants in the Factory class itself.
With that simple explanation of Factory, I wouldn't characterise BrokerToolFactory in your code as a Factory
[ May 03, 2002: Message edited by: Sai Prasad ]