Examples of ResultHandler


Examples of org.jboss.aesh.cl.result.ResultHandler

        @Override
        @SuppressWarnings("unchecked")
        public int execute(ConsoleOperation output) throws InterruptedException {
            if (output != null && output.getBuffer().trim().length() > 0) {
                ResultHandler resultHandler = null;
                try (CommandContainer commandContainer = getCommand(
                    Parser.findFirstWord(output.getBuffer()),
                    output.getBuffer())) {

                    CommandLine commandLine = commandContainer.getParser()
                        .parse(output.getBuffer());

                    resultHandler = commandContainer.getParser().getCommand().getResultHandler();

                    commandContainer
                        .getParser()
                        .getCommandPopulator()
                        .populateObject(commandContainer.getCommand(),
                            commandLine, invocationProviders, getAeshContext(), true);
                    // validate the command before execute, only call if no
                    // options with overrideRequired is not set
                    if (commandContainer.getParser().getCommand()
                        .getValidator() != null
                        && !commandLine.hasOptionWithOverrideRequired())
                        commandContainer.getParser().getCommand()
                            .getValidator()
                            .validate(commandContainer.getCommand());
                    result = commandContainer
                        .getCommand()
                        .execute(
                            commandInvocationServices
                                .getCommandInvocationProvider(
                                    commandInvocationProvider)
                                .enhanceCommandInvocation(
                                    new AeshCommandInvocation(console,
                                        output.getControlOperator(), this)));

                    if(result == CommandResult.SUCCESS)
                        resultHandler.onSuccess();
                    else
                        resultHandler.onFailure(result);
                }
                catch (CommandLineParserException | CommandValidatorException | OptionValidatorException e) {
                    getShell().out().println(e.getMessage());
                    result = CommandResult.FAILURE;
                    if(resultHandler != null)
                        resultHandler.onValidationFailure(result, e);
                }
                catch (CommandNotFoundException cnfe) {
                    getShell().out().println(cnfe.getMessage());
                    result = CommandResult.FAILURE;
                    if(commandNotFoundHandler != null)
                        commandNotFoundHandler.handleCommandNotFound(output.getBuffer(), getShell());
                }
                catch (Exception e) {
                    if(e instanceof InterruptedException)
                        throw (InterruptedException) e;
                    else {
                        LOGGER.log(Level.SEVERE, "Exception when parsing/running: "
                                + output.getBuffer(), e);
                        getShell().out().println(
                                "Exception when parsing/running: "
                                        + output.getBuffer() + ", "
                                        + e.getMessage()
                        );
                        result = CommandResult.FAILURE;
                        if (resultHandler != null)
                            resultHandler.onValidationFailure(result, e);
                    }
                }
            }
            // empty line
            else if (output != null) {
View Full Code Here

Examples of org.jboss.aesh.cl.result.ResultHandler

        @Override
        @SuppressWarnings("unchecked")
        public int execute(ConsoleOperation output) {
            if (output != null && output.getBuffer().trim().length() > 0) {
                ResultHandler resultHandler = null;
                try (CommandContainer commandContainer = getCommand(
                    Parser.findFirstWord(output.getBuffer()),
                    output.getBuffer())) {

                    CommandLine commandLine = commandContainer.getParser()
                        .parse(output.getBuffer());

                    resultHandler = commandContainer.getParser().getCommand().getResultHandler();

                    commandContainer
                        .getParser()
                        .getCommandPopulator()
                        .populateObject(commandContainer.getCommand(),
                            commandLine, invocationProviders, getAeshContext(), true);
                    // validate the command before execute, only call if no
                    // options with overrideRequired is not set
                    if (commandContainer.getParser().getCommand()
                        .getValidator() != null
                        && !commandLine.hasOptionWithOverrideRequired())
                        commandContainer.getParser().getCommand()
                            .getValidator()
                            .validate(commandContainer.getCommand());
                    result = commandContainer
                        .getCommand()
                        .execute(
                            commandInvocationServices
                                .getCommandInvocationProvider(
                                    commandInvocationProvider)
                                .enhanceCommandInvocation(
                                    new AeshCommandInvocation(console,
                                        output.getControlOperator(), this)));

                    if(result == CommandResult.SUCCESS)
                        resultHandler.onSuccess();
                    else
                        resultHandler.onFailure(result);
                }
                catch (CommandLineParserException e) {
                    getShell().out().println(e.getMessage());
                    result = CommandResult.FAILURE;
                    if(resultHandler != null)
                        resultHandler.onValidationFailure(result, e);
                }
                catch (CommandNotFoundException e) {
                    if (commandNotFoundHandler != null) {
                        commandNotFoundHandler.handleCommandNotFound(
                            output.getBuffer(), getShell());
                    }
                    else {
                        getShell().err().print(
                            "Command not found: "
                                + Parser.findFirstWord(output
                                    .getBuffer())
                                + Config.getLineSeparator());
                    }
                    result = CommandResult.FAILURE;
                }
                catch (OptionValidatorException e) {
                    getShell().out().println(e.getMessage());
                    result = CommandResult.FAILURE;
                    if(resultHandler != null)
                        resultHandler.onValidationFailure(result, e);
                }
                catch (CommandValidatorException e) {
                    getShell().out().println(e.getMessage());
                    result = CommandResult.FAILURE;
                    if(resultHandler != null)
                        resultHandler.onValidationFailure(result, e);
                }
                catch (Exception e) {
                    logger.log(Level.SEVERE, "Exception when parsing/running: "
                        + output.getBuffer(), e);
                    getShell().out().println(
                        "Exception when parsing/running: "
                            + output.getBuffer() + ", "
                            + e.getMessage());
                    result = CommandResult.FAILURE;
                    if(resultHandler != null)
                        resultHandler.onValidationFailure(result, e);
                }
            }
            // empty line
            else if (output != null) {
                result = CommandResult.FAILURE;
View Full Code Here

Examples of org.jboss.as.controller.OperationContext.ResultHandler

        }

        @Override
        public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
            configurationPersistence.prepare();
            context.completeStep(new ResultHandler() {
                @Override
                public void handleResult(final ResultAction resultAction, final OperationContext context, final ModelNode operation) {
                    if (resultAction == ResultAction.KEEP) {
                        configurationPersistence.commit();
                        if (!LoggingProfileOperations.isLoggingProfileAddress(getAddress(operation))) {
View Full Code Here

Examples of org.jboss.as.controller.ResultHandler

                            if(handler != null) {
                                // Create the attribute operation
                                final ModelNode attributeOperation = readOperation.clone();
                                attributeOperation.get(NAME).set(attributeName);
                                // TODO this assumes the ResultHandler is invoked synchronously
                                handler.execute(context, attributeOperation, new ResultHandler() {
                                    @Override
                                    public void handleResultFragment(final String[] location, final ModelNode attributeResult) {
                                        result.get(attributeName).set(attributeResult);
                                    }
                                    @Override
View Full Code Here

Examples of org.jboss.as.controller.ResultHandler

                            readOp.get(OP_ADDR).set(childAddress.toModelNode());

                            if(operation.hasDefined(INCLUDE_RUNTIME))
                                readOp.get(INCLUDE_RUNTIME).set(operation.get(INCLUDE_RUNTIME).asBoolean());

                            final ModelNode readResult = readModel(context, readOp, new ResultHandler() {
                                public void handleResultFragment(String[] location, ModelNode result) {
                                    // TODO
                                }
                                public void handleResultComplete() {
                                    // TODO
View Full Code Here

Examples of org.jboss.as.controller.ResultHandler

                for(final ProxyController proxy : proxies) {
                    final PathAddress proxyAddress = proxy.getProxyNodeAddress();
                    final ModelNode newOperation = operation.clone();
                    newOperation.get(OP_ADDR).set(address.subAddress(proxyAddress.size()).toModelNode());
                    final Operation operationContext = OperationBuilder.Factory.create(newOperation).build();
                    proxy.execute(operationContext, new ResultHandler() {
                        @Override
                        public void handleResultFragment(String[] location, ModelNode result) {
                            synchronized(failureResult) {
                                if(status.get() == 0) {
                                    // Addresses are aggregated as list by the controller
View Full Code Here

Examples of org.jboss.as.controller.ResultHandler

            final CountDownLatch completeLatch = new CountDownLatch(1);
            final IOExceptionHolder exceptionHolder = new IOExceptionHolder();
            final FailureHolder failureHolder = new FailureHolder();
            final AtomicInteger status = new AtomicInteger(0);

            OperationResult result = modelController.execute(builder.build(), new ResultHandler() {
                @Override
                public void handleResultFragment(String[] location, ModelNode fragment) {
                    try {
                        synchronized (outputStream) {
                            outputStream.write(ModelControllerClientProtocol.PARAM_HANDLE_RESULT_FRAGMENT);
View Full Code Here

Examples of org.jboss.as.controller.ResultHandler

        final ModelNodeRegistration hostRegistry = HostModelUtil.createHostRegistry(configurationPersister);

        // Load the host model
        final List<ModelNode> operations = configurationPersister.load();
        final AtomicInteger count = new AtomicInteger(1);
        final ResultHandler resultHandler = new ResultHandler() {
            @Override
            public void handleResultFragment(final String[] location, final ModelNode result) {
            }

            @Override
View Full Code Here

Examples of org.jboss.as.controller.ResultHandler

            log.error("failed to start domain controller", e);
            throw new StartException(e);
        }

        final AtomicInteger count = new AtomicInteger(1);
        final ResultHandler resultHandler = new ResultHandler() {
            @Override
            public void handleResultFragment(final String[] location, final ModelNode result) {
            }

            @Override
View Full Code Here

Examples of org.jboss.as.controller.ResultHandler

                for(final ProxyController proxy : proxies) {
                    final PathAddress proxyAddress = proxy.getProxyNodeAddress();
                    final ModelNode newOperation = operation.clone();
                    newOperation.get(OP_ADDR).set(address.subAddress(proxyAddress.size()).toModelNode());
                    final Operation operationContext = OperationBuilder.Factory.create(newOperation).build();
                    proxy.execute(operationContext, new ResultHandler() {
                        @Override
                        public void handleResultFragment(String[] location, ModelNode result) {
                            synchronized(failureResult) {
                                if(status.get() == 0) {
                                    // Addresses are aggregated as list by the controller
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.