Automatic factory registration
问题 i'm just learning java, and i meet some problems. Here we have simple factory pattern: public class SomeFactory { ... public static void registerProduct(String name, Class<? extends IProduct > f) } public SomeProduct implements IProduct { static { SomeFactory.register("some product", SomeProduct.class); } ... } All products should register themselves at factory. But before using this code, all Products classes should be loaded. I can put Class.forName() somewhere, for example in main function