Java / Design Patterns
Explain Service Provider framework pattern.
A service provider framework is a system in which multiple service providers implement a service, and the system makes the implementations available to its clients, decoupling them from the implementations.
There are 3 essential components of a service provider framework: a service interface, which providers implement; a provider registration API, which the system uses to register implementations, giving clients access to them; and a service access API, which clients use to obtain an instance of the service. The service access API typically allows but does not require the client to specify some criteria for choosing a provider. In the absence of such a specification, the API returns an instance of a default implementation. The service access API is the "flexible static factory" that forms the basis of the service provider framework.
An classic example of SPI is JDBC, where Connection acts as the service interface, DriverManager.registerDriver as provider registration API, DriverManager.getConnection as service access API, and Driver is the service provider interface.
More Related questions...