public void begin()

in configuration/xml/src/main/java/org/apache/commons/chain2/config/xml/ConfigRegisterRule.java [72:108]


    public void begin(String namespace, String name, Attributes attributes) throws Exception {
        // Is the top object a Command?
        Object top = getDigester().peek(0);
        if ((top == null)
            || !(top instanceof Command)) {
            return;
        }

        /* All commands can consume a generic context. Here we depend on
         * the configuration being correct because the rule binding is
         * dynamic. */
        Command<Object, Object, Map<Object, Object>> command =
                (Command<Object, Object, Map<Object, Object>>) top;

        // Is the next object a Catalog or a Chain?
        Object next = getDigester().peek(1);
        if (next == null) {
            return;
        }

        // Register the top element appropriately
        if (next instanceof Catalog) {
            String nameValue = attributes.getValue(nameAttribute);
            if (nameValue != null) {
                /* We are dynamically building a catalog and assigning
                 * generics to the most base types possible. */
                Catalog<Object, Object, Map<Object, Object>> catalog =
                        (Catalog<Object, Object, Map<Object, Object>>) next;
                catalog.addCommand(nameValue, command);
            }
        } else if (next instanceof Chain) {
            /* Like above - the chain is being dynamically generated,
             * so we can add a generic context signature at compile-time. */
            Chain<Object, Object, Map<Object, Object>> chain = (Chain<Object, Object, Map<Object, Object>>) next;
            chain.addCommand(command);
        }
    }