Example usage for org.apache.commons.jxpath JXPathIntrospector registerDynamicClass

List of usage examples for org.apache.commons.jxpath JXPathIntrospector registerDynamicClass

Introduction

In this page you can find the example usage for org.apache.commons.jxpath JXPathIntrospector registerDynamicClass.

Prototype

public static void registerDynamicClass(Class beanClass, Class dynamicPropertyHandlerClass) 

Source Link

Document

Automatically creates and registers a JXPathBeanInfo object for the specified class.

Usage

From source file:org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.java

public void initialize() throws Exception {
    if (enableDebugger) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Flow debugger enabled, creating");
        }//  w  w w  .  j  a v  a  2s  .  c o m
        getDebugger().doBreak();
    }
    Context context = Context.enter();
    context.setOptimizationLevel(OPTIMIZATION_LEVEL);
    context.setCompileFunctionsWithDynamicScope(true);
    context.setGeneratingDebug(true);
    // add support for Rhino objects to JXPath
    JXPathIntrospector.registerDynamicClass(Scriptable.class, ScriptablePropertyHandler.class);
    JXPathContextReferenceImpl.addNodePointerFactory(new ScriptablePointerFactory());

    try {
        scope = new Global(context);
        // Access to Cocoon internal objects
        FOM_Cocoon.init(scope);
        errorReporter = new JSErrorReporter(getLogger());
    } catch (Exception e) {
        Context.exit();
        e.printStackTrace();
        throw e;
    }
}

From source file:org.geotools.xml.impl.jxpath.JXPathStreamingParserHandler.java

protected boolean stream(ElementHandler handler) {
    //create an xpath context from the root element
    // TODO: cache the context, should work just the same
    //        JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class,
    //            ElementHandlerPropertyHandler.class);
    JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class);

    //        ElementHandler rootHandler = 
    //           ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler();
    Node root = ((DocumentHandler) handlers.firstElement()).getParseNode();
    JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root);

    jxpContext.setLenient(true);/*w  w w .  ja  v  a  2  s . c o m*/

    Iterator itr = jxpContext.iterate(xpath);

    for (; itr.hasNext();) {
        Object obj = itr.next();

        if (handler.getParseNode().equals(obj)) {
            return true;
        }
    }

    return false;
}

From source file:org.geotools.xml.impl.jxpath.JXPathTest.java

protected void setUp() throws Exception {
    ElementImpl e = new ElementImpl(null);
    e.setName("root");
    root = new NodeImpl(e);

    e = new ElementImpl(null);
    e.setName("child");
    child1 = new NodeImpl(e);
    //root.addChild( child1 );
    e = new ElementImpl(null);
    e.setName("child");
    child2 = new NodeImpl(e);
    //root.addChild( child2 );
    JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class);

    context = JXPathContextFactory.newInstance().newContext(null, root);
}

From source file:org.onecmdb.core.utils.xpath.model.OneCMDBContext.java

public OneCMDBContext(Map<String, Object> context, ISession session) {
    this.session = session;
    this.context = context;
    // Register Dynamic Handlers.
    JXPathIntrospector.registerDynamicClass(IDynamicHandler.class, OneCMDBContextHandler.class);

}