Skip to content

Commit 2ad8055

Browse files
committed
[WFCORE-7273] Add deprecation info to the ModelControllerClient methods that return AsyncFuture to advise about the upcoming change.
1 parent 1333870 commit 2ad8055

File tree

4 files changed

+41
-18
lines changed

4 files changed

+41
-18
lines changed

controller-client/src/main/java/org/jboss/as/controller/client/ModelControllerClient.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ default ModelNode execute(Operation operation, OperationMessageHandler messageHa
105105
*
106106
* @param operation the operation to execute
107107
* @return the future result of the operation
108+
*
109+
* @deprecated the type returned by this method will change to {@link java.util.concurrent.CompletableFuture}.
110+
* Callers can prepare for this by not assigning this method's returned value to a variable of type
111+
* {@link AsyncFuture} but instead use {@link java.util.concurrent.Future} as the variable type.
108112
*/
113+
@Deprecated
109114
default AsyncFuture<ModelNode> executeAsync(ModelNode operation) {
110115
return executeAsync(Operation.Factory.create(operation), OperationMessageHandler.DISCARD);
111116
}
@@ -116,7 +121,12 @@ default AsyncFuture<ModelNode> executeAsync(ModelNode operation) {
116121
* @param operation the operation to execute
117122
* @param messageHandler the message handler to use for operation progress reporting, or {@code null} for none
118123
* @return the future result of the operation
124+
*
125+
* @deprecated the type returned by this method will change to {@link java.util.concurrent.CompletableFuture}.
126+
* Callers can prepare for this by not assigning this method's returned value to a variable of type
127+
* {@link AsyncFuture} but instead use {@link java.util.concurrent.Future} as the variable type.
119128
*/
129+
@Deprecated
120130
default AsyncFuture<ModelNode> executeAsync(ModelNode operation, OperationMessageHandler messageHandler) {
121131
return executeAsync(Operation.Factory.create(operation), messageHandler);
122132
}
@@ -129,7 +139,12 @@ default AsyncFuture<ModelNode> executeAsync(ModelNode operation, OperationMessag
129139
*
130140
* @param operation the operation to execute
131141
* @return the future result of the operation
142+
*
143+
* @deprecated the type returned by this method will change to {@link java.util.concurrent.CompletableFuture}.
144+
* Callers can prepare for this by not assigning this method's returned value to a variable of type
145+
* {@link AsyncFuture} but instead use {@link java.util.concurrent.Future} as the variable type.
132146
*/
147+
@Deprecated
133148
default AsyncFuture<ModelNode> executeAsync(Operation operation) {
134149
return executeAsync(operation, OperationMessageHandler.DISCARD);
135150
}
@@ -143,7 +158,12 @@ default AsyncFuture<ModelNode> executeAsync(Operation operation) {
143158
* @param operation the operation to execute
144159
* @param messageHandler the message handler to use for operation progress reporting, or {@code null} for none
145160
* @return the future result of the operation
161+
*
162+
* @deprecated the type returned by this method will change to {@link java.util.concurrent.CompletableFuture}.
163+
* Callers can prepare for this by not assigning this method's returned value to a variable of type
164+
* {@link AsyncFuture} but instead use {@link java.util.concurrent.Future} as the variable type.
146165
*/
166+
@Deprecated
147167
AsyncFuture<ModelNode> executeAsync(Operation operation, OperationMessageHandler messageHandler);
148168

149169
/**
@@ -156,7 +176,12 @@ default AsyncFuture<ModelNode> executeAsync(Operation operation) {
156176
* @param operation the operation to execute
157177
* @param messageHandler the message handler to use for operation progress reporting, or {@code null} for none
158178
* @return the future result of the operation
179+
*
180+
* @deprecated the type returned by this method will change to {@link java.util.concurrent.CompletableFuture}.
181+
* Callers can prepare for this by not assigning this method's returned value to a variable of type
182+
* {@link AsyncFuture} but instead use {@link java.util.concurrent.Future} as the variable type.
159183
*/
184+
@Deprecated
160185
AsyncFuture<OperationResponse> executeOperationAsync(Operation operation, OperationMessageHandler messageHandler);
161186

162187
/** Factory methods for creating a {@code ModelControllerClient}. */

controller/src/test/java/org/jboss/as/controller/ModelControllerClientTestCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.concurrent.BlockingQueue;
1818
import java.util.concurrent.CountDownLatch;
1919
import java.util.concurrent.ExecutorService;
20+
import java.util.concurrent.Future;
2021
import java.util.concurrent.LinkedBlockingQueue;
2122
import java.util.concurrent.ThreadFactory;
2223
import java.util.concurrent.ThreadPoolExecutor;
@@ -41,7 +42,6 @@
4142
import org.jboss.dmr.ModelNode;
4243
import org.jboss.logging.Logger;
4344
import org.jboss.remoting3.Channel;
44-
import org.jboss.threads.AsyncFuture;
4545
import org.jboss.threads.JBossThreadFactory;
4646
import org.junit.After;
4747
import org.junit.Assert;
@@ -243,7 +243,7 @@ public ModelNode execute(ModelNode operation, OperationMessageHandler handler, O
243243

244244
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
245245

246-
AsyncFuture<ModelNode> resultFuture = client.executeAsync(operation,
246+
Future<ModelNode> resultFuture = client.executeAsync(operation,
247247
new OperationMessageHandler() {
248248

249249
@Override
@@ -296,7 +296,7 @@ public ModelNode execute(ModelNode operation, OperationMessageHandler handler, O
296296

297297
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
298298

299-
AsyncFuture<ModelNode> resultFuture = client.executeAsync(operation,
299+
Future<ModelNode> resultFuture = client.executeAsync(operation,
300300
new OperationMessageHandler() {
301301

302302
@Override

testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/DeploymentOverlayTestCase.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import org.jboss.dmr.ModelNode;
5757
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
5858
import org.jboss.shrinkwrap.api.spec.JavaArchive;
59-
import org.jboss.threads.AsyncFuture;
6059
import org.junit.After;
6160
import org.junit.AfterClass;
6261
import org.junit.BeforeClass;
@@ -119,7 +118,7 @@ public void testInstallAndOverlayDeploymentOnDC() throws IOException, MgmtOperat
119118
final JavaArchive archive = ServiceActivatorDeploymentUtil.createServiceActivatorDeploymentArchive("test-deployment.jar", properties);
120119
ModelNode result;
121120
try (InputStream is = archive.as(ZipExporter.class).exportAsInputStream()){
122-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(addDeployment(is), null);
121+
Future<ModelNode> future = primaryClient.executeAsync(addDeployment(is), null);
123122
result = awaitSimpleOperationExecution(future);
124123
}
125124
assertTrue(Operations.isSuccessfulOutcome(result));
@@ -284,13 +283,13 @@ public void testInstallAndOverlayDeploymentOnDC() throws IOException, MgmtOperat
284283
}
285284

286285
private void executeAsyncForResult(DomainClient client, ModelNode op) {
287-
AsyncFuture<ModelNode> future = client.executeAsync(op, null);
286+
Future<ModelNode> future = client.executeAsync(op, null);
288287
ModelNode response = awaitSimpleOperationExecution(future);
289288
assertTrue(response.toJSONString(true), Operations.isSuccessfulOutcome(response));
290289
}
291290

292291
private void executeAsyncForDomainFailure(DomainClient client, ModelNode op, String failureDescription) {
293-
AsyncFuture<ModelNode> future = client.executeAsync(op, null);
292+
Future<ModelNode> future = client.executeAsync(op, null);
294293
ModelNode response = awaitSimpleOperationExecution(future);
295294
assertFalse(response.toJSONString(true), Operations.isSuccessfulOutcome(response));
296295
assertTrue(response.toJSONString(true), Operations.getFailureDescription(response).hasDefined("domain-failure-description"));
@@ -299,7 +298,7 @@ private void executeAsyncForDomainFailure(DomainClient client, ModelNode op, Str
299298
}
300299

301300
private void executeAsyncForFailure(DomainClient client, ModelNode op, String failureDescription) {
302-
AsyncFuture<ModelNode> future = client.executeAsync(op, null);
301+
Future<ModelNode> future = client.executeAsync(op, null);
303302
ModelNode response = awaitSimpleOperationExecution(future);
304303
assertFalse(response.toJSONString(true), Operations.isSuccessfulOutcome(response));
305304
assertEquals(failureDescription, Operations.getFailureDescription(response).asString());
@@ -318,7 +317,7 @@ private ModelNode readDeploymentResource(PathAddress address) {
318317
ModelNode operation = Operations.createReadResourceOperation(address.toModelNode());
319318
operation.get(INCLUDE_RUNTIME).set(true);
320319
operation.get(INCLUDE_DEFAULTS).set(true);
321-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(operation, null);
320+
Future<ModelNode> future = primaryClient.executeAsync(operation, null);
322321
ModelNode result = awaitSimpleOperationExecution(future);
323322
assertTrue(Operations.isSuccessfulOutcome(result));
324323
return Operations.readResult(result);

testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ExplodedDeploymentTestCase.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
import org.jboss.dmr.ModelNode;
7676
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
7777
import org.jboss.shrinkwrap.api.spec.JavaArchive;
78-
import org.jboss.threads.AsyncFuture;
7978
import org.junit.After;
8079
import org.junit.AfterClass;
8180
import org.junit.Assert;
@@ -135,15 +134,15 @@ public void testInstallAndExplodeDeploymentOnDC() throws IOException, MgmtOperat
135134
final JavaArchive archive = ServiceActivatorDeploymentUtil.createServiceActivatorDeploymentArchive("test-deployment.jar", properties);
136135
ModelNode result;
137136
try (InputStream is = archive.as(ZipExporter.class).exportAsInputStream()) {
138-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(addDeployment(is), null);
137+
Future<ModelNode> future = primaryClient.executeAsync(addDeployment(is), null);
139138
result = awaitSimpleOperationExecution(future);
140139
}
141140
assertTrue(Operations.isSuccessfulOutcome(result));
142141
ModelNode contentNode = readDeploymentResource(PathAddress.pathAddress(DEPLOYMENT_PATH)).require(CONTENT).require(0);
143142
String initialHash = HashUtil.bytesToHexString(contentNode.get(HASH).asBytes());
144143
assertTrue(contentNode.get(ARCHIVE).asBoolean(true));
145144
//Let's explode it
146-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(Operations.createOperation(EXPLODE, PathAddress.pathAddress(DEPLOYMENT_PATH).toModelNode()), null);
145+
Future<ModelNode> future = primaryClient.executeAsync(Operations.createOperation(EXPLODE, PathAddress.pathAddress(DEPLOYMENT_PATH).toModelNode()), null);
147146
result = awaitSimpleOperationExecution(future);
148147
assertTrue(Operations.isSuccessfulOutcome(result));
149148
contentNode = readDeploymentResource(PathAddress.pathAddress(DEPLOYMENT_PATH)).require(CONTENT).require(0);
@@ -205,7 +204,7 @@ public void testInstallAndExplodeDeploymentOnDC() throws IOException, MgmtOperat
205204

206205
@Test
207206
public void testInstallAndExplodeDeploymentOnDCFromScratch() throws IOException, MgmtOperationException {
208-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(addEmptyDeployment(), null); //Add empty deployment
207+
Future<ModelNode> future = primaryClient.executeAsync(addEmptyDeployment(), null); //Add empty deployment
209208
ModelNode result = awaitSimpleOperationExecution(future);
210209
assertTrue(Operations.isSuccessfulOutcome(result));
211210
ModelNode contentNode = readDeploymentResource(PathAddress.pathAddress(DEPLOYMENT_PATH)).require(CONTENT).require(0);
@@ -305,7 +304,7 @@ public void testEmptyAndAddContentInComposite() throws Exception {
305304
steps.add(addContent);
306305
Operation operation = Operation.Factory.create(composite, contentAttachments);
307306

308-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(operation, null);
307+
Future<ModelNode> future = primaryClient.executeAsync(operation, null);
309308
ModelNode result = awaitSimpleOperationExecution(future);
310309
assertTrue(result.toString(), Operations.isSuccessfulOutcome(result));
311310
ModelNode contentNode = readDeploymentResource(PathAddress.pathAddress(DEPLOYMENT_PATH)).require(CONTENT).require(0);
@@ -342,7 +341,7 @@ public void testEmptyAndAddContentAndDeployInComposite() throws Exception {
342341
steps.add(deployOnServerGroup());
343342
Operation operation = Operation.Factory.create(composite, contentAttachments);
344343

345-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(operation, null);
344+
Future<ModelNode> future = primaryClient.executeAsync(operation, null);
346345
ModelNode result = awaitSimpleOperationExecution(future);
347346
assertTrue(result.toString(), Operations.isSuccessfulOutcome(result));
348347
ModelNode contentNode = readDeploymentResource(PathAddress.pathAddress(DEPLOYMENT_PATH)).require(CONTENT).require(0);
@@ -356,7 +355,7 @@ private ModelNode readDeploymentResource(PathAddress address) {
356355
ModelNode operation = Operations.createReadResourceOperation(address.toModelNode());
357356
operation.get(INCLUDE_RUNTIME).set(true);
358357
operation.get(INCLUDE_DEFAULTS).set(true);
359-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(operation, null);
358+
Future<ModelNode> future = primaryClient.executeAsync(operation, null);
360359
ModelNode result = awaitSimpleOperationExecution(future);
361360
assertTrue(Operations.isSuccessfulOutcome(result));
362361
return Operations.readResult(result);
@@ -383,7 +382,7 @@ public void browseContent(String path, List<String> expectedContents) throws IOE
383382
if (path != null && !path.isEmpty()) {
384383
operation.get(PATH).set(path);
385384
}
386-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(operation, null);
385+
Future<ModelNode> future = primaryClient.executeAsync(operation, null);
387386
ModelNode response = awaitSimpleOperationExecution(future);
388387
assertTrue(Operations.isSuccessfulOutcome(response));
389388
List<ModelNode> contents = Operations.readResult(response).asList();
@@ -403,7 +402,7 @@ public void browseContent(String path, List<String> expectedContents) throws IOE
403402
public void checkNoContent(String path) throws IOException {
404403
ModelNode operation = Operations.createOperation(READ_CONTENT, PathAddress.pathAddress(DEPLOYMENT_PATH).toModelNode());
405404
operation.get(PATH).set(path);
406-
AsyncFuture<ModelNode> future = primaryClient.executeAsync(operation, null);
405+
Future<ModelNode> future = primaryClient.executeAsync(operation, null);
407406
ModelNode result = awaitSimpleOperationExecution(future);
408407
assertFalse(Operations.isSuccessfulOutcome(result));
409408
}

0 commit comments

Comments
 (0)