Refine search
public OGNLVariableExpressionEvaluator(final boolean applyOGNLShortcuts) { super(); this.applyOGNLShortcuts = applyOGNLShortcuts; /* * INITIALIZE AND REGISTER THE PROPERTY ACCESSOR */ final OGNLContextPropertyAccessor accessor = new OGNLContextPropertyAccessor(); OgnlRuntime.setPropertyAccessor(IContext.class, accessor); }
throw new OgnlException("source is null for getProperty(null, \"" + propertyName + "\")"); final Class<?> targetClass = OgnlRuntime.getTargetClass(target); final PropertyAccessor ognlPropertyAccessor = OgnlRuntime.getPropertyAccessor(targetClass);
public String toGetSourceString(OgnlContext context, Object target) Object value = _children[0].getValue(context, context.getRoot()); _getterClass = m.getReturnType(); Object indexedValue = OgnlRuntime.callMethod(context, target, m.getName(), new Object[]{value}); context.setCurrentType(_getterClass); context.setCurrentObject(indexedValue); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); PropertyAccessor p = OgnlRuntime.getPropertyAccessor(target.getClass()); if (ASTConst.class.isInstance(_children[0]) && Number.class.isInstance(context.getCurrentObject())) context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentObject().getClass())); PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(context.getCurrentObject().getClass(), name); throw new UnsupportedCompilationException("Member access forbidden for property " + name + " on class " + context.getCurrentObject().getClass()); m = OgnlRuntime.getReadMethod(context.getCurrentObject().getClass(), name); PropertyAccessor pa = OgnlRuntime.getPropertyAccessor(context.getCurrentObject().getClass()); pd = OgnlRuntime.getProperty(context.getCurrentObject().getClass(), name); context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass()));
private static Object getObjectProperty( final ICache<ExpressionCacheKey,Object> expressionCache, final String propertyName, final Object target) { final Class<?> currClass = OgnlRuntime.getTargetClass(target); final ExpressionCacheKey cacheKey = computeMethodCacheKey(currClass, propertyName); if (propertyDescriptors != null) { for (final PropertyDescriptor propertyDescriptor : propertyDescriptors) { if (propertyDescriptor.getName().equals(propertyName)) { readMethod = propertyDescriptor.getReadMethod(); if (readMethod != null && expressionCache != null) { expressionCache.put(cacheKey, readMethod);
Method m = null; Object value = _children[0].getValue(context, context.getRoot()); indexedValue = OgnlRuntime.callMethod(context, target, m.getName(), new Object[]{value}); context.setCurrentType(_setterClass); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); PropertyAccessor p = OgnlRuntime.getPropertyAccessor(target.getClass()); Object currObj = context.getCurrentObject(); if (ASTConst.class.isInstance(_children[0]) && Number.class.isInstance(context.getCurrentObject())) context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentObject().getClass())); PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(OgnlRuntime.getCompiler().getInterfaceClass(context.getCurrentObject().getClass()), name); Method pdMethod = lastChild(context) ? pd.getWriteMethod() : pd.getReadMethod(); m = OgnlRuntime.getWriteMethod(context.getCurrentObject().getClass(), name); Class parm = m.getParameterTypes()[0]; String cast = parm.isArray() ? ExpressionCompiler.getCastString(parm) : parm.getName(); PropertyAccessor pa = OgnlRuntime.getPropertyAccessor(context.getCurrentObject().getClass()); context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass()));
Map<String, PropertyDescriptor> descriptors = OgnlRuntime.getPropertyDescriptors(v.getClass()); for (PropertyDescriptor pd : descriptors.values()) { sb.append(pd.getName()).append(": "); int padding = maxSize - pd.getName().length(); for (int i = 0; i < padding; i++) { sb.append(" "); sb.append(pd.getPropertyType().getName()); set.add(sb.toString()); Object value = OgnlRuntime.callMethod((OgnlContext) context, o, name, objects); Throwable reason = e.getReason(); throw new MethodFailedException(o, name, e.getReason());
try { OgnlContext ogContext=(OgnlContext)context; if (OgnlRuntime.hasSetProperty(ogContext, object, string)) { PropertyDescriptor descriptor=OgnlRuntime.getPropertyDescriptor(object.getClass(), string); Class propertyType=descriptor.getPropertyType(); if ((Collection.class).isAssignableFrom(propertyType)) { Object propVal=OgnlRuntime.getProperty(ogContext, object, string); PropertyAccessor accessor=OgnlRuntime.getPropertyAccessor(Collection.class); ReflectionContextState.setGettingByKeyProperty(ogContext,true); return accessor.getProperty(ogContext,propVal,objects[0]);
public static Object getIndexedProperty(OgnlContext context, Object source, String name, Object index) throws OgnlException { Object[] args = _objectArrayPool.create(index); try { PropertyDescriptor pd = getPropertyDescriptor((source == null) ? null : source.getClass(), name); Method m; if (pd instanceof IndexedPropertyDescriptor) { m = ((IndexedPropertyDescriptor) pd).getIndexedReadMethod(); } else { if (pd instanceof ObjectIndexedPropertyDescriptor) { m = ((ObjectIndexedPropertyDescriptor) pd).getIndexedReadMethod(); } else { throw new OgnlException("property '" + name + "' is not an indexed property"); } } return callMethod(context, source, m.getName(), args); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException("getting indexed property descriptor for '" + name + "'", ex); } finally { _objectArrayPool.recycle(args); } }
protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren()); try { Object result, root = context.getRoot(); for(int i = 0, icount = args.length; i < icount; ++i) { args[i] = _children[i].getValue(context, root); } result = OgnlRuntime.callMethod(context, source, _methodName, args); if (result == null) { NullHandler nh = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source)); result = nh.nullMethodResult(context, source, _methodName, args); } return result; } finally { OgnlRuntime.getObjectArrayPool().recycle(args); } }
protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Node expr = _children[0]; List answer = new ArrayList(); ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor(OgnlRuntime.getTargetClass(source)); for(Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) { answer.add(expr.getValue(context, e.nextElement())); } return answer; }
OgnlRuntime.setPropertyAccessor(c.getSubjectClass(), c.getAccessor()); OgnlRuntime.setNullHandler(h.getSubjectClass(), h.getHandler()); OgnlRuntime.setCompiler(new HiveMindExpressionCompiler(_classFactory));
protected OGNLAttributeEvaluator createOGNLEvaluator() { try { PropertyAccessor objectPropertyAccessor = OgnlRuntime.getPropertyAccessor(Object.class); PropertyAccessor applicationContextPropertyAccessor = new NestedObjectDelegatePropertyAccessor<>( new TilesApplicationContextNestedObjectExtractor(), objectPropertyAccessor); PropertyAccessor anyScopePropertyAccessor = new AnyScopePropertyAccessor(); PropertyAccessor scopePropertyAccessor = new ScopePropertyAccessor(); PropertyAccessorDelegateFactory<Request> factory = new TilesContextPropertyAccessorDelegateFactory( objectPropertyAccessor, applicationContextPropertyAccessor, anyScopePropertyAccessor, scopePropertyAccessor); PropertyAccessor tilesRequestAccessor = new DelegatePropertyAccessor<>(factory); OgnlRuntime.setPropertyAccessor(Request.class, tilesRequestAccessor); return new OGNLAttributeEvaluator(); } catch (OgnlException e) { throw new TilesContainerFactoryException("Cannot initialize OGNL evaluator", e); } }
public OgnlFacade(Converters converters, EmptyElementsRemoval removal, Proxifier proxifier) { this.converters = converters; this.removal = removal; this.proxifier = proxifier; OgnlRuntime.setNullHandler(Object.class, new ReflectionBasedNullHandler(proxifier)); OgnlRuntime.setPropertyAccessor(List.class, new ListAccessor(converters)); OgnlRuntime.setPropertyAccessor(Object[].class, new ArrayAccessor()); }
PropertyAccessor acc = container.getInstance(PropertyAccessor.class, name); OgnlRuntime.setPropertyAccessor(cls, container.getInstance(PropertyAccessor.class, name)); if (compoundRootAccessor == null && CompoundRoot.class.isAssignableFrom(cls)) { compoundRootAccessor = (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, name); Class cls = Class.forName(name); if (cls != null) { OgnlRuntime.setMethodAccessor(cls, container.getInstance(MethodAccessor.class, name)); Class cls = Class.forName(name); if (cls != null) { OgnlRuntime.setNullHandler(cls, new OgnlNullHandlerWrapper(container.getInstance(NullHandler.class, name)));
public static void clearCache() { OgnlRuntime.clearCache(); clearOGNLCache("cacheGetMethod"); clearOGNLCache("cacheSetMethod"); }
protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object property = getProperty(context, source); Object result = OgnlRuntime.getProperty(context, source, property); if (result == null) { result = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source)).nullPropertyValue(context, source, property); } return result; }
public boolean shouldCreateIfNew(Class parentClass, String property, Object target, String keyProperty, boolean isIndexAccessed) { try { System.out.println("ognl:"+OgnlRuntime.getPropertyAccessor(Map.class)+" this:"+this); } catch (OgnlException e) { // TODO Auto-generated catch block e.printStackTrace(); } return isShouldCreateIfNew(); }
public void configureWOForOgnl() { // Configure runtime. // Configure foundation classes. OgnlRuntime.setPropertyAccessor(Object.class, new NSObjectPropertyAccessor()); OgnlRuntime.setPropertyAccessor(NSArray.class, new NSArrayPropertyAccessor()); OgnlRuntime.setPropertyAccessor(NSDictionary.class, new NSDictionaryPropertyAccessor()); NSFoundationElementsAccessor e = new NSFoundationElementsAccessor(); OgnlRuntime.setElementsAccessor(NSArray.class, e); OgnlRuntime.setElementsAccessor(NSDictionary.class, e); OgnlRuntime.setElementsAccessor(NSSet.class, e); // Register template parser if (hasProperty("ognl.active", "true")) { String parserClassName = System.getProperty("ognl.parserClassName", "ognl.helperfunction.WOHelperFunctionParser54"); WOComponentTemplateParser.setWOHTMLTemplateParserClassName(parserClassName); if (hasProperty("ognl.inlineBindings", "false")) { WOHelperFunctionTagRegistry.setAllowInlineBindings(true); } if (hasProperty("ognl.parseStandardTags", "false")) { WOHelperFunctionHTMLParser.setParseStandardTags(true); } if (hasProperty("ognl.debugSupport", "false")) { WOHelperFunctionParser._debugSupport = true; } } }
public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { ObjectProxy proxy = (ObjectProxy) target; setupContext(context, proxy); OgnlRuntime.getPropertyAccessor(proxy.getValue().getClass()).setProperty(context, target, name, value); }
/** * This method returns a PropertyDescriptor for the given class and property name using a Map * lookup (using getPropertyDescriptorsMap()). */ public static PropertyDescriptor getPropertyDescriptor(Class targetClass, String propertyName) throws IntrospectionException, OgnlException { if (targetClass == null) return null; return (PropertyDescriptor) getPropertyDescriptors(targetClass).get(propertyName); }