Class AuthleteApiFactory
- java.lang.Object
-
- com.authlete.common.api.AuthleteApiFactory
-
public class AuthleteApiFactory extends Object
Factory to create anAuthleteApi
instance.- Author:
- Takahiko Kawasaki
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AuthleteApi
create(AuthleteConfiguration configuration)
Create an instance ofAuthleteApi
.static AuthleteApi
create(AuthleteConfiguration configuration, String className)
Create an instance ofAuthleteApi
from the specified class.static AuthleteApi
getDefaultApi()
Get the default instance ofAuthleteApi
.
-
-
-
Method Detail
-
create
public static AuthleteApi create(AuthleteConfiguration configuration)
Create an instance ofAuthleteApi
.This method repeats to call
create(AuthleteConfiguration, String)
until one of the known classes is successfully instantiated.The classes listed below are the ones that the current implementation knows for Authlete API V3.
com.authlete.jaxrs.api.AuthleteApiImplV3
(using JAX-RS 2.0 API, contained incom.authlete:authlete-java-jaxrs
)
The classes listed below are the ones that the current implementation knows for Authlete API V2.
com.authlete.jaxrs.api.AuthleteApiImpl
(using JAX-RS 2.0 API, contained incom.authlete:authlete-java-jaxrs
)com.authlete.common.api.AuthleteApiImpl
(usingHttpURLConnection
, contained incom.authlete:authlete-java-common
since version 2.0)
- Parameters:
configuration
- Authlete configuration.- Returns:
- An instance of
AuthleteApi
. If none of the known classes that implementAuthleteApi
interface was successfully instantiated,null
is returned.
-
create
public static AuthleteApi create(AuthleteConfiguration configuration, String className)
Create an instance ofAuthleteApi
from the specified class.- Parameters:
configuration
- Authlete configuration.className
- The name of a class that implementsAuthleteApi
interface. The class must have a constructor which takes one argument of typeAuthleteConfiguration
.- Returns:
- An instance of the specified class.
- Throws:
IllegalArgumentException
-configuration
isnull
.className
isnull
.- The specified class is not found.
- The specified class does not implement
AuthleteApi
interface. - The specified class does not have a constructor which takes one
argument of type
AuthleteConfiguration
.
IllegalStateException
- The constructor of the specified class threw an exception.
-
getDefaultApi
public static AuthleteApi getDefaultApi()
Get the default instance ofAuthleteApi
.This method loads a configuration file (using
AuthletePropertiesConfiguration
) on the first call, creates an instance ofAuthleteApi
and caches the instance. The second and subsequent calls return the cached instance.The default name of the configuration file is
authlete.properties
, but it can be changed by a system propertyauthlete.configuration.file
. The current directory and the classpath are searched for the configuration file in this order.- Returns:
- An instance of
AuthleteApi
. - Since:
- 1.29
-
-