Package org.apache.commons.chain

Examples of org.apache.commons.chain.Catalog


                        HttpServletResponse response)
        throws IOException, ServletException {

        ServletWebContext context =
            new ServletWebContext(getServletContext(), request, response);
        Catalog theCatalog = null;
        if (attribute != null) {
            theCatalog = (Catalog) getServletContext().getAttribute
                (this.attribute);
        } else if (catalog != null) {
            theCatalog = factory.getCatalog(catalog);
        } else {
            theCatalog = factory.getCatalog();
        }
        if (attribute == null) {
            request.setAttribute(CATALOG_DEFAULT, theCatalog);
        }
        Command command = theCatalog.getCommand(this.command);
        try {
            command.execute(context);
        } catch (Exception e) {
            throw new ServletException(e);
        }
View Full Code Here


        if (servletPath == null) {
            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

        if (lookupFactory == null) {
            lookupFactory = CatalogFactory.getInstance();
        }

        String catalogName = getCatalogName();
        Catalog catalog = null;
        if (catalogName == null) {
            // use default catalog
            catalog = lookupFactory.getCatalog();
        } else {
            catalog = lookupFactory.getCatalog(catalogName);
        }
        if (catalog == null) {
            if (catalogName == null) {
                throw new IllegalArgumentException
                    ("Cannot find default catalog");
            } else {
                throw new IllegalArgumentException
                    ("Cannot find catalog '" + catalogName + "'");
            }
        }

        Command command = null;
        String name = getName();
        if (name == null) {
            name = (String) context.get(getNameKey());
        }
        if (name != null) {
            command = catalog.getCommand(name);
            if ((command == null) && !isOptional()) {
                if (catalogName == null) {
                    throw new IllegalArgumentException
                        ("Cannot find command '" + name
                         + "' in default catalog");
View Full Code Here

     */
    public void begin(String namespace, String name, Attributes attributes)
        throws Exception {

        // Retrieve any current Catalog with the specified name
        Catalog catalog = null;
        CatalogFactory factory = CatalogFactory.getInstance();
        String nameValue = attributes.getValue(nameAttribute);
        if (nameValue == null) {
            catalog = factory.getCatalog();
        } else {
View Full Code Here

        }
        context.put(getExceptionKey(), exception);

        // Execute the specified command
        try {
            Catalog catalog = (Catalog)
                context.get(getCatalogKey());
            Command command = catalog.getCommand(getExceptionCommand());
            if (log.isTraceEnabled()) {
                log.trace("Calling handler command '" + getExceptionCommand()
                          + "'");
            }
            command.execute(context);
View Full Code Here

     */
    public void init(ActionServlet servlet, ModuleConfig config)
        throws ServletException {

        // Retrieve or create the Catalog instance we will be updating
        Catalog catalog = (Catalog)
            servlet.getServletContext().getAttribute(Constants.CATALOG_ATTR);
        if (catalog == null) {
            log.info("Creating new Catalog instance");
            catalog = new CatalogBase();
            servlet.getServletContext().setAttribute(Constants.CATALOG_ATTR,
View Full Code Here

        context.put(getExceptionKey(), exception);

        // Execute the specified command
        try {
            String catalogName = getCatalogName();
            Catalog catalog = null;
            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");
            }
            Command command = catalog.getCommand(exceptionCommand);
            if (command == null) {
                log.error("Cannot find exceptionCommand '" +
                          exceptionCommand + "'");
                throw new IllegalStateException
                    ("Cannot find exceptionCommand '" +
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

   * @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

   * @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

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.