From 9182b8f93cc0e87b50dc8474326d6468b1186ee6 Mon Sep 17 00:00:00 2001 From: Paul Ferraro Date: Thu, 25 Apr 2024 11:14:21 -0400 Subject: [PATCH] WFCORE-6806 Add method to combine multiple DeploymentServiceInstaller --- .../service/DeploymentServiceInstaller.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/subsystem/src/main/java/org/wildfly/subsystem/service/DeploymentServiceInstaller.java b/subsystem/src/main/java/org/wildfly/subsystem/service/DeploymentServiceInstaller.java index 3e5f67d7e73..dce656550dd 100644 --- a/subsystem/src/main/java/org/wildfly/subsystem/service/DeploymentServiceInstaller.java +++ b/subsystem/src/main/java/org/wildfly/subsystem/service/DeploymentServiceInstaller.java @@ -4,6 +4,9 @@ */ package org.wildfly.subsystem.service; +import java.util.Collection; +import java.util.List; + import org.jboss.as.server.deployment.DeploymentPhaseContext; /** @@ -16,4 +19,29 @@ public interface DeploymentServiceInstaller { * @param context a deployment phase context */ void install(DeploymentPhaseContext context); + + /** + * Returns a composite {@link DeploymentServiceInstaller} that installs the specified installers. + * @param installers a variable number of installers + * @return a composite installer + */ + static DeploymentServiceInstaller combine(DeploymentServiceInstaller... installers) { + return combine(List.of(installers)); + } + + /** + * Returns a composite {@link DeploymentServiceInstaller} that installs the specified installers. + * @param installers a collection of installers + * @return a composite installer + */ + static DeploymentServiceInstaller combine(Collection installers) { + return new DeploymentServiceInstaller() { + @Override + public void install(DeploymentPhaseContext context) { + for (DeploymentServiceInstaller installer : installers) { + installer.install(context); + } + } + }; + } }