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-6662] Remove deprecated usage of ServiceController.getValue() by capturing ModelControllerClientFactory ... #5834

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -71,6 +71,7 @@ interface ShutdownHandler {
private final ShutdownHandler shutdownHandler;

private final AtomicReference<ModelControllerClientFactory> clientFactorySvcCaptureRef;
private final AtomicReference<ProcessStateNotifier> notifierRef;

private Server(String[] cmdargs, Properties systemProps,
Map<String, String> systemEnv, ModuleLoader moduleLoader,
Expand All @@ -80,7 +81,8 @@ private Server(String[] cmdargs, Properties systemProps,
this.systemEnv = systemEnv;
this.moduleLoader = moduleLoader;
this.shutdownHandler = shutdownHandler;
this.clientFactorySvcCaptureRef = new AtomicReference<>(null);
this.clientFactorySvcCaptureRef = new AtomicReference<>();
this.notifierRef = new AtomicReference<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't need to be a field, as its use is confined to one method and the anonymous Service impl created by a call from that method.


processStateListener = new PropertyChangeListener() {
@Override
Expand Down Expand Up @@ -163,7 +165,6 @@ public void exit(int status) {
configuration.setModuleLoader(moduleLoader);

// As part of bootstrap install a service to capture the ProcessStateNotifier
AtomicReference<ProcessStateNotifier> notifierRef = new AtomicReference<>();
ServiceActivator notifierCapture = ctx -> captureNotifier(ctx, notifierRef, ControlledProcessStateService.INTERNAL_SERVICE_NAME);
ServiceActivator clientFactorySvcCapture = ctx -> captureNotifier(ctx, clientFactorySvcCaptureRef, ServerService.JBOSS_SERVER_CLIENT_FACTORY);

Expand Down Expand Up @@ -234,7 +235,7 @@ private synchronized void establishModelControllerClient(ControlledProcessState.
modelControllerClient = null;
if (state != ControlledProcessState.State.STOPPING && state != ControlledProcessState.State.STOPPED
&& serviceContainer != null && clientFactorySvcCaptureRef.get() != null) {
modelControllerClient = clientFactorySvcCaptureRef.get().createSuperUserClient(executorService, true);
modelControllerClient = clientFactorySvcCaptureRef.get().createSuperUserClient(executorService, true);
}
if (storeState || currentProcessState == null) {
currentProcessState = state;
Expand Down Expand Up @@ -274,13 +275,15 @@ private static<T> void captureNotifier(ServiceActivatorContext ctx, AtomicRefere
@Override
public void start(StartContext context) {
notifierRef.set(result.get());
context.getController().setMode(ServiceController.Mode.REMOVE);
}

@Override
public void stop(StopContext context) {
notifierRef.set(null);
}
});
sb.install();

sb.setInitialMode(ServiceController.Mode.PASSIVE)
.install();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,16 @@ private static class StandaloneServerImpl implements StandaloneServer {
private ExecutorService executorService;
private ProcessStateNotifier processStateNotifier;
private final AtomicReference<ModelControllerClientFactory> clientFactorySvcCaptureRef;
private final AtomicReference<ProcessStateNotifier> notifierRef;

public StandaloneServerImpl(String[] cmdargs, Properties systemProps, Map<String, String> systemEnv, ModuleLoader moduleLoader, ClassLoader embeddedModuleCL) {
this.cmdargs = cmdargs;
this.systemProps = systemProps;
this.systemEnv = systemEnv;
this.moduleLoader = moduleLoader;
this.embeddedModuleCL = embeddedModuleCL;
this.clientFactorySvcCaptureRef = new AtomicReference<>(null);
this.clientFactorySvcCaptureRef = new AtomicReference<>();
this.notifierRef = new AtomicReference<>();

processStateListener = new PropertyChangeListener() {
@Override
Expand Down Expand Up @@ -270,7 +272,6 @@ public void exit(int status) {
configuration.setModuleLoader(moduleLoader);

// As part of bootstrap install a service to capture the ProcessStateNotifier
AtomicReference<ProcessStateNotifier> notifierRef = new AtomicReference<>();
ServiceActivator notifierCapture = ctx -> captureNotifier(ctx, notifierRef, ControlledProcessStateService.INTERNAL_SERVICE_NAME);
ServiceActivator clientFactorySvcCapture = ctx -> captureNotifier(ctx, clientFactorySvcCaptureRef, ServerService.JBOSS_SERVER_CLIENT_FACTORY);

Expand Down Expand Up @@ -307,14 +308,16 @@ private static<T> void captureNotifier(ServiceActivatorContext ctx, AtomicRefere
@Override
public void start(StartContext context) {
notifierRef.set(result.get());
context.getController().setMode(ServiceController.Mode.REMOVE);
}

@Override
public void stop(StopContext context) {
notifierRef.set(null);
}
});
sb.install();

sb.setInitialMode(ServiceController.Mode.PASSIVE)
.install();
}

@Override
Expand Down