@Override
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    ModelNode newValue = operation.require(CacheContainerResource.PROTO_URL.getName());
    String urlString = newValue.asString();

    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String cacheContainerName = address.getElement(address.size() - 1).getValue();
    final ServiceController<?> controller =
        context
            .getServiceRegistry(false)
            .getService(EmbeddedCacheManagerService.getServiceName(cacheContainerName));

    EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) controller.getValue();
    ProtobufMetadataManager protoManager =
        cacheManager.getGlobalComponentRegistry().getComponent(ProtobufMetadataManager.class);
    if (protoManager != null) {
      try {
        URL url = new URL(urlString);
        protoManager.registerProtofile(url.openStream());
      } catch (Exception e) {
        throw new OperationFailedException(
            new ModelNode().set(MESSAGES.failedToInvokeOperation(e.getLocalizedMessage())));
      }
    }
    context.stepCompleted();
  }
Пример #2
0
 @Override
 public CompletableFuture<Object> invokeAsync() throws Throwable {
   GlobalComponentRegistry globalComponentRegistry = cacheManager.getGlobalComponentRegistry();
   ComponentRegistry cacheComponentRegistry =
       globalComponentRegistry.getNamedComponentRegistry(cacheName);
   String name = cacheName.toString();
   if (cacheComponentRegistry != null) {
     cacheComponentRegistry.getComponent(PersistenceManager.class).setClearOnStop(true);
     cacheComponentRegistry.getComponent(CacheJmxRegistration.class).setUnregisterCacheMBean(true);
     cacheComponentRegistry.getComponent(PassivationManager.class).skipPassivationOnStop(true);
     Cache<?, ?> cache = cacheManager.getCache(name, false);
     if (cache != null) {
       cache.stop();
     }
   }
   globalComponentRegistry.removeCache(name);
   // Remove cache configuration and remove it from the computed cache name list
   globalComponentRegistry.getComponent(ConfigurationManager.class).removeConfiguration(name);
   // Remove cache from dependency graph
   //noinspection unchecked
   globalComponentRegistry
       .getComponent(DependencyGraph.class, CACHE_DEPENDENCY_GRAPH)
       .remove(cacheName);
   return CompletableFutures.completedNull();
 }
Пример #3
0
 public static ScriptingManager getScriptingManager(EmbeddedCacheManager manager) {
   return manager.getGlobalComponentRegistry().getComponent(ScriptingManager.class);
 }