In this article, we describe the default strategy that the FactoryFinder uses to find, load and instantiate Objects.

FactoryFinder is responsible for loading the factory class and instantiate it.
The implementation class name is stored in a property file against key “class”.
For example:

The path of the property file is known to the class creating an instance of FactoryFinder.
The full path is determined based on the scheme of the factory which is passed to the factory method as key.


The path where this property file is located should be known prior and fed to FactoryFinder static instance.
Each category will have a different factory finder and path.
For example, in case of a broker factory, the property file is found at “META-INF/services/org/apache/activemq/broker/”.
In case of a transport factory, the property file is found at “META-INF/services/org/apache/activemq/transport”.


Based on the scheme we determine its full path. For example, for scheme=tcp, the property file would be “META-INF/services/org/apache/activemq/transport/tcp”

The thread’s context class loader would be used to load the property file. In case it is null, FactoryFinder’s class loader would be used.
Once the class is loaded, it is cached so that we don’t have to redo the loading process.
The factory instance created will also be cached so that we don’t have to re-create the factory instance.


Leave A Reply