Refine search
/** * Retrieves the <code>ImportHandler</code> associated with this * <code>ELContext</code>. * * @return The import handler to manage imports of classes and packages. * @since EL 3.0 */ public ImportHandler getImportHandler() { if (importHandler == null) { importHandler = new ImportHandler(); } return importHandler; }
/** * Import a class. The imported class must be loadable from the classloader * at the expression evaluation time. * @param className The full class name of the class to be imported * @throws ELException if the name is not a full class name. */ public void importClass(String className) throws ELException { getELContext().getImportHandler().importClass(className); }
/** * Import a package. At the expression evaluation time, the imported package * name will be used to construct the full class name, which will then be * used to load the class. Inherently, this is less efficient than * importing a class. * @param packageName The package name to be imported */ public void importPackage(String packageName) { getELContext().getImportHandler().importPackage(packageName); }
private Class<?> resolveClassFor(String className) { Class<?> c = classMap.get(className); if (c != null) { return c; } c = getClassFor(className); if (c != null) { checkModifiers(c.getModifiers()); classMap.put(className, c); } return c; }
/** * Import a static field or method. The class of the static member must be * loadable from the classloader, at class resolution time. * @param staticMemberName The full class name of the class to be imported * @throws ELException if the name is not a full class name. */ public void importStatic(String staticMemberName) throws ELException { getELContext().getImportHandler().importStatic(staticMemberName); }
@Override public ImportHandler getImportHandler() { if (importHandler == null) { importHandler = new ImportHandler(); if (jspTag instanceof JspSourceImports) { Set<String> packageImports = ((JspSourceImports) jspTag).getPackageImports(); if (packageImports != null) { for (String packageImport : packageImports) { importHandler.importPackage(packageImport); } } Set<String> classImports = ((JspSourceImports) jspTag).getClassImports(); if (classImports != null) { for (String classImport : classImports) { importHandler.importClass(classImport); } } } } return importHandler; }
result = ctx.getImportHandler().resolveClass(this.image); if (result != null) { return new ELClass((Class<?>) result); result = ctx.getImportHandler().resolveStatic(this.image); if (result != null) { try {
@Override public Class<?> run() { return importHandler.resolveClass(klassName); } });
/** * Resolve a static field or method name. * * @param name The name of the member(without package and class name) * to be resolved. * @return If the field or method has been imported previously, with * {@link #importStatic}, then the class object representing the class that * declares the static field or method. * Otherwise <code>null</code>. * @throws ELException if the class is not public, or is abstract or * is an interface. */ public Class<?> resolveStatic(String name) { String className = staticNameMap.get(name); if (className != null) { Class<?> c = resolveClassFor(className); if (c != null) { return c; } } return null; }
Class<?> clazz = context.getImportHandler().resolveClass(className); manager.mapFunction(prefix, function, method); return; } else { manager.mapFunction(prefix, function, method); return;
public ImportHandler() { importPackage("java.lang"); }
@Override public Object getValue(EvaluationContext ctx) throws ELException { // First check if this is a lambda argument if (ctx.isLambdaArgument(this.image)) { return ctx.getLambdaArgument(this.image); } VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getValue(ctx.getELContext()); } } ctx.setPropertyResolved(false); Object ret = ctx.getELResolver().getValue(ctx, null, this.image); if (! ctx.isPropertyResolved()) { // Check if this is an imported static field if (ctx.getImportHandler() != null) { Class<?> c = ctx.getImportHandler().resolveStatic(this.image); if (c != null) { return ctx.getELResolver().getValue(ctx, new ELClass(c), this.image); } } ELSupport.throwUnhandled(null, this.image); } return ret; }
/** * Import a static field or method. The class of the static member must be * loadable from the classloader, at class resolution time. * @param staticMemberName The full class name of the class to be imported * @throws ELException if the name is not a full class name. */ public void importStatic(String staticMemberName) throws ELException { getELContext().getImportHandler().importStatic(staticMemberName); }
private Class<?> resolveClassFor(String className) { Class<?> c = classMap.get(className); if (c != null) { return c; } c = getClassFor(className); if (c != null) { checkModifiers(c.getModifiers()); classMap.put(className, c); } return c; }
result = ctx.getImportHandler().resolveClass(this.image); if (result != null) { return new ELClass((Class<?>) result); result = ctx.getImportHandler().resolveStatic(this.image); if (result != null) { try {
klass = importHandler.resolveClass(klassName);
/** * Resolve a class name. * * @param name The name of the class (without package name) to be resolved. * @return If the class has been imported previously, with * {@link #importClass} or {@link #importPackage}, then its * Class instance. Otherwise <code>null</code>. * @throws ELException if the class is abstract or is an interface, or * not public. */ public Class<?> resolveClass(String name) { String className = classNameMap.get(name); if (className != null) { return resolveClassFor(className); } for (String packageName: packages) { String fullClassName = packageName + "." + name; Class<?>c = resolveClassFor(fullClassName); if (c != null) { classNameMap.put(name, fullClassName); return c; } } return null; }
@Override public Object getValue(EvaluationContext ctx) throws ELException { // First check if this is a lambda argument if (ctx.isLambdaArgument(this.image)) { return ctx.getLambdaArgument(this.image); } VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getValue(ctx.getELContext()); } } ctx.setPropertyResolved(false); Object ret = ctx.getELResolver().getValue(ctx, null, this.image); if (! ctx.isPropertyResolved()) { // Check if this is an imported static field if (ctx.getImportHandler() != null) { Class<?> c = ctx.getImportHandler().resolveStatic(this.image); if (c != null) { return ctx.getELResolver().getValue(ctx, new ELClass(c), this.image); } } ELSupport.throwUnhandled(null, this.image); } return ret; }
/** * Import a class. The imported class must be loadable from the classloader * at the expression evaluation time. * @param className The full class name of the class to be imported * @throws ELException if the name is not a full class name. */ public void importClass(String className) throws ELException { getELContext().getImportHandler().importClass(className); }
/** * Import a package. At the expression evaluation time, the imported package * name will be used to construct the full class name, which will then be * used to load the class. Inherently, this is less efficient than * importing a class. * @param packageName The package name to be imported */ public void importPackage(String packageName) { getELContext().getImportHandler().importPackage(packageName); }