Package com.buschmais.xo.api

Examples of com.buschmais.xo.api.XOException


    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (datastoreType == null) {
            throw new XOException("Invalid access to an un-managed instance.");
        }
        return proxyMethodService.invoke(datastoreType, proxy, method, args);
    }
View Full Code Here


                    ImplementedByMethodMetadata implementedByMethodMetadata = (ImplementedByMethodMetadata) methodMetadata;
                    Class<? extends ProxyMethod> proxyMethodType = implementedByMethodMetadata.getProxyMethodType();
                    try {
                        addProxyMethod(proxyMethodType.newInstance(), typeMethod.getAnnotatedElement());
                    } catch (InstantiationException e) {
                        throw new XOException("Cannot instantiate proxy method of type " + proxyMethodType.getName(), e);
                    } catch (IllegalAccessException e) {
                        throw new XOException("Unexpected exception while instantiating type " + proxyMethodType.getName(), e);
                    }
                }
                if (methodMetadata instanceof ResultOfMethodMetadata) {
                    ResultOfMethodMetadata resultOfMethodMetadata = (ResultOfMethodMetadata) methodMetadata;
                    addProxyMethod(new ResultOfMethod(sessionContext, resultOfMethodMetadata), typeMethod.getAnnotatedElement());
View Full Code Here

        } else if (List.class.isAssignableFrom(collectionPropertyMetadata.getAnnotatedMethod().getType())) {
            collection = new ListProxy<>(collectionProxy);
        } else if (Collection.class.isAssignableFrom(collectionPropertyMetadata.getAnnotatedMethod().getType())) {
            collection = collectionProxy;
        } else {
            throw new XOException("Unsupported collection type " + collectionPropertyMetadata.getAnnotatedMethod().getType());
        }
        return sessionContext.getInterceptorFactory().addInterceptor(collection);
    }
View Full Code Here

                if (rowProxyMethodService != null) {
                    RowInvocationHandler invocationHandler = new RowInvocationHandler(row, rowProxyMethodService);
                    return (T) sessionContext.getProxyFactory().createInstance(invocationHandler, returnTypes.toArray(new Class<?>[0]), CompositeRowObject.class);
                }
                if (row.size() != 1) {
                    throw new XOException("Only single columns per row can be returned.");
                }
                return (T) row.values().iterator().next();
            }

            @Override
View Full Code Here

    public Object invoke(Map<String, Object> row, Object instance, Object[] args) throws Exception {
        if (row.size() == 1) {
            Class<?> type = (Class) args[0];
            Object value = row.values().iterator().next();
            if (value != null && !type.isAssignableFrom(value.getClass())) {
                throw new XOException("Cannot cast value of type '" + value.getClass() + "' to '" + type + "'.");
            }
            return value;
        }
        throw new XOException("The row contains more than one column.");
    }
View Full Code Here

     * @param methods    The map of methods.
     */
    private void evaluateMethod(Object listener, Class<? extends Annotation> annotation, Method method, Map<Object, Set<Method>> methods) {
        if (method.isAnnotationPresent(annotation)) {
            if (method.getParameterTypes().length != 1) {
                throw new XOException("Life cycle method '" + method.toGenericString() + "' annotated with '" + annotation.getName() + "' must declare exactly one parameter but declares " + method.getParameterTypes().length + ".");
            }
            Set<Method> listenerMethods = methods.get(listener);
            if (listenerMethods == null) {
                listenerMethods = new HashSet<>();
                methods.put(listener, listenerMethods);
View Full Code Here

                    Class<?> parameterType = method.getParameterTypes()[0];
                    if (parameterType.isAssignableFrom(instance.getClass())) {
                        try {
                            method.invoke(listener, instance);
                        } catch (IllegalAccessException e) {
                            throw new XOException("Cannot access instance listener method " + method.toGenericString(), e);
                        } catch (InvocationTargetException e) {
                            throw new XOException("Cannot invoke instance listener method " + method.toGenericString(), e);
                        }
                    }
                }
            }
        }
View Full Code Here

    public TypeMetadataSet<RelationTypeMetadata<RelationMetadata>> getRelationTypes(Set<EntityDiscriminator> sourceDiscriminators, RelationDiscriminator discriminator, Set<EntityDiscriminator> targetDiscriminators) {
        TypeMetadataSet<RelationTypeMetadata<RelationMetadata>> types = new TypeMetadataSet<>();
        Set<RelationMapping<EntityDiscriminator, RelationMetadata, RelationDiscriminator>> relations = relationMappings.get(discriminator);
        if (relations == null) {
            throw new XOException("Cannot resolve relation from discriminator '" + discriminator + "'");
        }
        for (RelationMapping<EntityDiscriminator, RelationMetadata, RelationDiscriminator> relation : relations) {
            EntityDiscriminator source = relation.getSource();
            EntityDiscriminator target = relation.getTarget();
            if (sourceDiscriminators.contains(source) && targetDiscriminators.contains(target)) {
View Full Code Here

                break;
            default:
                throw direction.createNotSupportedException();
        }
        if (containingType == null) {
            throw new XOException("Cannot resolve entity type containing a relation of type '" + relationTypeMetadata.getAnnotatedType().getName() + "'.");
        }
        RelationPropertyKey relationPropertyKey = new RelationPropertyKey(containingType, relationTypeMetadata, direction);
        AbstractRelationPropertyMethodMetadata<?> propertyMethodMetadata = relationProperties.get(relationPropertyKey);
        if (propertyMethodMetadata == null) {
            throw new XOException("Cannot resolve property in type '" + containingType.getName() + "' for relation type '" + relationTypeMetadata.getAnnotatedType().getAnnotatedElement().getName() + "'.");
        }
        return propertyMethodMetadata;
    }
View Full Code Here

    }

    @Override
    public Object invoke(Map<String, Object> entity, Object instance, Object[] args) {
        if (!entity.containsKey(name)) {
            throw new XOException("Query result does not contain column '" + name + "'");
        }
        Object value = entity.get(name);
        return value != null ? type.cast(value) : null;
    }
View Full Code Here

TOP

Related Classes of com.buschmais.xo.api.XOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.