public final void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { String aname = attribute.getName(); Object avalue = attribute.getValue(); try { setAttribute0(aname, avalue); } catch (AttributeNotFoundException e) { // Do nothing } catch (Exception e) { throwMBeanException(e); } PropertyDescriptor pdesc = propertyDescriptors.get(aname); if (pdesc == null) { throwMBeanException(new IllegalArgumentException("Unknown attribute: " + aname)); } try { PropertyEditor e = getPropertyEditor(getParent(aname).getClass(), pdesc.getName(), pdesc.getPropertyType()); e.setAsText((String) avalue); OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(source); ctx.setTypeConverter(typeConverter); Ognl.setValue(aname, ctx, source, e.getValue()); } catch (Exception e) { throwMBeanException(e); } }
e.setAsText((String) avalue); OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(source); ctx.setTypeConverter(typeConverter); Ognl.setValue(aname, ctx, source, e.getValue()); } catch (Throwable e) {
private Object getAttribute(Object object, String fqan, Class<?> attrType) throws OgnlException { Object property; OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(object); ctx.setTypeConverter(new OgnlTypeConverter()); if (attrType == null) { property = Ognl.getValue(fqan, ctx, object); } else { property = Ognl.getValue(fqan, ctx, object, attrType); } return property; }
private Object getAttribute(Object object, String fqan, Class<?> attrType) throws OgnlException { Object property; OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(object); ctx.setTypeConverter(new OgnlTypeConverter()); if (attrType == null) { property = Ognl.getValue(fqan, ctx, object); } else { property = Ognl.getValue(fqan, ctx, object, attrType); } return property; }
if (key.equals(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY)) { result = getTypeConverter(); setTypeConverter(null); } else { if (key.equals(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY)) {
/** * Finds a {@link Set} of {@link IoSession}s that matches the query * from the specified sessions and returns the matches. * @throws OgnlException if failed to evaluate the OGNL expression */ public Set<IoSession> find(Iterable<IoSession> sessions) throws OgnlException { if (sessions == null) { throw new NullPointerException("sessions"); } Set<IoSession> answer = new LinkedHashSet<>(); for (IoSession s: sessions) { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(s); context.setTypeConverter(typeConverter); context.put(AbstractPropertyAccessor.READ_ONLY_MODE, true); context.put(AbstractPropertyAccessor.QUERY, query); Object result = Ognl.getValue(expression, context, s); if (result instanceof Boolean) { if ((Boolean) result) { answer.add(s); } } else { throw new OgnlException( "Query didn't return a boolean value: " + query); } } return answer; } }
if (key.equals(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY)) { result = getTypeConverter(); setTypeConverter((TypeConverter)value); } else { if (key.equals(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY)) {
public void clear() { values.clear(); setRoot(null); setCurrentObject(null); setRootEvaluation(null); setCurrentEvaluation(null); setLastEvaluation(null); setCurrentNode(null); setClassResolver(DEFAULT_CLASS_RESOLVER); setTypeConverter(DEFAULT_TYPE_CONVERTER); setMemberAccess(DEFAULT_MEMBER_ACCESS); }
/** * Appends the standard naming context for evaluating an OGNL expression * into the context given so that cached maps can be used as a context. * * @param root the root of the object graph * @param context the context to which OGNL context will be added. * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE> * set appropriately */ public static Map addDefaultContext( Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess, Map context ) { OgnlContext result; if (!(context instanceof OgnlContext)) { result = new OgnlContext(); result.setValues(context); } else { result = (OgnlContext)context; } if (classResolver != null) { result.setClassResolver(classResolver); } if (converter != null) { result.setTypeConverter(converter); } if (memberAccess != null) { result.setMemberAccess(memberAccess); } result.setRoot(root); return result; }