Search in sources :

Example 1 with ExpressionElementReader

use of org.dozer.loader.xml.ExpressionElementReader in project camel by apache.

the class DozerEndpoint method initELEngine.

public void initELEngine() {
    String elprop = System.getProperty("javax.el.ExpressionFactory");
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    try {
        ClassLoader appcl = getCamelContext().getApplicationContextClassLoader();
        ClassLoader auxcl = appcl != null ? appcl : DozerEndpoint.class.getClassLoader();
        Thread.currentThread().setContextClassLoader(auxcl);
        try {
            Class<?> clazz = auxcl.loadClass("com.sun.el.ExpressionFactoryImpl");
            ExpressionFactory factory = (ExpressionFactory) clazz.newInstance();
            System.setProperty("javax.el.ExpressionFactory", factory.getClass().getName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
            LOG.debug("Cannot load glasfish expression engine, using default");
        }
        ELEngine engine = new ELEngine();
        engine.init();
        BeanContainer.getInstance().setElEngine(engine);
        ElementReader reader = new ExpressionElementReader(engine);
        BeanContainer.getInstance().setElementReader(reader);
    } finally {
        Thread.currentThread().setContextClassLoader(tccl);
        if (elprop != null) {
            System.setProperty("javax.el.ExpressionFactory", elprop);
        } else {
            System.clearProperty("javax.el.ExpressionFactory");
        }
    }
}
Also used : ExpressionFactory(javax.el.ExpressionFactory) ExpressionElementReader(org.dozer.loader.xml.ExpressionElementReader) ELEngine(org.dozer.loader.xml.ELEngine) ElementReader(org.dozer.loader.xml.ElementReader) ExpressionElementReader(org.dozer.loader.xml.ExpressionElementReader)

Aggregations

ExpressionFactory (javax.el.ExpressionFactory)1 ELEngine (org.dozer.loader.xml.ELEngine)1 ElementReader (org.dozer.loader.xml.ElementReader)1 ExpressionElementReader (org.dozer.loader.xml.ExpressionElementReader)1