Suppose you have a hierarchy of classes that implement MyServiceIF .
Suppose you have an appropriate factory class hierarchy to create each instance in the original hierarchy.
In this case, MyServiceFactorySupplier may have a registry of available plants, and you may have a call to getMyServiceFactory(parameter) , where the parameter determines which factory will be created (and therefore an instance of this class will be created by the factory).
I do not know if this use case was in your project, but it is a real use case.
Here is a sample code that I have in mind:
public class MyServiceImpl implements MyServiceIF { .... } public class MyServiceImpl2 implements MyServiceIF { .... } public class MyServiceFactoryImpl implements MyServiceFactoryIF { .... public MyServiceIF getMyService () { return new MyServiceImpl (); } .... } public class MyServiceFactoryImpl2 implements MyServiceFactoryIF { .... public MyServiceIF getMyService () { return new MyServiceImpl2 (); } .... } public class MyServiceFactorySupplier { .... public static MyServiceFactoryIF getMyServiceFactory() { return new MyServiceFactoryImpl ();
I have an associated hierarchy of classes that are created by a hierarchy of factories. Although I do not have a FactorySupplier class, the base class of the factory hierarchy has a static method BaseFactory.getInstance(parameter) that returns a factory instance that depends on the parameter passed.
source share