/**
  * Replaces a component in a running cache manager (global component registry)
  *
  * @param cacheContainer cache in which to replace component
  * @param componentType component type of which to replace
  * @param replacementComponent new instance
  * @param rewire if true, ComponentRegistry.rewire() is called after replacing.
  * @return the original component that was replaced
  */
 public static <T> T replaceComponent(
     CacheContainer cacheContainer,
     Class<T> componentType,
     T replacementComponent,
     boolean rewire) {
   GlobalComponentRegistry cr = extractGlobalComponentRegistry(cacheContainer);
   T old = cr.getComponent(componentType);
   cr.registerComponent(replacementComponent, componentType);
   if (rewire) {
     cr.rewire();
     cr.rewireNamedRegistries();
   }
   return old;
 }
 private void initProtobufMetadataManager(
     DefaultCacheManager cacheManager, GlobalComponentRegistry gcr) {
   ProtobufMetadataManagerImpl protobufMetadataManager = new ProtobufMetadataManagerImpl();
   gcr.registerComponent(protobufMetadataManager, ProtobufMetadataManager.class);
   registerProtobufMetadataManagerMBean(protobufMetadataManager, gcr, cacheManager.getName());
 }