Stay organized with collections
Save and categorize content based on your preferences.
publicfinalclassServiceFactoryFactory
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).
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.
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eServiceFactoryFactory\u003c/code\u003e is designed for internal use and provides factory instances for AppEngine APIs.\u003c/p\u003e\n"],["\u003cp\u003eIt uses \u003ccode\u003ejava.util.ServiceLoader\u003c/code\u003e to discover and register \u003ccode\u003eFactoryProvider\u003c/code\u003e entities, mapping APIs to factories.\u003c/p\u003e\n"],["\u003cp\u003eMultiple providers for the same factory interface are resolved using the \u003ccode\u003eServiceProvider#precedence\u003c/code\u003e property, with higher precedence winning, except for explicit registrations which take absolute precedence.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eregister(FactoryProvider)\u003c/code\u003e method allows for the explicit registration of providers, overriding any previously registered ones.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetFactory(Class<T> base)\u003c/code\u003e method is used by AppEngine to retrieve an instance of a factory that implements a given interface, raising an error if no appropriate provider is found.\u003c/p\u003e\n"]]],[],null,["# Class ServiceFactoryFactory (2.0.0)\n\n public final class ServiceFactoryFactory\n\n**This class is not intended for end users.**\n\nProvide factory instances for AppEngine APIs. Each API will have an associated\n[FactoryProvider](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.spi.FactoryProvider) registered with this class. N.B. *Once \\\u003cxref uid=\"com.google.appengine.spi.ServiceFactoryFactory.*\n\nTo construct the runtime mapping, this class first uses `java.util.ServiceLoader` to\nfind all registered [FactoryProvider](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.spi.FactoryProvider) entities using the `ClassLoader` of\n`ServiceFactoryFactory`. Finally, the explicitly registered providers\n\\\u003cxref uid=\"com.google.appengine.spi.ServiceFactoryFactory.*register(com.google.appengine.spi.FactoryProvider\\\u003cI\\\u003e)\" data-throw-if-not-resolved=\"false\"\\\u003e#register(FactoryProvider) are merged in.*\n\n*If `ServiceLoader` locates multiple providers for a given factory interface, the\nambiguity can be resolved by using the [ServiceProvider#precedence](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.spi.ServiceProvider#com_google_appengine_spi_ServiceProvider_precedence_) annotation property\n(higher precedence wins; *the google implementations all have precedence\nInteger.MIN_VALUE* ). An exception is raised if the ambiguity cannot be resolved. Note that\nexplicit registration (\\\u003cxref uid=\"com.google.appengine.spi.ServiceFactoryFactory.*register(com.google.appengine.spi.FactoryProvider\\\u003cI\\\u003e)\" data-throw-if-not-resolved=\"false\"\\\u003e#register(FactoryProvider)) always takes precedence (it does not\nhonor the [ServiceProvider#precedence](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.spi.ServiceProvider#com_google_appengine_spi_ServiceProvider_precedence_) annotation property).**\n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e ServiceFactoryFactory \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Fields\n-------------\n\n### USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY\n\n public static final String USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY\n\nIf this system property is set to \"true\" the thread context classloader is used (if non-null)\nwhen looking up API service implementations. Otherwise the class loader of this class is used.\n\nStatic Methods\n--------------\n\n### \\\u003cI\\\u003eregister(FactoryProvider\\\u003cI\\\u003e p)\n\n public static synchronized void \u003cI\u003eregister(FactoryProvider\u003cI\u003e p)\n\nExplicitly register a provider. This does not take the precedence (see\nFactoryProvider#getPrecedence()) of the provider into consideration; subsequent\nregistrations will always override previous ones.\n\n### \\\u003cT\\\u003egetFactory(Class\\\u003cT\\\u003e base)\n\n public static T \u003cT\u003egetFactory(Class\u003cT\u003e base)\n\nUsed by AppEngine service factories. Returns an instance of the factory implementing the\ninterface provide by `base`. Since there must always be a provider registered for a given\nbase, an error will be raised if no appropriate registration is found.\n\nConstructors\n------------\n\n### ServiceFactoryFactory()\n\n public ServiceFactoryFactory()"]]