"Effective Java" service provider framework

Source: Internet
Author: User

The static factory method returns the class to which the object belongs, and can not be present when writing a class that contains the static factory method. This flexible, static factory approach forms the basis of the service provider Framework (Provider framework), such as the JDBC API. The service provider framework refers to a system in which multiple service providers implement a service (interface) that provides multiple implementations of the service provider's clients and decouples them from multiple implementations.

There are four important components in the service provider framework:

  • Service Interface, which is implemented by the provider. such as the connection of JDBC
  • Provider Registration API (Provider Registration API), which is used by the system to register provider implementations that allow clients to access them. such as Drivermanager.registerdriver
  • The Services Access API (service Access API) is the instance that the client uses to obtain the service. such as Drivermanager.get
  • Service Provider Interface (Provider Interface) These providers are responsible for creating instances of their service implementations. This is optional. such as driver

If there is no service provider interface, the implementation is registered according to the class name and instantiated by reflection. The interface is superior to the reflection mechanism and is strongly recommended for use with the service provider interface.

"Effective Java" service provider framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.