Class ServiceFactoryFactory (2.0.0)

public final class ServiceFactoryFactory

This class is not intended for end users.

Provide factory instances for AppEngine APIs. Each API will have an associated FactoryProvider registered with this class. N.B. Once <xref uid="com.google.appengine.spi.ServiceFactoryFactory.

To construct the runtime mapping, this class first uses java.util.ServiceLoader to find all registered FactoryProvider entities using the ClassLoader of ServiceFactoryFactory. Finally, the explicitly registered providers <xref uid="com.google.appengine.spi.ServiceFactoryFactory.register(com.google.appengine.spi.FactoryProvider<I>)" data-throw-if-not-resolved="false">#register(FactoryProvider) are merged in.

If ServiceLoader locates multiple providers for a given factory interface, the ambiguity can be resolved by using the ServiceProvider#precedence annotation property (higher precedence wins; the google implementations all have precedence Integer.MIN_VALUE). An exception is raised if the ambiguity cannot be resolved. Note that explicit registration (<xref uid="com.google.appengine.spi.ServiceFactoryFactory.register(com.google.appengine.spi.FactoryProvider<I>)" data-throw-if-not-resolved="false">#register(FactoryProvider)) always takes precedence (it does not honor the ServiceProvider#precedence annotation property).

Inheritance

java.lang.Object > ServiceFactoryFactory

Static Fields

USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY

public static final String USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY

If this system property is set to "true" the thread context classloader is used (if non-null) when looking up API service implementations. Otherwise the class loader of this class is used.

Field Value
TypeDescription
String

Static Methods

<I>register(FactoryProvider<I> p)

public static synchronized void <I>register(FactoryProvider<I> p)

Explicitly register a provider. This does not take the precedence (see FactoryProvider#getPrecedence()) of the provider into consideration; subsequent registrations will always override previous ones.

Parameter
NameDescription
pFactoryProvider<I>

The provider to register

<T>getFactory(Class<T> base)

public static T <T>getFactory(Class<T> base)

Used by AppEngine service factories. Returns an instance of the factory implementing the interface provide by base. Since there must always be a provider registered for a given base, an error will be raised if no appropriate registration is found.

Parameter
NameDescription
baseClass<T>

The returned factory must extend this class.

Returns
TypeDescription
T

Constructors

ServiceFactoryFactory()

public ServiceFactoryFactory()