Service Provider Interface

An Extensible application is one in which you can extend without modifying its original code base.  Using SPI all you have to do is to add a jar (with META-INF/services/<interface> file in applicaitons class path or extended library location) and the services will be found and made available to the application.

Service: A set of programming interfaces and classes that

  • Define a functionality (Service Interface).
  • And a way to retrieve an implementation (Service Access API).
  • And a way to regiser a provider (Registration API).

Service Provider Interface: A Set of public interfaces and abstract classes that providers implement to create an instance of their Service Implementation.

Service Provider: Implements SPI.


1. A word processor application that allows end users to write their own dictionary and spell checkers.

  • DictionaryServiceDemo: Applicaiton Name
  • Client
  • Service Interface; Service Access Interface; Provier Registration through SPI standard
  • SPI
  • Service Provider 1
  • GeneralDictionary: Service Provider 2

2. In JDBC Connection plays part of Service Inreface (or the feature that clients use); Driver.getConnection is Servce Access API; DriverManager.registerDriver is the provider registration API; Driver is the SPI that service providers implement.

Java Trail:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s