javadesign-patternslenskit

Service provider design pattern


I am looking for some explanation or reference info on the service provider design pattern as i came across this while studying the Grapht @defaultImplementation code (http://grepcode.com/file/repo1.maven.org/maven2/org.grouplens.grapht/grapht/0.5.0/org/grouplens/grapht/annotation/DefaultImplementation.java)

This annotation is used with annotations in the LensKit implementation as in 28:57 of this video: https://www.youtube.com/watch?v=ug_JfORWK7w

I am looking for explanation or references to learn & understand the utility of this design pattern.

Please advise

Thanks


Solution

  • Service Provider Interface: Creating Extensible Java Applications

    An application is an aggregation of cohesive services. While an application offers a broader set of functionality in terms of application programming interfaces (APIs) and classes, a service provides access to some specific application functionality or feature. The service defines the interfaces for the functionality and a way to retrieve an implementation. For example, consider an application that provides a variety of information about a geographical location, such as real estate data, weather information, demographics, etc. The weather service, a part of the application, may define only the interface for retrieving the weather information (more on this example shortly).

    A service provider interface (SPI) is the set of public interfaces and abstract classes that a service defines. A SPI may be represented by a single interface (type) or abstract class or a set of interfaces or abstract classes that define the service contract.

    Source Service Provider Interface: Creating Extensible Java Applications