當前位置: 首頁>>代碼示例>>Java>>正文


Java OperationMessageHandler類代碼示例

本文整理匯總了Java中org.jboss.as.controller.client.OperationMessageHandler的典型用法代碼示例。如果您正苦於以下問題:Java OperationMessageHandler類的具體用法?Java OperationMessageHandler怎麽用?Java OperationMessageHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OperationMessageHandler類屬於org.jboss.as.controller.client包,在下文中一共展示了OperationMessageHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readLogFile

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
private void readLogFile(ModelNode opNode) throws IOException {

        Operation op = OperationBuilder.create(opNode).build();
        try (OperationResponse response = getModelControllerClient().executeOperation(op, OperationMessageHandler.DISCARD)) {

            ModelNode respNode = response.getResponseNode();
            Assert.assertEquals(respNode.toString(), "success", respNode.get("outcome").asString());
            Assert.assertEquals(respNode.toString(), ModelType.STRING, respNode.get("result").getType());
            String uuid = respNode.get("result").asString();
            List<? extends OperationResponse.StreamEntry> streams = response.getInputStreams();
            Assert.assertEquals(1, streams.size());
            OperationResponse.StreamEntry se = streams.get(0);
            Assert.assertEquals(uuid, se.getUUID());
            readLogStream(se.getStream());
        }

    }
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:18,代碼來源:ResponseAttachmentTestCase.java

示例2: readLogFile

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
private void readLogFile(ModelNode opNode, ModelControllerClient client, boolean forServer) throws IOException {
    Operation op = OperationBuilder.create(opNode).build();
    OperationResponse response = null;
    try {
        response = client.executeOperation(op, OperationMessageHandler.DISCARD);

        ModelNode respNode = response.getResponseNode();
        System.out.println(respNode.toString());
        Assert.assertEquals(respNode.toString(), "success", respNode.get("outcome").asString());
        ModelNode result = respNode.get("result");
        Assert.assertEquals(respNode.toString(), ModelType.STRING, result.getType());
        List<? extends OperationResponse.StreamEntry> streams = response.getInputStreams();
        Assert.assertEquals(1, streams.size());
        processResponseStream(response, result.asString(), forServer, client == masterClient);

    } finally {
        StreamUtils.safeClose(response);
    }

}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:21,代碼來源:ResponseStreamTestCase.java

示例3: execute

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
private OperationResponse execute(ModelNode request, boolean useWaitCursor) throws IOException {

        if(request.get(Util.OPERATION).asString().equals(Util.COMPOSITE) &&
                (!request.get(Util.STEPS).isDefined() || request.get(Util.STEPS).asList().isEmpty())) {
            return OperationResponse.Factory.createSimple(new ModelNode("WARN: no request was sent as there were no server-side operations to execute"));
        }

        try {
            if (useWaitCursor) {
                cliGuiCtx.getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            }
            return client.get().executeOperation(OperationBuilder.create(request).build(), OperationMessageHandler.DISCARD);
        } finally {
            if (useWaitCursor) {
                cliGuiCtx.getMainWindow().setCursor(Cursor.getDefaultCursor());
            }
        }
    }
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:19,代碼來源:CommandExecutor.java

示例4: execute

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
/**
 * Executes an operation on the controller
 * @param operation the operation
 * @param handler the handler
 * @param control the transaction control
 * @param attachments the operation attachments
 * @return the result of the operation
 */
@Override
public ModelNode execute(final ModelNode operation, final OperationMessageHandler handler, final OperationTransactionControl control, final OperationAttachments attachments) {
    SecurityIdentity securityIdentity = securityIdentitySupplier.get();
    OperationResponse or = securityIdentity.runAs((PrivilegedAction<OperationResponse>) () -> internalExecute(operation,
            handler, control, attachments, prepareStep, false, partialModelIndicator.isModelPartial()));

    ModelNode result = or.getResponseNode();
    try {
        or.close();
    } catch (IOException e) {
        ROOT_LOGGER.debugf(e, "Caught exception closing response to %s whose associated streams, " +
                "if any, were not wanted", operation);
    }
    return result;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:24,代碼來源:ModelControllerImpl.java

示例5: setup

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Before
public void setup() {
    root = ManagementResourceRegistration.Factory.forProcessType(ProcessType.HOST_CONTROLLER).createRegistration(new SimpleResourceDefinition(null, new NonResolvingResourceDescriptionResolver()));
    proxyController = new ProxyController() {
        @Override
        public PathAddress getProxyNodeAddress() {
            return PathAddress.pathAddress(PROXY_ELEMENT);
        }

        @Override
        public void execute(ModelNode operation, OperationMessageHandler handler, ProxyOperationControl control, OperationAttachments attachments, BlockingTimeout blockingTimeout) {
            throw new UnsupportedOperationException();
        }
    };
    root.registerProxyController(PROXY_ELEMENT, proxyController);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:17,代碼來源:ProxyControllerRegistrationUnitTestCase.java

示例6: execute

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Override
public void execute(ModelNode operation, OperationMessageHandler handler, final ProxyOperationControl control, OperationAttachments attachments, BlockingTimeout blockingTimeout) {
    final ModelNode response = new ModelNode();
    response.get("outcome").set("success");
    response.get("result", "attr").set(true);

    control.operationPrepared(new ModelController.OperationTransaction() {
        @Override
        public void commit() {
            control.operationCompleted(OperationResponse.Factory.createSimple(response));
        }

        @Override
        public void rollback() {
            control.operationCompleted(OperationResponse.Factory.createSimple(response));
        }
    }, response);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:19,代碼來源:ReadResourceWithRuntimeResourceTestCase.java

示例7: readResource

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
/**
 * This returns information on the resource at the given address, recursively
 * returning child nodes with the result if recursive argument is set to <code>true</code>.
 * This will not return an exception if the address points to a non-existent resource, rather,
 * it will just return null. You can use this as a test for resource existence.
 *
 * @param addr the address of the resource
 * @param recursive if true, return all child data within the resource node
 * @return the found item or null if not found
 * @throws Exception if some error prevented the lookup from even happening
 */
public ModelNode readResource(Address addr, boolean recursive) throws Exception {
    final ModelNode request = createRequest(READ_RESOURCE, addr);
    request.get("recursive").set(recursive);
    final ModelNode results = getModelControllerClient().execute(request, OperationMessageHandler.logging);
    if (isSuccess(results)) {
        final ModelNode resource = getResults(results);
        return resource;
    } else {
        return null;
    }
}
 
開發者ID:hawkular,項目名稱:hawkular-agent,代碼行數:23,代碼來源:JBossASClient.java

示例8: block

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
private Future<ModelNode> block(String host, String server, BlockerExtension.BlockPoint blockPoint) {
    ModelNode op = BLOCK_OP.clone();
    op.get(TARGET_HOST.getName()).set(host);
    if (server != null) {
        op.get(TARGET_SERVER.getName()).set(server);
    }
    op.get(BLOCK_POINT.getName()).set(blockPoint.toString());
    op.get(CALLER.getName()).set(getTestMethod());
    return masterClient.executeAsync(op, OperationMessageHandler.DISCARD);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:11,代碼來源:OperationTimeoutTestCase.java

示例9: before

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Before
public void before() throws IOException {

    logMessageContent = String.valueOf(System.currentTimeMillis());
    ModelNode opNode = Util.createAddOperation(PathAddress.pathAddress(SYSTEM_PROPERTY, LogStreamExtension.LOG_MESSAGE_PROP));
    opNode.get(VALUE).set(logMessageContent);
    Operation op = OperationBuilder.create(opNode).build();
    masterClient.executeOperation(op, OperationMessageHandler.DISCARD);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:10,代碼來源:ResponseStreamTestCase.java

示例10: after

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@After
public void after() throws IOException {
    ModelNode opNode = Util.createEmptyOperation(REMOVE, PathAddress.pathAddress(SYSTEM_PROPERTY, LogStreamExtension.LOG_MESSAGE_PROP));
    Operation op = OperationBuilder.create(opNode).build();
    masterClient.executeOperation(op, OperationMessageHandler.DISCARD);

    shutdownHttpClient();

}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:10,代碼來源:ResponseStreamTestCase.java

示例11: testComposite

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Test
public void testComposite() throws IOException {
    ModelNode composite = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    ModelNode steps = composite.get(STEPS);
    steps.add(createReadAttributeOp(PathAddress.pathAddress(PROFILE, "default")));
    steps.add(createReadAttributeOp(PathAddress.pathAddress(HOST, "master").append(SERVER, "main-one")));
    steps.add(createReadAttributeOp(PathAddress.pathAddress(HOST, "slave").append(SERVER, "main-three")));
    Operation op = OperationBuilder.create(composite).build();
    OperationResponse response = null;
    try {
        response = masterClient.executeOperation(op, OperationMessageHandler.DISCARD);

        ModelNode respNode = response.getResponseNode();
        System.out.println(respNode.toString());
        Assert.assertEquals(respNode.toString(), "success", respNode.get("outcome").asString());
        List<? extends OperationResponse.StreamEntry> streams = response.getInputStreams();
        //Assert.assertEquals(3, streams.size());

        ModelNode result0 = respNode.get(RESULT, "step-1", RESULT);
        Assert.assertEquals(ModelType.STRING, result0.getType());
        String uuid = result0.asString();
        processResponseStream(response, uuid, false, true);

        ModelNode result1 = respNode.get(RESULT, "step-2", RESULT);
        Assert.assertEquals(ModelType.STRING, result1.getType());
        uuid = result1.asString();
        processResponseStream(response, uuid, true, false);

        ModelNode result2 = respNode.get(RESULT, "step-3", RESULT);
        Assert.assertEquals(ModelType.STRING, result2.getType());
        uuid = result2.asString();
        processResponseStream(response, uuid, true, false);

    } finally {
        StreamUtils.safeClose(response);
    }
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:38,代碼來源:ResponseStreamTestCase.java

示例12: testSlaveBlockOtherOpCancelMaster

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Test
public void testSlaveBlockOtherOpCancelMaster() throws Exception {
    long start = System.currentTimeMillis();
    Future<ModelNode> blockFuture = block("slave", null, BlockerExtension.BlockPoint.MODEL);
    String blockId = findActiveOperation(masterClient, "slave", null, "block", null, start);
    Future<ModelNode> writeFuture = masterClient.executeAsync(WRITE_FOO_OP, OperationMessageHandler.DISCARD);
    cancel(masterClient, "master", null, "write-attribute", OperationContext.ExecutionStatus.AWAITING_OTHER_OPERATION, start, false);
    ModelNode response = writeFuture.get(GET_TIMEOUT, TimeUnit.MILLISECONDS);
    assertEquals(response.asString(), CANCELLED, response.get(OUTCOME).asString());
    blockFuture.cancel(true);
    validateNoActiveOperation(masterClient, "slave", null, blockId, true);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:13,代碼來源:OperationCancellationTestCase.java

示例13: execute

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Override
public ModelNode execute(Operation operation, OperationMessageHandler handler, OperationTransactionControl control,
        OperationStepHandler step) {
    Function<DomainModelControllerService, OperationResponse> function = new Function<DomainModelControllerService, OperationResponse>() {
        @Override
        public OperationResponse apply(DomainModelControllerService controllerService) {
            return InVmAccess.runInVm((PrivilegedAction<OperationResponse>) () -> controllerService.internalExecute(operation, handler, control, step));
        }
    };
    return SecurityActions.privilegedExecution(function, DomainModelControllerService.this).getResponseNode();
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:12,代碼來源:DomainModelControllerService.java

示例14: installSlaveExtensions

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Override
public ModelNode installSlaveExtensions(List<ModelNode> extensions) {
    Operation operation = ApplyExtensionsHandler.getOperation(extensions);
    OperationStepHandler stepHandler = modelNodeRegistration.getOperationHandler(PathAddress.EMPTY_ADDRESS, ApplyExtensionsHandler.OPERATION_NAME);
    Function<DomainModelControllerService, OperationResponse> function = new Function<DomainModelControllerService, OperationResponse>() {
        @Override
        public OperationResponse apply(DomainModelControllerService controllerService) {
            return InVmAccess.runInVm((PrivilegedAction<OperationResponse>) () -> controllerService.internalExecute(operation, OperationMessageHandler.logging, OperationTransactionControl.COMMIT, stepHandler, false, true));
        }
    };
    return SecurityActions.privilegedExecution(function, DomainModelControllerService.this).getResponseNode();
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:13,代碼來源:DomainModelControllerService.java

示例15: joinActiveOperation

import org.jboss.as.controller.client.OperationMessageHandler; //導入依賴的package包/類
@Override
@SuppressWarnings("deprecation")
public ModelNode joinActiveOperation(ModelNode operation, OperationMessageHandler handler,
                                     OperationTransactionControl control,
                                     OperationStepHandler step, int permit) {
    Function<DomainModelControllerService, ModelNode> function = new Function<DomainModelControllerService, ModelNode>() {
        @Override
        public ModelNode apply(DomainModelControllerService controllerService) {
            return InVmAccess.runInVm((PrivilegedAction<ModelNode>) () -> controllerService.executeReadOnlyOperation(operation, handler, control, step, permit));
        }
    };
    return SecurityActions.privilegedExecution(function, DomainModelControllerService.this);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:14,代碼來源:DomainModelControllerService.java


注:本文中的org.jboss.as.controller.client.OperationMessageHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。