Package org.apache.velocity.context

Examples of org.apache.velocity.context.InternalContextAdapterImpl


        /*
         * now we want to init and render
         */

        if (nodeTree != null) {
            InternalContextAdapterImpl ica =
                new InternalContextAdapterImpl(context);

            ica.pushCurrentTemplateName(logTag);

            try {
                try {
                    nodeTree.init(ica, ri);
                }
                catch (TemplateInitException pex) {
                    throw new ParseErrorException(pex);
                }
                /**
                 * pass through application level runtime exceptions
                 */
                catch (RuntimeException e) {
                    throw e;
                }
                catch (Exception e) {
                    getLog().error("Velocity.evaluate() : init exception for tag = "
                        + logTag, e);
                }

                /*
                 *  now render, and let any exceptions fly
                 */

                nodeTree.render(ica, writer);
            }
            finally {
                ica.popCurrentTemplateName();
            }

            return true;
        }

View Full Code Here


        /*
         * now we want to init and render
         */

        if (nodeTree != null) {
            InternalContextAdapterImpl ica =
                new InternalContextAdapterImpl(context);

            ica.pushCurrentTemplateName(logTag);

            try {
                try {
                    nodeTree.init(ica, ri);
                }
                catch (TemplateInitException pex) {
                    throw new ParseErrorException(pex);
                }
                /**
                 * pass through application level runtime exceptions
                 */
                catch (RuntimeException e) {
                    throw e;
                }
                catch (Exception e) {
                    getLog().error("Velocity.evaluate() : init exception for tag = "
                        + logTag, e);
                }

                /*
                 *  now render, and let any exceptions fly
                 */

                nodeTree.render(ica, writer);
            }
            finally {
                ica.popCurrentTemplateName();
            }

            return true;
        }

View Full Code Here

     * @param writer The writer to which the merged template will be written.
     * @throws IOException thrown when the merging fails.
     */
    public void merge(Context context, Writer writer) throws IOException {

        InternalContextAdapterImpl ica = new InternalContextAdapterImpl(context);

        ica.pushCurrentTemplateName(name);

        try {

            node.render(ica, writer);

        } catch (IOException ioe) {
            logger.error("Could not merge veloctiy template '" + name + "'", ioe);
            throw ioe;
        } finally {
            ica.popCurrentTemplateName();
        }
    }
View Full Code Here

     * @param node The node to initialize.
     * @param ri The velcotiy runtime instance that will be used while initilizing.
     * @param name A name to be associated with the template to be used in log messages.
     */
    protected static void init(SimpleNode node, ExtendedRuntimeInstance ri, String name) {
        InternalContextAdapterImpl ica = new InternalContextAdapterImplnew VelocityContext() );
        try {

            ica.pushCurrentTemplateName( name );
            node.init(ica, ri);

        } finally {
            ica.popCurrentTemplateName();
        }
    }
View Full Code Here

                          String logTag, SimpleNode nodeTree) throws IOException
    {
        /*
         * we want to init then render
         */
        InternalContextAdapterImpl ica =
            new InternalContextAdapterImpl(context);

        ica.pushCurrentTemplateName(logTag);

        try
        {
            try
            {
                nodeTree.init(ica, this);
            }
            catch (TemplateInitException pex)
            {
                throw new ParseErrorException(pex);
            }
            /**
             * pass through application level runtime exceptions
             */
            catch(RuntimeException e)
            {
                throw e;
            }
            catch(Exception e)
            {
                String msg = "RuntimeInstance.render(): init exception for tag = "+logTag;
                getLog().error(msg, e);
                throw new VelocityException(msg, e);
            }

            /*
             *  now render, and let any exceptions fly
             */
            nodeTree.render(ica, writer);
        }
        finally
        {
            ica.popCurrentTemplateName();
        }

        return true;
    }
View Full Code Here

                          String logTag, SimpleNode nodeTree) throws IOException
    {
        /*
         * we want to init then render
         */
        InternalContextAdapterImpl ica =
            new InternalContextAdapterImpl(context);

        ica.pushCurrentTemplateName(logTag);

        try
        {
            try
            {
                nodeTree.init(ica, this);
            }
            catch (TemplateInitException pex)
            {
                throw new ParseErrorException(pex);
            }
            /**
             * pass through application level runtime exceptions
             */
            catch(RuntimeException e)
            {
                throw e;
            }
            catch(Exception e)
            {
                String msg = "RuntimeInstance.render(): init exception for tag = "+logTag;
                getLog().error(msg, e);
                throw new VelocityException(msg, e);
            }

            /*
             *  now render, and let any exceptions fly
             */
            nodeTree.render(ica, writer);
        }
        finally
        {
            ica.popCurrentTemplateName();
        }

        return true;
    }
View Full Code Here

         * now we want to init and render
         */

        if (nodeTree != null)
        {
            InternalContextAdapterImpl ica =
                new InternalContextAdapterImpl( context );
           
            ica.pushCurrentTemplateName( logTag );
           
            try
            {
                try
                {
                    nodeTree.init( ica, ri );
                }
                catch( Exception e )
                {
                    ri.error("Velocity.evaluate() : init exception for tag = "
                                  + logTag + " : " + e );
                }
               
                /*
                 *  now render, and let any exceptions fly
                 */

                nodeTree.render( ica, writer );
            }
            finally
            {
                ica.popCurrentTemplateName();
            }
           
            return true;
        }
       
View Full Code Here

         * now we want to init and render
         */

        if (nodeTree != null)
        {
            InternalContextAdapterImpl ica =
                new InternalContextAdapterImpl( context );
           
            ica.pushCurrentTemplateName( logTag );
           
            try
            {
                try
                {
                    nodeTree.init( ica, RuntimeSingleton.getRuntimeServices() );
                }
                catch( Exception e )
                {
                    RuntimeSingleton.error("Velocity.evaluate() : init exception for tag = "
                                  + logTag + " : " + e );
                }
               
                /*
                 *  now render, and let any exceptions fly
                 */

                nodeTree.render( ica, writer );
            }
            finally
            {
                ica.popCurrentTemplateName();
            }
           
            return true;
        }
       
View Full Code Here

         if we found something, render
         */

        if( sn != null)
        {
            InternalContextAdapterImpl ica =
                new InternalContextAdapterImpl( context );

            ica.pushCurrentTemplateName( node.name() );

            try
            {
                sn.render( ica, writer );
            }
            finally
            {
                ica.popCurrentTemplateName();
            }

            return true;
        }

View Full Code Here

    VelocityContext context = new VelocityContext(new HashMap<String, Object>(
        map));
    // 进行临时的输出, 成功才真正的返回得到的结果
    StringWriter out = new StringWriter();

    InternalContextAdapterImpl ica = new InternalContextAdapterImpl(context);
    node.init(ica, engine);
    node.render(ica, out);

    // 回写指定的参数
    if (names != null) {
View Full Code Here

TOP

Related Classes of org.apache.velocity.context.InternalContextAdapterImpl

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.