Package javax.json.bind.spi
Class JsonbProvider
java.lang.Object
javax.json.bind.spi.JsonbProvider
Service provider for JSON Binding implementations.
Provider implementors must implement all abstract methods.
API clients can obtain instance of default provider by calling:
All the methods in this class are allowed to be called by multiple concurrent threads.
JsonbProvider provider = JsonbProvider.provider();
}
Specific provider instance lookup:
JsonbProvider provider;
try {
JsonbProvider.provider("foo.bar.ProviderImpl");
} catch (JsonbException e) {
// provider not found or could not be instantiated
}
where 'foo.bar.ProviderImpl
' is a vendor implementation class extending
JsonbProvider
and identified to service loader as
specified in ServiceLoader
documentation.
All the methods in this class are allowed to be called by multiple concurrent threads.
- Since:
- JSON Binding 1.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract JsonbBuilder
create()
Returns a new instance ofJsonbBuilder
class.static JsonbProvider
provider()
Creates a JSON Binding provider object by using theServiceLoader.load(Class)
method.static JsonbProvider
Creates a JSON Binding provider object by using theServiceLoader.load(Class)
method, matchingproviderName
.
-
Constructor Details
-
JsonbProvider
protected JsonbProvider()Protected constructor.
-
-
Method Details
-
provider
Creates a JSON Binding provider object by using theServiceLoader.load(Class)
method. The first provider ofJsonbProvider
class from list of providers returned byServiceLoader.load
call is returned. If there are no available service providers, this method tries to load the default service provider usingClass.forName(String)
method.- Returns:
JsonbProvider
instance- Throws:
JsonbException
- if there is no provider found, or there is a problem instantiating the provider instance.- See Also:
-
provider
Creates a JSON Binding provider object by using theServiceLoader.load(Class)
method, matchingproviderName
. The first provider ofJsonbProvider
class from list of providers returned byServiceLoader.load
call, 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:
JsonbProvider
instance- Throws:
JsonbException
- if there is no provider found, or there is a problem instantiating the provider instance.NullPointerException
- if providerName isnull
.- See Also:
-
create
Returns a new instance ofJsonbBuilder
class.JsonbBuilder
provides 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 theJsonbBuilder
instance.- See Also:
-