-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFCORE-7120] Factor out the embedded bootstrap code that requires se…
…rver-side types Move the server-side embedding logic to the server and host-controller modules
- Loading branch information
1 parent
604e53e
commit c17b69c
Showing
39 changed files
with
1,254 additions
and
692 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...oller-client/src/main/java/org/jboss/as/controller/client/LocalModelControllerClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.controller.client; | ||
|
||
import java.io.IOException; | ||
|
||
import org.jboss.as.controller.client.logging.ControllerClientLogger; | ||
import org.jboss.dmr.ModelNode; | ||
|
||
/** | ||
* A {@link ModelControllerClient} subinterface that does not throw {@link java.io.IOException}. | ||
* Used for clients that operate in the same VM as the target {@code ModelController} and hence | ||
* are not subject to IO failures associated with remote calls. | ||
* | ||
* @author Brian Stansberry | ||
*/ | ||
public interface LocalModelControllerClient extends ModelControllerClient { | ||
|
||
@Override | ||
default ModelNode execute(ModelNode operation) { | ||
return execute(Operation.Factory.create(operation), OperationMessageHandler.DISCARD); | ||
} | ||
|
||
@Override | ||
default ModelNode execute(Operation operation) { | ||
return execute(operation, OperationMessageHandler.DISCARD); | ||
} | ||
|
||
@Override | ||
default ModelNode execute(ModelNode operation, OperationMessageHandler messageHandler) { | ||
return execute(Operation.Factory.create(operation), messageHandler); | ||
} | ||
|
||
@Override | ||
default ModelNode execute(Operation operation, OperationMessageHandler messageHandler) { | ||
OperationResponse or = executeOperation(operation, messageHandler); | ||
ModelNode result = or.getResponseNode(); | ||
try { | ||
or.close(); | ||
} catch (IOException e) { | ||
ControllerClientLogger.ROOT_LOGGER.debugf(e, "Failed closing response to %s", operation); | ||
} | ||
return result; | ||
} | ||
|
||
@Override | ||
OperationResponse executeOperation(Operation operation, OperationMessageHandler messageHandler); | ||
|
||
@Override | ||
void close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceName; | ||
import org.jboss.msc.service.ServiceTarget; | ||
import org.wildfly.core.embedded.spi.EmbeddedProcessState; | ||
|
||
/** | ||
* Exposes the current {@link ControlledProcessState.State} and allows services to register a listener for changes | ||
|
@@ -21,7 +22,7 @@ | |
* @author Brian Stansberry (c) 2011 Red Hat Inc. | ||
* @author <a href="mailto:[email protected]">Richard Opalka</a> | ||
*/ | ||
public class ControlledProcessStateService implements ProcessStateNotifier { | ||
public class ControlledProcessStateService implements ProcessStateNotifier, org.wildfly.core.embedded.spi.ProcessStateNotifier { | ||
|
||
/** @deprecated use the 'org.wildfly.management.process-state-notifier' capability to obtain a {@link ProcessStateNotifier}*/ | ||
@Deprecated(forRemoval = true) | ||
|
@@ -41,18 +42,20 @@ public class ControlledProcessStateService implements ProcessStateNotifier { | |
public static ProcessStateNotifier addService(ServiceTarget target, ControlledProcessState processState) { | ||
final ControlledProcessStateService notifier = processState.getService(); | ||
final ServiceBuilder<?> sb = target.addService(); | ||
Consumer<ProcessStateNotifier> consumer = sb.provides(INTERNAL_SERVICE_NAME, SERVICE_NAME); | ||
Consumer<ProcessStateNotifier> consumer = sb.provides(INTERNAL_SERVICE_NAME, SERVICE_NAME, org.wildfly.core.embedded.spi.ProcessStateNotifier.SERVICE_NAME); | ||
sb.setInstance(Service.newInstance(consumer, notifier)); | ||
sb.install(); | ||
return notifier; | ||
} | ||
|
||
private ControlledProcessState.State processState; | ||
private final PropertyChangeSupport changeSupport; | ||
private final boolean embedded; | ||
|
||
ControlledProcessStateService(ControlledProcessState.State initialState) { | ||
ControlledProcessStateService(ControlledProcessState.State initialState, boolean embedded) { | ||
this.processState = initialState; | ||
changeSupport = new PropertyChangeSupport(this); | ||
this.changeSupport = new PropertyChangeSupport(this); | ||
this.embedded = embedded; | ||
} | ||
|
||
/** | ||
|
@@ -65,6 +68,17 @@ public ControlledProcessState.State getCurrentState() { | |
return processState; | ||
} | ||
|
||
/** | ||
* Returns the current process state. | ||
* | ||
* @return the current state | ||
*/ | ||
@Override | ||
public EmbeddedProcessState getEmbeddedProcessState() { | ||
checkEmbedded(); | ||
return processState.getEmbeddedProcessState(); | ||
} | ||
|
||
/** | ||
* Registers a listener for changes to the process state. | ||
* | ||
|
@@ -73,7 +87,7 @@ public ControlledProcessState.State getCurrentState() { | |
@Override | ||
public void addPropertyChangeListener( | ||
PropertyChangeListener listener) { | ||
changeSupport.addPropertyChangeListener(listener); | ||
changeSupport.addPropertyChangeListener("currentState", listener); | ||
} | ||
|
||
/** | ||
|
@@ -84,12 +98,31 @@ public void addPropertyChangeListener( | |
@Override | ||
public void removePropertyChangeListener( | ||
PropertyChangeListener listener) { | ||
changeSupport.removePropertyChangeListener(listener); | ||
changeSupport.removePropertyChangeListener("currentState", listener); | ||
} | ||
|
||
@Override | ||
public void addProcessStateListener(PropertyChangeListener listener) { | ||
checkEmbedded(); | ||
changeSupport.addPropertyChangeListener("embeddedState", listener); | ||
} | ||
|
||
@Override | ||
public void removeProcessStateListener(PropertyChangeListener listener) { | ||
checkEmbedded(); | ||
changeSupport.removePropertyChangeListener("embeddedState", listener); | ||
} | ||
|
||
synchronized void stateChanged(ControlledProcessState.State newState) { | ||
final ControlledProcessState.State oldState = processState; | ||
processState = newState; | ||
changeSupport.firePropertyChange("currentState", oldState, newState); | ||
changeSupport.firePropertyChange("embeddedState", oldState.getEmbeddedProcessState(), newState.getEmbeddedProcessState()); | ||
} | ||
|
||
private void checkEmbedded() { | ||
if (!embedded) { | ||
throw new IllegalStateException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.