private ELEngine getELEngine() { if (elEngine == null) { if (ELExpressionFactory.isSupported()) { if (RuntimeUtils.isOSGi()) { ClassLoader classLoader = getClass().getClassLoader(); return new TcclELEngine(ELExpressionFactory.newInstance(classLoader), classLoader); } else { return new DefaultELEngine(ELExpressionFactory.newInstance()); } } else { return new NoopELEngine(); } } else { return elEngine; } }
/** * Constructs a {@link ExpressionFactory} via {@link Thread#getContextClassLoader() Thread.currentThread().getContextClassLoader()} * or the provided {@link ClassLoader} * * @param classLoader class loader to resolve {@link ExpressionFactory} * @return {@link ExpressionFactory} instance * @throws IllegalStateException if javax.el is not on the class path or a {@link ExpressionFactory} instance could not be constructed */ public static ExpressionFactory newInstance(ClassLoader classLoader) throws IllegalStateException { resolveClassForName(); return resolveViaClassLoaderOrTCCL(classLoader); }
/** * Checks whether javax.el is on the classpath and a {@link ExpressionFactory} can be constructed * * @param classLoader class loader to resolve {@link ExpressionFactory} * @return if javax.el can be used */ public static Boolean isSupported(ClassLoader classLoader) { if (isJavaxEL == null) { try { isJavaxEL = newInstance(classLoader) != null; LOG.info("javax.el support is {}", isJavaxEL); } catch (IllegalStateException ex) { LOG.warn("javax.el is not supported; {}", ex.getMessage()); isJavaxEL = false; } } return isJavaxEL; }
/** * Checks whether javax.el is on the classpath and a {@link ExpressionFactory} can be constructed * * @return if javax.el can be used */ public static Boolean isSupported() { return isSupported(ELExpressionFactory.class.getClassLoader()); }
private static ExpressionFactory resolveViaClassLoaderOrTCCL(ClassLoader classLoader) { ExpressionFactory answer; ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { ClassLoader newTccl = classLoader == null ? tccl : classLoader; Thread.currentThread().setContextClassLoader(newTccl); answer = newInstance(); } catch (ClassCastException ex) { throw new IllegalStateException("Failed to resolve ExpressionFactory, " + ex.getMessage(), ex); } finally { Thread.currentThread().setContextClassLoader(tccl); } return answer; }
/** * Checks whether javax.el is on the classpath and a {@link ExpressionFactory} can be constructed * * @return if javax.el can be used */ public static Boolean isSupported() { return isSupported(ELExpressionFactory.class.getClassLoader()); }
private ELEngine getELEngine() { if (elEngine == null) { if (ELExpressionFactory.isSupported()) { if (RuntimeUtils.isOSGi()) { ClassLoader classLoader = getClass().getClassLoader(); return new TcclELEngine(ELExpressionFactory.newInstance(classLoader), classLoader); } else { return new DefaultELEngine(ELExpressionFactory.newInstance()); } } else { return new NoopELEngine(); } } else { return elEngine; } }
private static ExpressionFactory resolveViaClassLoaderOrTCCL(ClassLoader classLoader) { ExpressionFactory answer; ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { ClassLoader newTccl = classLoader == null ? tccl : classLoader; Thread.currentThread().setContextClassLoader(newTccl); answer = newInstance(); } catch (ClassCastException ex) { throw new IllegalStateException("Failed to resolve ExpressionFactory, " + ex.getMessage(), ex); } finally { Thread.currentThread().setContextClassLoader(tccl); } return answer; }
/** * Constructs a {@link ExpressionFactory} via {@link Thread#getContextClassLoader() Thread.currentThread().getContextClassLoader()} * or the provided {@link ClassLoader} * * @param classLoader class loader to resolve {@link ExpressionFactory} * @return {@link ExpressionFactory} instance * @throws IllegalStateException if javax.el is not on the class path or a {@link ExpressionFactory} instance could not be constructed */ public static ExpressionFactory newInstance(ClassLoader classLoader) throws IllegalStateException { resolveClassForName(); return resolveViaClassLoaderOrTCCL(classLoader); }
private ELEngine createELEngine() { ELEngine answer; ClassLoader appcl = camelContext.getApplicationContextClassLoader(); ClassLoader auxcl = appcl == null ? DozerEndpoint.class.getClassLoader() : appcl; if (ELExpressionFactory.isSupported(auxcl)) { if (RuntimeUtils.isOSGi()) { answer = new TcclELEngine(ELExpressionFactory.newInstance(auxcl), auxcl); } else { answer = new DefaultELEngine(ELExpressionFactory.newInstance()); } } else { LOG.warn("Expressions are not supported by Dozer. Are you missing javax.el dependency?"); answer = new NoopELEngine(); } return answer; } }
/** * Checks whether javax.el is on the classpath and a {@link ExpressionFactory} can be constructed * * @param classLoader class loader to resolve {@link ExpressionFactory} * @return if javax.el can be used */ public static Boolean isSupported(ClassLoader classLoader) { if (isJavaxEL == null) { try { isJavaxEL = newInstance(classLoader) != null; LOG.info("javax.el support is {}", isJavaxEL); } catch (IllegalStateException ex) { LOG.warn("javax.el is not supported; {}", ex.getMessage()); isJavaxEL = false; } } return isJavaxEL; }