use of org.apache.geode.cache.query.NameNotFoundException in project geode by apache.
the class CompiledSelect method getFieldTypeOfProjAttrib.
private ObjectType getFieldTypeOfProjAttrib(ExecutionContext context, CompiledValue cv) throws TypeMismatchException, AmbiguousNameException {
// Identify the RuntimeIterator for the compiled value
ObjectType retType = TypeUtils.OBJECT_TYPE;
try {
RuntimeIterator rit = context.findRuntimeIterator(cv);
List pathOnItr = cv.getPathOnIterator(rit, context);
if (pathOnItr != null) {
String[] path = (String[]) pathOnItr.toArray(new String[pathOnItr.size()]);
ObjectType[] ot = PathUtils.calculateTypesAlongPath(rit.getElementType(), path);
retType = ot[ot.length - 1];
}
} catch (NameNotFoundException ignore) {
// Unable to determine the type Of attribute.It will default to
// ObjectType
}
return retType;
}
use of org.apache.geode.cache.query.NameNotFoundException in project geode by apache.
the class AttributeDescriptor method getReadMember.
Member getReadMember(Class targetClass) throws NameNotFoundException {
// mapping: public field (same name), method (getAttribute()),
// method (attribute())
List key = new ArrayList();
key.add(targetClass);
key.add(_name);
Member m = (Member) _cache.get(key);
if (m != null)
return m;
m = getReadField(targetClass);
if (m == null)
m = getReadMethod(targetClass);
if (m != null)
_cache.putIfAbsent(key, m);
else
throw new NameNotFoundException(LocalizedStrings.AttributeDescriptor_NO_PUBLIC_ATTRIBUTE_NAMED_0_WAS_FOUND_IN_CLASS_1.toLocalizedString(new Object[] { _name, targetClass.getName() }));
// override security for nonpublic derived classes with public members
((AccessibleObject) m).setAccessible(true);
return m;
}
use of org.apache.geode.cache.query.NameNotFoundException in project geode by apache.
the class AttributeDescriptor method readReflection.
// used when the resolution of an attribute must be on a superclass
// instead of the runtime class
private Object readReflection(Object target) throws NameNotFoundException, QueryInvocationTargetException {
Support.Assert(target != null);
Support.Assert(target != QueryService.UNDEFINED);
if (target instanceof Token) {
return QueryService.UNDEFINED;
}
Class resolutionClass = target.getClass();
Member m = getReadMember(resolutionClass);
try {
if (m instanceof Method) {
try {
return ((Method) m).invoke(target, (Object[]) null);
} catch (EntryDestroyedException e) {
// eat the Exception
return QueryService.UNDEFINED;
} catch (IllegalAccessException e) {
throw new NameNotFoundException(LocalizedStrings.AttributeDescriptor_METHOD_0_IN_CLASS_1_IS_NOT_ACCESSIBLE_TO_THE_QUERY_PROCESSOR.toLocalizedString(new Object[] { m.getName(), target.getClass().getName() }), e);
} catch (InvocationTargetException e) {
// if the target exception is Exception, wrap that,
// otherwise wrap the InvocationTargetException itself
Throwable t = e.getTargetException();
if ((t instanceof EntryDestroyedException)) {
// eat the exception
return QueryService.UNDEFINED;
}
if (t instanceof Exception)
throw new QueryInvocationTargetException(t);
throw new QueryInvocationTargetException(e);
}
} else {
try {
return ((Field) m).get(target);
} catch (IllegalAccessException e) {
throw new NameNotFoundException(LocalizedStrings.AttributeDescriptor_FIELD_0_IN_CLASS_1_IS_NOT_ACCESSIBLE_TO_THE_QUERY_PROCESSOR.toLocalizedString(new Object[] { m.getName(), target.getClass().getName() }), e);
} catch (EntryDestroyedException e) {
return QueryService.UNDEFINED;
}
}
} catch (EntryDestroyedException e) {
// eat the exception
return QueryService.UNDEFINED;
}
}
Aggregations