Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-7039

Add ServiceInstaller.Builder.onRemove(...) to accomodate ValueRegistry removal

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 27.0.0.Beta3
    • 26.0.0.Final
    • Management
    • None

      Subsystem developers wanting to use ValueRegistry to capture service values via ServiceInstaller.Builder.withCaptor(...) current lack a facility to remove the associated registry entry on service removal.
      e.g.

      ServiceInstaller installer = ServiceInstaller.builder(...).withCaptor(registry.add(...)).build();
      

      Currently, one must resort to a verbosely decorating the result of Installer.install() in order to add service removal behavior.
      e.g.

      ResourceServiceInstaller installer = ServiceInstaller.builder(...).withCaptor(registry.add(...)).build();
      ResourceServiceInstaller decorator = new ResourceServiceInstaller() {
          Consumer<OperationContext> remover = ctx -> registry.remove(ctx.getCurrentAddressValue());
          return new ResourceServiceInstaller() {
              @Override
              public Consumer<OperationContext> install(OperationContext context) {
                  return installer.install(context).andThen(remover);
              }
          }
      }
      

      It would more user friendly to be able to add this behavior via the ServiceInstaller.Builder itself, e.g.:

      ServiceInstaller installer = ServiceInstaller.builder(...)
          .withCaptor(registry.add(...))
          .onRemove(() -> registry.remove(...))
          .build();
      

              pferraro@redhat.com Paul Ferraro
              pferraro@redhat.com Paul Ferraro
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: