Examples of InvokeContext


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 nodeSuccesfull = 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);
     
      nodeSuccesfull = 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 (nodeSuccesfull) {
          return true;
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

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

        try {
            prepare(context, env, ex);

            // Create error context
            InvokeContext errorContext = new InvokeContext(context.isBuildingPipelineOnly());
            errorContext.enableLogging(getLogger());
            errorContext.setRedirector(context.getRedirector());
            errorContext.compose(this.manager);
            try {
                // Process error handling node
                if (node.invoke(env, errorContext)) {
                    // Exception was handled.
                    return errorContext.getProcessingPipeline();
                }
            } finally {
                errorContext.dispose();
            }
        } catch (Exception e) {
            getLogger().error("An exception occured while handling errors at " + node.getLocation(), e);
            // Rethrow it: It will either be handled by the parent sitemap or by the environment (e.g. Cocoon servlet)
            throw e;
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 nodeSuccessful = 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);
     
      nodeSuccessful = node.invoke(env, errorContext);
        } catch (Exception subEx) {
            getLogger().error("An exception occured 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 (nodeSuccessful) {
          return true;
View Full Code Here

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

        String expr = "{request-param:{request-param:foo}}";
        MockRequest request = getRequest();
        request.reset();
        request.addParameter("foo", "bar");
        request.addParameter("bar", "123");
        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("123", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

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

    public void testNestedModuleAndSitemapExpressions() throws PatternException, ComponentException {
        String expr = "{request-param:f{1}}";
        MockRequest request = getRequest();
        request.reset();
        request.addParameter("foo", "123");
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));
       
        Map sitemapElements = new HashMap();
        sitemapElements.put("1", "oo");
        context.pushMap("sitemap", sitemapElements);
        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("123", resolver.resolve(context, getObjectModel()));
    }
View Full Code Here

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

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

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

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

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

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

    }

    public void testSitemapVariablesWithText() throws PatternException {
        String expr = "123{1}/def";
   
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

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

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

    }
   
    public void testPrefixedSitemapVariable() throws PatternException {
        String expr = "123{sitemap:1}/def";
   
        InvokeContext context = new InvokeContext(true);
        context.enableLogging(new LogKitLogger(getLogger()));

        Map sitemapElements = new HashMap();
        sitemapElements.put("1", "abc");
        context.pushMap("label", sitemapElements);
        PreparedVariableResolver resolver = new PreparedVariableResolver(expr, manager);
        assertEquals("123abc/def", resolver.resolve(context, getObjectModel()));
    }
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.