Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFCORE-6844 DeploymentPhaseContext is missing wildfly-service integration #6029

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
* @param <T> the type of objects that may be supplied by this supplier.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @deprecated To be removed without replacement.
*/
@Deprecated(forRemoval = true)
public final class DelegatingSupplier<T> implements Supplier<T> {

private volatile Supplier<T> delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.service.ServiceDependency;

/**
* The deployment unit processor context. Maintains state pertaining to the current cycle
Expand Down Expand Up @@ -93,8 +94,23 @@ default ServiceTarget getServiceTarget() {
* @param serviceName the service name to add to {@link Attachments#NEXT_PHASE_DEPS}
* @param supplier the supplier into which the dependency value is injected
* @throws IllegalStateException If this is the last phase
* @deprecated Use {@link #requires(ServiceDependency)} instead.
*/
<T> void requires(ServiceName serviceName, DelegatingSupplier<T> supplier);
@Deprecated(forRemoval = true)
default <T> void requires(ServiceName serviceName, DelegatingSupplier<T> supplier) {
ServiceDependency<T> dependency = ServiceDependency.on(serviceName);
supplier.set(dependency);
this.requires(dependency);
}

/**
* Adds the specified dependency to the next phase service.
*
* @param <T> the dependency type
* @param dependency a service dependency
* @throws IllegalStateException If this is the last phase
*/
<T> void requires(ServiceDependency<T> dependency);

/**
* Adds a dependency on the service to the next phase service. The service value will be make available as an attachment to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.wildfly.service.ServiceDependency;

/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
Expand Down Expand Up @@ -63,27 +64,12 @@ public <T> void addDependency(ServiceName serviceName, AttachmentKey<T> attachme
}

@Override
public <T> void requires(final ServiceName serviceName, final DelegatingSupplier<T> supplier) {
this.dependencies.add(new SupplierDeploymentPhaseDependency<>(serviceName, supplier));
public <T> void requires(ServiceDependency<T> dependency) {
this.dependencies.add(dependency);
}

@Override
public <T> void addDeploymentDependency(ServiceName serviceName, AttachmentKey<T> attachmentKey) {
addToAttachmentList(Attachments.NEXT_PHASE_ATTACHABLE_DEPS, new AttachableDependency(attachmentKey, serviceName, true));
}

private static final class SupplierDeploymentPhaseDependency<T> implements Consumer<ServiceBuilder<?>> {
private final ServiceName name;
private final DelegatingSupplier<T> supplier;

private SupplierDeploymentPhaseDependency(final ServiceName name, final DelegatingSupplier<T> supplier) {
this.name = name;
this.supplier = supplier;
}

@Override
public void accept(ServiceBuilder<?> builder) {
supplier.set(builder.requires(name));
}
}
}