Package org.apache.commons.chain

Examples of org.apache.commons.chain.Command


        actionCtx.setException(exception);

        // Execute the specified command
        try {
            Command command = lookupExceptionCommand();

            if (command == null) {
                LOG.error("Cannot find exceptionCommand '" + exceptionCommand
                    + "'");
                throw new IllegalStateException(
                    "Cannot find exceptionCommand '" + exceptionCommand + "'");
            }

            if (LOG.isTraceEnabled()) {
                LOG.trace("Calling exceptionCommand '" + exceptionCommand + "'");
            }

            command.execute(context);
        } catch (Exception e) {
            LOG.warn("Exception from exceptionCommand '" + exceptionCommand
                + "'", e);
            throw new IllegalStateException("Exception chain threw exception");
        }
View Full Code Here


        throws Exception {
        if (LOG.isTraceEnabled()) {
            LOG.trace("execute [" + this + "]");
        }

        Command command = getCommand(context);

        if (command != null) {
            return command.execute(getContext(context));
        } else {
            return false;
        }
    }
View Full Code Here

     * @param context   Our ActionContext
     * @param exception The Exception thrown by another Comamnd in a Chain
     * @return TRUE if there is a Filter to process
     */
    public boolean postprocess(Context context, Exception exception) {
        Command command = getCommand(context);

        if ((command != null) && (command instanceof Filter)) {
            try {
                return ((Filter) command).postprocess(getContext(context),
                    exception);
View Full Code Here

        if (catalog == null) {
            throw new IllegalArgumentException("Cannot find catalog '"
                + catalogName + "'");
        }

        Command command;
        String name = getName();

        if (name == null) {
            name = (String) context.get(getNameKey());
        }
View Full Code Here

     * @throws Exception on any error
     */
    public boolean execute(ActionContext actionCtx)
        throws Exception {
        if (shouldProcess(actionCtx)) {
            Command command = getCommand(actionCtx);

            if (command != null) {
                return (command.execute(actionCtx));
            }
        }

        return (false);
    }
View Full Code Here

    // Test getting commands
    public void testGetCommand() {

        addCommands();
        Command command = null;

        command = catalog.getCommand("AddingCommand");
        assertNotNull(command);
        assertTrue(command instanceof AddingCommand);
View Full Code Here

    // Test the ability to add commands
    public void testCommands() {

        checkCommandCount(0);

        Command command1 = new NonDelegatingCommand("1");
        chain.addCommand(command1);
        checkCommandCount(1);

        Command command2 = new DelegatingCommand("2");
        chain.addCommand(command2);
        checkCommandCount(2);

        Command command3 = new ExceptionCommand("3");
        chain.addCommand(command3);
        checkCommandCount(3);

    }
View Full Code Here


    // Verify the number of configured commands
    protected void checkCommandCount(int expected) {
        if (chain instanceof ChainBase) {
            Command commands[] = ((ChainBase) chain).getCommands();
            assertNotNull("getCommands() returned a non-null array",
                          commands);
            assertEquals("Correct command count", expected, commands.length);
        }
    }
View Full Code Here

        Object top = digester.peek(0);
        if ((top == null)
            || !(top instanceof Command)) {
            return;
        }
        Command command = (Command) top;

        // Is the next object a Catalog or a Chain?
        Object next = digester.peek(1);
        if (next == null) {
            return;
View Full Code Here

            servletPath = request.getServletPath();
        }

        // Map to the Command specified by the extra path info
        Catalog catalog = (Catalog) context.get(getCatalogKey());
        Command command = catalog.getCommand(servletPath);
        return (command.execute(context));

    }
View Full Code Here

TOP

Related Classes of org.apache.commons.chain.Command

Copyright © 2018 www.massapicom. 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.