Examples of InvokeContext


Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    }

    public void testMultilevelSitemapVariables() throws PatternException {
        String expr = "from {../1} to {1}";
       
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

        Map sitemapElements;
        sitemapElements = new HashMap();
        sitemapElements.put("1", "juliet");
        context.pushMap("label1", sitemapElements);
       
        sitemapElements = new HashMap();
        sitemapElements.put("1", "oscar");
        context.pushMap("label2", sitemapElements);

        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("from juliet to oscar", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    }

    public void testRootSitemapVariables() throws PatternException {
        String expr = "from {/1} to {1}";
       
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

        Map sitemapElements;
        sitemapElements = new HashMap();
        sitemapElements.put("1", "juliet");
        context.pushMap("label1", sitemapElements);
       
        sitemapElements = new HashMap();
        sitemapElements.put("1", "oscar");
        context.pushMap("label2", sitemapElements);

        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("from juliet to oscar", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    }
   
    public void testColonInTextContent() throws PatternException {
        String expr = "http://cocoon.apache.org";
       
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

        Map sitemapElements;
        sitemapElements = new HashMap();
        context.pushMap("label", sitemapElements);
       
        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("http://cocoon.apache.org", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    }
   
    public void testColonBeginningTextContent() throws PatternException {
        String expr = ":colon-starts-this";
       
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

        Map sitemapElements;
        sitemapElements = new HashMap();
        context.pushMap("label", sitemapElements);
       
        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals(":colon-starts-this", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    }
   
    public void testEmbeddedColon() throws PatternException {
        String expr = "{1}:{1}";
       
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

        Map sitemapElements;
        sitemapElements = new HashMap();
        sitemapElements.put("1", "abc");
        context.pushMap("label", sitemapElements);
       
        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("abc:abc", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    }

    public void testEscapedBraces() throws PatternException {
        String expr = "This is a \\{brace\\}";
       
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

        Map sitemapElements;
        sitemapElements = new HashMap();
        context.pushMap("label", sitemapElements);

        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("This is a {brace}", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

        assertEquals("This is a {brace}", resolver.resolve(context, getObjectModel()));
    }

    public void testModuleWithoutOption() throws PatternException {
        String expr = "{baselink:}";
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));
       
        Map sitemapElements = new HashMap();
        context.pushMap("sitemap", sitemapElements);
        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    public boolean invokeErrorHandler(ProcessingNode node, Exception ex, Environment env)
    throws Exception {
    Map objectModel = env.getObjectModel();
   
        InvokeContext errorContext = null;
    boolean nodeSuccessfull = false;
   
        try {
          if (objectModel.get(Constants.NOTIFYING_OBJECT) == null) {
        // error has not been processed by another handler before
       
              // Try to reset the response to avoid mixing already produced output
              // and error page.
              env.tryResetResponse();
 
              // Create a Notifying
              NotifyingBuilder notifyingBuilder= (NotifyingBuilder)this.manager.lookup(NotifyingBuilder.ROLE);
              Notifying currentNotifying = null;
              try {
                  currentNotifying = notifyingBuilder.build(this, ex);
              } finally {
                  this.manager.release(notifyingBuilder);
              }
 
              // Add it to the object model
              objectModel.put(Constants.NOTIFYING_OBJECT, currentNotifying);
             
              // Also add the exception
              objectModel.put(ObjectModelHelper.THROWABLE_OBJECT, ex);
          }

      // Build a new context
      errorContext = new InvokeContext();
      errorContext.enableLogging(getLogger());
      errorContext.compose(this.manager);
     
      nodeSuccessfull = node.invoke(env, errorContext);
        } catch (Exception subEx) {
            getLogger().error("An exception occured in while handling errors at " + node.getLocation(), subEx);
            // Rethrow it : it will either be handled by the parent sitemap or by the environment (e.g. Cocoon servlet)
            throw subEx;
        } finally {
            if (errorContext != null) {
                errorContext.dispose();
            }
        }
       
        if (nodeSuccessfull) {
          return true;
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

     */
    public String locate(String hint, Map om) throws Exception {

        String location = null;

        final InvokeContext context = new InvokeContext();
        final Logger contextLogger = getLogger().getChildLogger("ctx");

        ContainerUtil.enableLogging(context, contextLogger);
        ContainerUtil.service(context, m_manager);

        final Map anchorMap = new HashMap(2);
        anchorMap.put(HINT_KEY,hint);
        context.pushMap(ANCHOR_NAME,anchorMap);

        //mounted locations first
        if (m_mountNodes != null) {
          for (int i = 0; i < m_mountNodes.length; i++) {
            location = m_mountNodes[i].locate(om,context);
View Full Code Here

Examples of org.apache.cocoon.components.treeprocessor.InvokeContext

    }

    private boolean invokeErrorHandler(ProcessingNode node, Exception ex, Environment env)
      throws Exception {

        InvokeContext errorContext = null;

        try {
            // Try to reset the response to avoid mixing already produced output
            // and error page.
            env.tryResetResponse();

            // Build a new context
            errorContext = new InvokeContext();
            errorContext.setLogger(getLogger());
            errorContext.compose(this.manager);

            // Create a Notifying
            NotifyingBuilder notifyingBuilder= (NotifyingBuilder)this.manager.lookup(NotifyingBuilder.ROLE);
            Notifying currentNotifying = notifyingBuilder.build(this, ex);
            this.manager.release(notifyingBuilder);

            // Add it to the object model
            env.getObjectModel().put(Constants.NOTIFYING_OBJECT, currentNotifying );

            // notifying-generator is added in HandleErrorsNode
            return node.invoke(env, errorContext);

        } catch (Exception subEx) {
            getLogger().error("error notifier barfs", subEx);
            return false;

        } finally {
            if (errorContext != null) {
                errorContext.dispose();
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.