Package jakarta.json.bind.spi
Class JsonbProvider
- java.lang.Object
-
- jakarta.json.bind.spi.JsonbProvider
-
public abstract class JsonbProvider extends Object
Service provider for JSON Binding implementations. Provider implementors must implement all abstract methods. API clients can obtain instance of default provider by calling:
Specific provider instance lookup:JsonbProvider provider = JsonbProvider.provider();}
where 'JsonbProvider provider; try { JsonbProvider.provider("foo.bar.ProviderImpl"); } catch (JsonbException e) { // provider not found or could not be instantiated }foo.bar.ProviderImpl' is a vendor implementation class extendingJsonbProviderand identified to service loader as specified inServiceLoaderdocumentation.
All the methods in this class are allowed to be called by multiple concurrent threads.- Since:
- JSON Binding 1.0
- See Also:
Jsonb,ServiceLoader
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJsonbProvider()Protected constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract JsonbBuildercreate()Returns a new instance ofJsonbBuilderclass.static JsonbProviderprovider()Creates a JSON Binding provider object by using theServiceLoader.load(Class)method.static JsonbProviderprovider(String providerName)Creates a JSON Binding provider object by using theServiceLoader.load(Class)method, matchingproviderName.
-
-
-
Method Detail
-
provider
public static JsonbProvider provider()
Creates a JSON Binding provider object by using theServiceLoader.load(Class)method. The first provider ofJsonbProviderclass from list of providers returned byServiceLoader.loadcall is returned. If there are no available service providers, this method tries to load the default service provider usingClass.forName(String)method.- Returns:
JsonbProviderinstance- Throws:
JsonbException- if there is no provider found, or there is a problem instantiating the provider instance.- See Also:
ServiceLoader
-
provider
public static JsonbProvider provider(String providerName)
Creates a JSON Binding provider object by using theServiceLoader.load(Class)method, matchingproviderName. The first provider ofJsonbProviderclass from list of providers returned byServiceLoader.loadcall, matching providerName is returned. If no such provider is found, JsonbException is thrown.- Parameters:
providerName- Class name (class.getName()) to be chosen from the list of providers returned byServiceLoader.load(JsonbProvider.class)call.- Returns:
JsonbProviderinstance- Throws:
JsonbException- if there is no provider found, or there is a problem instantiating the provider instance.NullPointerException- if providerName isnull.- See Also:
ServiceLoader
-
create
public abstract JsonbBuilder create()
Returns a new instance ofJsonbBuilderclass.JsonbBuilderprovides necessary getter methods to access required parameters.- Returns:
- JsonbBuilder
A new instance of class implementing
JsonbBuilder. Always a non-null valid object. - Throws:
JsonbException- If an error was encountered while creating theJsonbBuilderinstance.- See Also:
Jsonb,JsonbBuilder
-
-