Skip to content

Commit

Permalink
[WFCORE-6728] Refactor ExtensionRegistry to be a supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed Mar 21, 2024
1 parent 05006ab commit 720f835
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -118,7 +117,7 @@ public static class Builder {
private JmxAuthorizer authorizer = NO_OP_AUTHORIZER;
private Supplier<SecurityIdentity> securityIdentitySupplier = Functions.constantSupplier(null);
private RuntimeHostControllerInfoAccessor hostControllerInfoAccessor = RuntimeHostControllerInfoAccessor.SERVER;
private AtomicReference<Stability> stabilityReference = new AtomicReference<>(Stability.DEFAULT);
private Supplier<Stability> stabilitySupplier = Functions.constantSupplier(Stability.DEFAULT);

private Builder(ProcessType processType) {
this.processType = processType;
Expand Down Expand Up @@ -185,21 +184,21 @@ public Builder withHostControllerInfoAccessor(RuntimeHostControllerInfoAccessor

/**
* Overrides the default stability level of the extension registry. This is a convenience method for
* {@link #withStabilityReference(AtomicReference)}.
* {@link #withStabilitySupplier(Supplier)}.
* @param stability the stability level to use
* @return a reference to this builder
*/
public Builder withStability(Stability stability) {
return withStabilityReference(new AtomicReference<>(stability));
return withStabilitySupplier(Functions.constantSupplier(stability));
}

/**
* Overrides the default stability level of the extension registry.
* @param stabilityReference an AtomicReference containing the stability level
* @param stabilitySupplier a Supplier returning the stability level
* @return a reference to this builder
*/
public Builder withStabilityReference(AtomicReference<Stability> stabilityReference) {
this.stabilityReference = stabilityReference;
public Builder withStabilitySupplier(Supplier<Stability> stabilitySupplier) {
this.stabilitySupplier = stabilitySupplier;
return this;
}

Expand All @@ -220,7 +219,7 @@ public ExtensionRegistry build() {
}

private final ProcessType processType;
private final AtomicReference<Stability> stability;
private final Supplier<Stability> stability;

private SubsystemXmlWriterRegistry writerRegistry;
private volatile PathManager pathManager;
Expand All @@ -244,7 +243,7 @@ private ExtensionRegistry(Builder builder) {
this.authorizer = builder.authorizer;
this.securityIdentitySupplier = builder.securityIdentitySupplier;
this.hostControllerInfoAccessor = builder.hostControllerInfoAccessor;
this.stability = builder.stabilityReference;
this.stability = builder.stabilitySupplier;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/org/jboss/as/server/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ final class Configuration {
private final DelegatingConfigurableAuthorizer authorizer;
private final ManagementSecurityIdentitySupplier securityIdentitySupplier;

// Used to update the stability in the supplier cached by the ExtensionRegistry
private final AtomicReference<Stability> stabilityReference;
private ModuleLoader moduleLoader = Module.getBootModuleLoader();
private ConfigurationPersisterFactory configurationPersisterFactory;
Expand All @@ -96,7 +97,7 @@ public Configuration(final ServerEnvironment serverEnvironment) {
this.stabilityReference = new AtomicReference<>(serverEnvironment.getStability());
this.extensionRegistry = ExtensionRegistry.builder(serverEnvironment.getLaunchType().getProcessType())
.withRunningModeControl(this.runningModeControl)
.withStabilityReference(this.stabilityReference)
.withStabilitySupplier(stabilityReference::get)
.withAuditLogger(this.auditLogger)
.withAuthorizer(this.authorizer)
.withSecurityIdentitySupplier(this.securityIdentitySupplier)
Expand Down

0 comments on commit 720f835

Please sign in to comment.