Package org.apache.velocity.app.event

Examples of org.apache.velocity.app.event.EventCartridge


        Writer writer = new BufferedWriter(new OutputStreamWriter(System.out));

        Context context = new VelocityContext();

        EventCartridge ec = new EventCartridge();
        ec.addEventHandler(this);
        ec.attachToContext( context );

        template1.merge(context, writer);
        writer.flush();
        writer.close();
    }
View Full Code Here


    private void initializeEventHandlers()
        throws Exception
    {

        eventCartridge = new EventCartridge();

        /**
         * For each type of event handler, get the class name, instantiate it, and store it.
         */

 
View Full Code Here

            throw new IllegalStateException("Have not call nextEntry method yet");
        }

        final Map descriptorProps = new HashMap(currentGenerate.getConfigDescriptor().getContext());

        EventCartridge eventCartridge = new EventCartridge();
        eventCartridge.addEventHandler(new PropertiesReferenceInsertionHandler(currentGenerate.getConfigDescriptor(),
                props));

        Context context = new AbstractContext() {
            @Override
            public Object internalRemove(Object key) {
                return descriptorProps.remove(key);
            }

            @Override
            public Object internalPut(String key, Object value) {
                return descriptorProps.put(key, value);
            }

            @Override
            public Object[] internalGetKeys() {
                Set<Object> keys = new LinkedHashSet<Object>(props.keySet());
                keys.addAll(descriptorProps.keySet());
                return keys.toArray(new Object[keys.size()]);
            }

            @Override
            public Object internalGet(String key) {
                if (descriptorProps.containsKey(key)) {
                    return descriptorProps.get(key);
                } else {
                    return PropertiesLoader.evaluate(key, props);
                }
            }

            @Override
            public boolean internalContainsKey(Object key) {
                return descriptorProps.containsKey(key) || props.containsKey(key);
            }
        };

        eventCartridge.attachToContext(context); // ����ʹ��${a.b.c}
        context.put("D", "$"); // ������${D}������$

        return context;
    }
View Full Code Here

            /*
             *  first, are we supposed to say anything anyway?
             */
            if(blather)
            {
                EventCartridge ec = context.getEventCartridge();

                boolean doit = true;
              
                /*
                 *  if we have an EventCartridge...
                 */
                if (ec != null)
                {
                    doit = ec.shouldLogOnNullSet( left.literal(), right.literal() );
                }

                if (doit)
                {
                    rsvc.error("RHS of #set statement is null. Context will not be modified. "
View Full Code Here

        {
            return method.invoke(o, null)
        }
        catch( InvocationTargetException ite )
        {
            EventCartridge ec = context.getEventCartridge();

            /*
             *  if we have an event cartridge, see if it wants to veto
             *  also, let non-Exception Throwables go...
             */

            if ( ec != null && ite.getTargetException() instanceof java.lang.Exception)
            {
                try
                {
                    return ec.methodException( o.getClass(), methodUsed, (Exception)ite.getTargetException() );
                }
                catch( Exception e )
                {
                    throw new MethodInvocationException(
                      "Invocation of method '" + methodUsed + "'"
View Full Code Here

             *  wrap it, and throw.  We don't log here as we want to figure
             *  out which reference threw the exception, so do that
             *  above
             */

            EventCartridge ec = context.getEventCartridge();

            /*
             *  if we have an event cartridge, see if it wants to veto
             *  also, let non-Exception Throwables go...
             */

            if ( ec != null && ite.getTargetException() instanceof java.lang.Exception)
            {
                try
                {
                    return ec.methodException( o.getClass(), methodName, (Exception)ite.getTargetException() );
                }
                catch( Exception e )
                {
                    throw new MethodInvocationException(
                        "Invocation of method '"
View Full Code Here

         *  the normal processing
         *
         *  if we have an event cartridge, get a new value object
         */

        EventCartridge ec = context.getEventCartridge();

        if (ec != null)
        {
            value =  ec.referenceInsert( nullString, value );
        }

        /*
         *  if value is null...
         */
 
View Full Code Here

            /*
             *  event cartridge stuff
             */

            EventCartridge ec = new EventCartridge();
            ec.addEventHandler(this);
            ec.attachToContext( context );

            /*
             *  make a writer, and merge the template 'against' the context
             */

 
View Full Code Here

         *  Now make an event cartridge, register the
         *  input event handler and attach it to the
         *  Context
         */

        EventCartridge ec = new EventCartridge();
        ec.addEventHandler(this);
        ec.attachToContext( context );


        // BEHAVIOR A: pass through #input and #parse with no change
        EventHandlerBehavior = PASS_THROUGH;

View Full Code Here

        /**
         * @see org.apache.velocity.context.InternalContextAdapter#attachEventCartridge(org.apache.velocity.app.event.EventCartridge ec)
         */
        public EventCartridge attachEventCartridge(EventCartridge ec)
        {
            EventCartridge cartridge = innerContext.attachEventCartridge( ec );

            return cartridge;
        }
View Full Code Here

TOP

Related Classes of org.apache.velocity.app.event.EventCartridge

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.