Package org.apache.commons.jexl2.introspection

Examples of org.apache.commons.jexl2.introspection.Uberspect


    public Object invokeMethod(Object obj, String meth, Object... args) {
        JexlException xjexl = null;
        Object result = null;
        JexlInfo info = debugInfo();
        try {
            JexlMethod method = uberspect.getMethod(obj, meth, args, info);
            if (method == null && arithmetic.narrowArguments(args)) {
                method = uberspect.getMethod(obj, meth, args, info);
            }
            if (method != null) {
                result = method.invoke(obj, args);
            } else {
                xjexl = new JexlException(info, "failed finding method " + meth);
            }
        } catch (Exception xany) {
            xjexl = new JexlException(info, "failed executing method " + meth, xany);
View Full Code Here


        }
        // attempt to reuse last executor cached in volatile JexlNode.value
        if (node != null && cache) {
            Object cached = node.jjtGetValue();
            if (cached instanceof JexlPropertyGet) {
                JexlPropertyGet vg = (JexlPropertyGet) cached;
                Object value = vg.tryInvoke(object, attribute);
                if (!vg.tryFailed(value)) {
                    return value;
                }
            }
        }
        JexlPropertyGet vg = uberspect.getPropertyGet(object, attribute, node);
        if (vg != null) {
            try {
                Object value = vg.invoke(object);
                // cache executor in volatile JexlNode.value
                if (node != null && cache && vg.isCacheable()) {
                    node.jjtSetValue(vg);
                }
                return value;
            } catch (Exception xany) {
                if (node == null) {
View Full Code Here

    protected void setAttribute(Object object, Object attribute, Object value, JexlNode node) {
        // attempt to reuse last executor cached in volatile JexlNode.value
        if (node != null && cache) {
            Object cached = node.jjtGetValue();
            if (cached instanceof JexlPropertySet) {
                JexlPropertySet setter = (JexlPropertySet) cached;
                Object eval = setter.tryInvoke(object, attribute, value);
                if (!setter.tryFailed(eval)) {
                    return;
                }
            }
        }
        JexlException xjexl = null;
        JexlPropertySet vs = uberspect.getPropertySet(object, attribute, value, node);
        if (vs != null) {
            try {
                // cache executor in volatile JexlNode.value
                vs.invoke(object, value);
                if (node != null && cache && vs.isCacheable()) {
                    node.jjtSetValue(vs);
                }
                return;
            } catch (RuntimeException xrt) {
                if (node == null) {
View Full Code Here

    }

    // JEXL-52: can be implemented by deriving Interpreter.{g,s}etAttribute; later
    public void test52base() throws Exception {
        JexlEngine jexl = new JexlEngine();
        Uberspect uber = jexl.getUberspect();
        // most likely, call will be in an Interpreter, getUberspect
        String[] names = ((Introspector) uber).getMethodNames(Another.class);
        assertTrue("should find methods", names.length > 0);
        int found = 0;
        for (String name : names) {
View Full Code Here

    }

    // JEXL-52: can be implemented by deriving Interpreter.{g,s}etAttribute; later
    public void test52base() throws Exception {
        JexlEngine jexl = new JexlEngine();
        Uberspect uber = jexl.getUberspect();
        // most likely, call will be in an Interpreter, getUberspect
        String[] names = ((Introspector) uber).getMethodNames(Another.class);
        assertTrue("should find methods", names.length > 0);
        int found = 0;
        for (String name : names) {
View Full Code Here

    }

    // JEXL-52: can be implemented by deriving Interpreter.{g,s}etAttribute; later
    public void test52base() throws Exception {
        JexlEngine jexl = createEngine(false);
        Uberspect uber = jexl.getUberspect();
        // most likely, call will be in an Interpreter, getUberspect
        String[] names = ((Introspector) uber).getMethodNames(Another.class);
        assertTrue("should find methods", names.length > 0);
        int found = 0;
        for (String name : names) {
View Full Code Here

        result = script.execute(null);
        assertEquals("42", ((Foo) result).getName());

        Sandbox sandbox = new Sandbox();
        sandbox.black(Foo.class.getName()).execute("");
        Uberspect uber = new SandboxUberspectImpl(null, sandbox);
        JexlEngine sjexl = new JexlEngine(uber, null, null, null);
        sjexl.setStrict(true);

        script = sjexl.createScript(expr);
        try {
View Full Code Here

        result = script.execute(null, foo);
        assertEquals(foo.Quux(), result);

        Sandbox sandbox = new Sandbox();
        sandbox.black(Foo.class.getName()).execute("Quux");
        Uberspect uber = new SandboxUberspectImpl(null, sandbox);
        JexlEngine sjexl = new JexlEngine(uber, null, null, null);
        sjexl.setStrict(true);

        script = sjexl.createScript(expr, "foo");
        try {
View Full Code Here

        result = script.execute(null, foo);
        assertEquals(foo.alias, result);

        Sandbox sandbox = new Sandbox();
        sandbox.black(Foo.class.getName()).read("alias");
        Uberspect uber = new SandboxUberspectImpl(null, sandbox);
        JexlEngine sjexl = new JexlEngine(uber, null, null, null);
        sjexl.setStrict(true);

        script = sjexl.createScript(expr, "foo");
        try {
View Full Code Here

        result = script.execute(null, foo, "43");
        assertEquals("43", result);

        Sandbox sandbox = new Sandbox();
        sandbox.black(Foo.class.getName()).write("alias");
        Uberspect uber = new SandboxUberspectImpl(null, sandbox);
        JexlEngine sjexl = new JexlEngine(uber, null, null, null);
        sjexl.setStrict(true);

        script = sjexl.createScript(expr, "foo", "$0");
        try {
View Full Code Here

TOP

Related Classes of org.apache.commons.jexl2.introspection.Uberspect

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.