Package org.apache.commons.chain

Examples of org.apache.commons.chain.Catalog


     * @return commons chains customizations catalog
     * @exception Exception finding customizations catalog
     */
    protected Catalog getCustomizationCatalog() throws Exception {

        Catalog catalog = CatalogFactory.getInstance().getCatalog(
                Globals.CLAY_CUSTOMIZATION_CATALOG_NAME);

        return catalog;
    }
View Full Code Here


                    ClayContext subContext = (ClayContext) clayContext.clone();
                    subContext.setDisplayElement(actionListener);
                    subContext.setParent(child);

                    Catalog catalog = getCatalog();
                    Command command = catalog
                            .getCommand(Globals.ADD_ACTION_LISTENER_COMMAND_NAME);
                    command.execute(subContext);

                }
            } else {
View Full Code Here

            subContext.setParent(parent);
            subContext.setChild(null);
            subContext.setChildIndex(childIndex);
            subContext.setJspIds(clayContext.getJspIds());

            Catalog catalog = getCatalog();
            Command command = catalog
                    .getCommand(Globals.ADD_COMPONENT_COMMAND_NAME);
            command.execute(subContext);

            UIComponent child = (UIComponent) subContext.getChild();
View Full Code Here

            throw new NullPointerException(getMessages()
                    .getMessage("clay.null.componentBean"));
        }

        Iterator ai = displayElement.getAttributeIterator();
        Catalog defaultCatalog = getCatalog();
        Catalog customizationCatalog = getCustomizationCatalog();

        Command defaultCommand = defaultCatalog.getCommand(Globals.SET_ATTRIBUTE_COMMAND_NAME);
        next: while (ai.hasNext()) {
            AttributeBean a = (AttributeBean) ai.next();
            if (a.getValue() == null) {
               continue next;
            }

            Command command = null;
            //look for a command override in the customization catalog first
            if (customizationCatalog != null) {
                command = customizationCatalog.getCommand(a.getName());
            }
            //look for a command override in the defaut catalog
            if (command == null) {
               command = defaultCatalog.getCommand(a.getName());
            }
View Full Code Here

                    ClayContext subContext = (ClayContext) clayContext.clone();
                    subContext.setDisplayElement(validator);
                    subContext.setParent(child);

                    Catalog catalog = getCatalog();
                    Command command = catalog
                            .getCommand(Globals.ADD_VALIDATOR_COMMAND_NAME);
                    command.execute(subContext);

                }
            } else {
View Full Code Here

                ClayContext subContext = (ClayContext) clayContext.clone();
                subContext.setDisplayElement(displayElement.getConverter());
                subContext.setParent(child);

                Catalog catalog = getCatalog();
                Command command = catalog
                        .getCommand(Globals.ADD_CONVERTER_COMMAND_NAME);
                command.execute(subContext);

            } else {
                log.error(getMessages().getMessage("assign.converter.error",
View Full Code Here

     */
    private Catalog getCatalog() throws Exception {

        // Look up the "shale" catalog, returning any existing instance
        // if it is fully configured
        Catalog catalog = CatalogFactory.getInstance().getCatalog(CATALOG_NAME);
        if ((catalog != null) &&
            (catalog.getCommand(COMMAND_INIT) != null) &&
            (catalog.getCommand(COMMAND_DESTROY) != null)) {
            return catalog;
        }

        // Create a new catalog (if necessary)
        if (catalog == null) {
View Full Code Here

    protected Command getCommand(String commandName, String catalogName) {
        if (commandName == null) {
            return null;
        }

        Catalog catalog;

        if (catalogName != null) {
            catalog = CatalogFactory.getInstance().getCatalog(catalogName);

            if (catalog == null) {
                LOG.warn("When looking up " + commandName + ","
                    + " no catalog found under " + catalogName);

                return null;
            }
        } else {
            catalogName = "the default catalog";
            catalog = CatalogFactory.getInstance().getCatalog();

            if (catalog == null) {
                LOG.warn("When looking up " + commandName + ","
                    + " no default catalog found.");

                return null;
            }
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("looking up command " + commandName + " in "
                + catalogName);
        }

        return catalog.getCommand(commandName);
    }
View Full Code Here

     * @return The Command to process for this Context
     */
    protected Command getCommand(Context context) {
        CatalogFactory catalogFactory = CatalogFactory.getInstance();
        String catalogName = getCatalogName();
        Catalog catalog;

        if (catalogName == null) {
            catalog = catalogFactory.getCatalog();
            catalogName = "{default}"; // for debugging purposes
        } else {
            catalog = catalogFactory.getCatalog(catalogName);
        }

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

        Command command;
        String name = getName();

        if (name == null) {
            name = (String) context.get(getNameKey());
        }

        if (name != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Lookup command " + name + " in catalog "
                    + catalogName);
            }

            command = catalog.getCommand(name);

            if (LOG.isDebugEnabled()) {
                LOG.debug("Found command " + command + ";" + " optional: "
                    + isOptional());
            }
View Full Code Here

     * @throws IllegalArgumentException If catalog cannot be found
     * @throws IllegalStateException    If command property is not specified
     */
    protected Command lookupExceptionCommand() {
        String catalogName = getCatalogName();
        Catalog catalog;

        if (catalogName == null) {
            catalog = CatalogFactory.getInstance().getCatalog();

            if (catalog == null) {
                LOG.error("Cannot find default catalog");
                throw new IllegalArgumentException(
                    "Cannot find default catalog");
            }
        } else {
            catalog = CatalogFactory.getInstance().getCatalog(catalogName);

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

        String exceptionCommand = getExceptionCommand();

        if (exceptionCommand == null) {
            LOG.error("No exceptionCommand property specified");
            throw new IllegalStateException(
                "No exceptionCommand property specfied");
        }

        return catalog.getCommand(exceptionCommand);
    }
View Full Code Here

TOP

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

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.