In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of java SPI how to define the interface, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to define the interface in java SPI. Let's take a look.
instructions
After the service provider provides the specific implementation of the interface, create a file named with the fully qualified name of the interface in the META-INF/services directory of the jar package, which is the fully qualified name of the implementation class.
1. The jar package of the interface implementation class is placed in the classpath of the main program. The main program dynamically loads the implementation module through java.util.ServiceLoder, finds the fully qualified name of the implementation class by scanning the configuration file in the META-INF/services directory, and loads the class into JVM.
2. The implementation class of SPI must carry a structure method without parameters.
Example
Public interface IShout {void shout ();} public class Cat implements IShout {@ Override public void shout () {System.out.println ("miao miao");}} public class Dog implements IShout {@ Override public void shout () {System.out.println ("wang wang");}} this is the end of the article on "how java SPI defines interfaces". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to define the interface of java SPI". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.