Package org.apache.commons.chain

Examples of org.apache.commons.chain.Catalog


    /**
     * <p>Test <code>getCatalog()</code> method.</p>
     */
    public void testCatalogIdentifier() {

        Catalog defaultCatalog = new CatalogBase();
        Command defaultFoo = new NonDelegatingCommand();
        defaultCatalog.addCommand("foo", defaultFoo);
        Command fallback = new NonDelegatingCommand();
        defaultCatalog.addCommand("noSuchCatalog:fallback", fallback);

        factory.setCatalog(defaultCatalog);

        Catalog specificCatalog = new CatalogBase();
        Command specificFoo = new NonDelegatingCommand();
        specificCatalog.addCommand("foo", specificFoo);
        factory.addCatalog("specific", specificCatalog);

        Command command = factory.getCommand("foo");
        assertSame(defaultFoo, command);

View Full Code Here


     *  can be found
     *
     * @since Chain 1.2
     */
    protected Catalog getCatalog(Context context) {
        Catalog catalog = (Catalog) context.get(getCatalogKey());
        if (catalog == null) {
            catalog = super.getCatalog(context);
        }
        return catalog;
    }
View Full Code Here

                        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 = CatalogFactory.getInstance().getCatalog(catalog);
        } else {
            theCatalog = CatalogFactory.getInstance().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

    /**
     * <p>Test the default {@link Catalog} instance.</p>
     */
    public void testDefaultCatalog() {

        Catalog catalog = new CatalogBase();
        factory.setCatalog(catalog);
        assertTrue(catalog == factory.getCatalog());
        assertEquals(0, getCatalogCount());

    }
View Full Code Here

    /**
     * <p>Test adding a specifically named {@link Catalog} instance.</p>
     */
    public void testSpecificCatalog() {

        Catalog catalog = new CatalogBase();
        factory.setCatalog(catalog);
        catalog = new CatalogBase();
        factory.addCatalog("foo", catalog);
        assertTrue(catalog == factory.getCatalog("foo"));
        assertEquals(1, getCatalogCount());
View Full Code Here

    /**
     * <p>Test <code>getCatalog()</code> method.</p>
     */
    public void testCatalogIdentifier() {

        Catalog defaultCatalog = new CatalogBase();
        Command defaultFoo = new NonDelegatingCommand();
        defaultCatalog.addCommand("foo", defaultFoo);
        Command fallback = new NonDelegatingCommand();
        defaultCatalog.addCommand("noSuchCatalog:fallback", fallback);

        factory.setCatalog(defaultCatalog);

        Catalog specificCatalog = new CatalogBase();
        Command specificFoo = new NonDelegatingCommand();
        specificCatalog.addCommand("foo", specificFoo);
        factory.addCatalog("specific", specificCatalog);

        Command command = factory.getCommand("foo");
        assertSame(defaultFoo, command);

View Full Code Here

            context.getInitParameter(CONFIG_CLASS_RESOURCE);
        String ruleSet = context.getInitParameter(RULE_SET);
        String webResources = context.getInitParameter(CONFIG_WEB_RESOURCE);

        // Retrieve or create the Catalog instance we may be updating
        Catalog catalog = null;
        if (attr != null) {
            catalog = (Catalog) context.getAttribute(attr);
            if (catalog == null) {
                catalog = new CatalogBase();
            }
View Full Code Here

            context.getInitParameter(CONFIG_CLASS_RESOURCE);
        String ruleSet = context.getInitParameter(RULE_SET);
        String webResources = context.getInitParameter(CONFIG_WEB_RESOURCE);

        // Retrieve or create the Catalog instance we may be updating
        Catalog catalog = null;
        if (attr != null) {
            catalog = (Catalog) context.getAttribute(attr);
            if (catalog == null) {
                catalog = new CatalogBase();
            }
View Full Code Here

        ServletWebContext swcontext = (ServletWebContext) context;
        HttpServletRequest request = swcontext.getRequest();
        String value = request.getParameter(getParameter());

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

    }
View Full Code Here

        if (pathInfo == null) {
            pathInfo = request.getPathInfo();
        }

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

    }
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.