Search in sources :

Example 1 with NameNotFoundException

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;
}
Also used : ObjectType(org.apache.geode.cache.query.types.ObjectType) NameNotFoundException(org.apache.geode.cache.query.NameNotFoundException) ArrayList(java.util.ArrayList) List(java.util.List) PdxString(org.apache.geode.pdx.internal.PdxString)

Example 2 with NameNotFoundException

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;
}
Also used : NameNotFoundException(org.apache.geode.cache.query.NameNotFoundException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AccessibleObject(java.lang.reflect.AccessibleObject) Member(java.lang.reflect.Member)

Example 3 with NameNotFoundException

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;
    }
}
Also used : EntryDestroyedException(org.apache.geode.cache.EntryDestroyedException) NameNotFoundException(org.apache.geode.cache.query.NameNotFoundException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) Token(org.apache.geode.internal.cache.Token) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) PdxSerializationException(org.apache.geode.pdx.PdxSerializationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) NameNotFoundException(org.apache.geode.cache.query.NameNotFoundException) EntryDestroyedException(org.apache.geode.cache.EntryDestroyedException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) Field(java.lang.reflect.Field) AccessibleObject(java.lang.reflect.AccessibleObject) Member(java.lang.reflect.Member)

Aggregations

NameNotFoundException (org.apache.geode.cache.query.NameNotFoundException)3 AccessibleObject (java.lang.reflect.AccessibleObject)2 Member (java.lang.reflect.Member)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 EntryDestroyedException (org.apache.geode.cache.EntryDestroyedException)1 QueryInvocationTargetException (org.apache.geode.cache.query.QueryInvocationTargetException)1 ObjectType (org.apache.geode.cache.query.types.ObjectType)1 Token (org.apache.geode.internal.cache.Token)1 PdxSerializationException (org.apache.geode.pdx.PdxSerializationException)1 PdxString (org.apache.geode.pdx.internal.PdxString)1