Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.JellyTagException


        if (e instanceof LocationAware) {
            applyLocation((LocationAware) e);
        }

        throw new JellyTagException(e, fileName, elementName, columnNumber, lineNumber);
    }
View Full Code Here


    public void beforeSetAttributes() throws JellyTagException {
        // create a new dynabean before the attributes are set
        try {
            setDynaBean( beanClass.newInstance() );
        } catch (IllegalAccessException e) {
            throw new JellyTagException("Could not instantiate dynabean",e);
        } catch (InstantiationException e) {
            throw new JellyTagException("Could not instantiate dynabean",e);
        }

        setAttributesSet.clear();
    }
View Full Code Here

     */
    public Script script() throws JellyTagException {
        Script script = (Script) reference.get();
       
        if (script == null) {
            throw new JellyTagException("Attempt to use a script that has been garbage collected.");
        }
       
        return script;
    }
View Full Code Here

            assertNotNull(value);
        } else if(null != typeString) {
            try {
              klass = getClassLoader().loadClass(typeString);
            } catch (ClassNotFoundException e) {
                throw new JellyTagException(e);
            }
        } else if(null == value) { // and (by construction) null == typeString
            klass = Object.class;
        } else {
            klass = value.getClass();
        }

        if(!isInstanceOf(klass,value)) {
            if (klass.equals(Class.class))
            {
                try {
                    value = getClassLoader().loadClass((String) value);
                } catch (ClassNotFoundException e) {
                    throw new JellyTagException(e);
                }
            }
            else
            {
                value = convert(klass,value);
            }
        }

        ArgTagParent parent = (ArgTagParent)findAncestorWithClass(ArgTagParent.class);
        if(null == parent) {
            throw new JellyTagException("This tag must be enclosed inside an ArgTagParent implementation (for example, <new> or <invoke>)" );
        } else {
            parent.addArgument(klass,value);
        }
    }
View Full Code Here

    // private methods
    //-------------------------------------------------------------------------

    private void assertNotNull(Object value) throws JellyTagException {
        if(null == value) {
            throw new JellyTagException("A " + typeString + " instance cannot be null.");
        }
    }
View Full Code Here

        if(null == value) {
            return null;
        } else if(!klass.isInstance(value)) {
            Converter converter = (Converter)(converterMap.get(klass));
            if(null == converter) {
                throw new JellyTagException("Can't convert " + value + " to " + klass);
            } else {
                try {
                    return converter.convert(klass,value);
                } catch(ConversionException e) {
                    throw new JellyTagException("Can't convert " + value + " to " + klass + " (" + e.toString() + ")",e);
                }
            }
        } else {
            return value;
        }
View Full Code Here

        }
        catch (InvocationTargetException e) {
            if(null != exceptionVar) {
                context.setVariable(exceptionVar,e.getTargetException());
            } else {
                throw new JellyTagException("method " + methodName +
                    " threw exception: "+ e.getTargetException().getMessage(),
                    e.getTargetException() );
            }
        }
        finally {
View Full Code Here

     * failure exception
     * @param e is the exception which occurred attempting to load the class
     * @return JellyTagException
     */
    protected JellyTagException createLoadClassFailedException(Exception e) {
        return new JellyTagException(
            "Could not load class: " + className + ". Reason: " + e, e
        );
    }
View Full Code Here

        Object result = null;
        try {
            result = MethodUtils.invokeMethod(onInstance,methodName,values,types);
        }
        catch (NoSuchMethodException e) {
            throw new JellyTagException(e);
        }
        catch (IllegalAccessException e) {
            throw new JellyTagException(e);
        }
        catch (InvocationTargetException e) {
            if(null != exceptionVar) {
                context.setVariable(exceptionVar,e.getTargetException());
            } else {
                throw new JellyTagException("method " + methodName +
                    " threw exception: "+ e.getTargetException().getMessage(),
                    e.getTargetException() );
            }
        }
        finally {
View Full Code Here

    //-------------------------------------------------------------------------
    public void run(JellyContext context, XMLOutput output) throws JellyTagException {
        try {
            startNamespacePrefixes(output);
        } catch (SAXException e) {
            throw new JellyTagException("could not start namespace prefixes",e);
        }

        Tag tag = null;
        try {
            tag = getTag();

            // lets see if we have a dynamic tag
            if (tag instanceof StaticTag) {
                tag = findDynamicTag(context, (StaticTag) tag);
            }

            setTag(tag);
        } catch (JellyException e) {
            throw new JellyTagException(e);
        }

        URL rootURL = context.getRootURL();
        URL currentURL = context.getCurrentURL();
        try {
            if ( tag == null ) {
                return;
            }
            tag.setContext(context);
            setContextURLs(context);

            DynaTag dynaTag = (DynaTag) tag;

            // ### probably compiling this to 2 arrays might be quicker and smaller
            for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry) iter.next();
                String name = (String) entry.getKey();
                Expression expression = (Expression) entry.getValue();

                Object value = null;

                if ( Expression.class.isAssignableFrom( dynaTag.getAttributeType(name) ) ) {
                    value = expression;
                } else {
                    value = expression.evaluate(context);
                }

                dynaTag.setAttribute(name, value);
            }

            tag.doTag(output);
        }
        catch (JellyTagException e) {
            handleException(e);
        }
        catch (RuntimeException e) {
            handleException(e);
        } finally {
            context.setCurrentURL(currentURL);
            context.setRootURL(rootURL);
        }

        try {
            endNamespacePrefixes(output);
        } catch (SAXException e) {
            throw new JellyTagException("could not end namespace prefixes",e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.JellyTagException

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.