31 package com.google.protobuf;
41 final class ExtensionRegistryFactory {
43 static final String FULL_REGISTRY_CLASS_NAME =
"com.google.protobuf.ExtensionRegistry";
47 static final Class<?> EXTENSION_REGISTRY_CLASS = reflectExtensionRegistry();
50 static Class<?> reflectExtensionRegistry() {
52 return Class.forName(FULL_REGISTRY_CLASS_NAME);
53 }
catch (ClassNotFoundException e) {
61 public static ExtensionRegistryLite create() {
62 if (EXTENSION_REGISTRY_CLASS !=
null) {
64 return invokeSubclassFactory(
"newInstance");
65 }
catch (Exception e) {
69 return new ExtensionRegistryLite();
73 public static ExtensionRegistryLite createEmpty() {
74 if (EXTENSION_REGISTRY_CLASS !=
null) {
76 return invokeSubclassFactory(
"getEmptyRegistry");
77 }
catch (Exception e) {
81 return EMPTY_REGISTRY_LITE;
85 static boolean isFullRegistry(ExtensionRegistryLite registry) {
86 return EXTENSION_REGISTRY_CLASS !=
null
87 && EXTENSION_REGISTRY_CLASS.isAssignableFrom(registry.getClass());
90 private static final ExtensionRegistryLite invokeSubclassFactory(String methodName)
92 return (ExtensionRegistryLite)
93 EXTENSION_REGISTRY_CLASS.getDeclaredMethod(methodName).invoke(
null);