Package com.buschmais.cdo.api

Examples of com.buschmais.cdo.api.CdoException


    }

    private <Instance> InstanceInvocationHandler<Entity> getInvocationHandler(Instance instance) {
        InvocationHandler invocationHandler = Proxy.getInvocationHandler(interceptorFactory.removeInterceptor(instance));
        if (!(invocationHandler instanceof InstanceInvocationHandler)) {
            throw new CdoException("Instance " + instance + " implementing " + Arrays.asList(instance.getClass().getInterfaces()) + " is not a " + InstanceInvocationHandler.class.getName());
        }
        return (InstanceInvocationHandler<Entity>) invocationHandler;
    }
View Full Code Here


        for (Class<?> type : instance.getClass().getInterfaces()) {
            if (targetType.isAssignableFrom(type)) {
                return instance;
            }
        }
        throw new CdoException(instance + " cannot be cast to " + targetType.getName());
    }
View Full Code Here

    }

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

        BeanMethodProvider beanMethodProvider = BeanMethodProvider.newInstance();
        for (Class<?> type : types) {
            Collection<AnnotatedMethod> typeMethodsOfType = beanMethodProvider.getMethods(type);
            for (AnnotatedMethod typeMethod : typeMethodsOfType) {
                if (!(typeMethod instanceof GetPropertyMethod)) {
                    throw new CdoException("Only get methods are supported for projections: '" + typeMethod.getAnnotatedElement().getName() + "'.");
                }
                PropertyMethod beanPropertyMethod = (PropertyMethod) typeMethod;
                GetMethod proxyMethod = new GetMethod(beanPropertyMethod.getName(), beanPropertyMethod.getType());
                addProxyMethod(proxyMethod, beanPropertyMethod.getAnnotatedElement());
            }
View Full Code Here

    @Override
    public Object invoke(E element, Object instance, Method method, Object[] args) throws Exception {
        ProxyMethod<E> proxyMethod = proxyMethods.get(method);
        if (proxyMethod == null) {
            throw new CdoException("Cannot find query for method " + method.getName());
        }
        return proxyMethod.invoke(element, instance, args);
    }
View Full Code Here

    protected void addMethod(ProxyMethod<E> proxyMethod, Class<?> type, String name, Class<?>... argumentTypes) {
        Method method;
        try {
            method = type.getDeclaredMethod(name, argumentTypes);
        } catch (NoSuchMethodException e) {
            throw new CdoException("Cannot resolve method '" + name + "' (" + Arrays.asList(argumentTypes) + ")");
        }
        addProxyMethod(proxyMethod, method);
    }
View Full Code Here

            case OUTGOING:
                return datastorePropertyManager.getTarget(relation);
            case INCOMING:
                return datastorePropertyManager.getSource(relation);
            default:
                throw new CdoException("Unsupported direction: " + direction);
        }
    }
View Full Code Here

    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (entity == null) {
            throw new CdoException("Invalid access to an un-managed instance.");
        }
        return proxyMethodService.invoke(entity, 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 CdoException("Cannot instantiate query method of type " + proxyMethodType.getName(), e);
                    } catch (IllegalAccessException e) {
                        throw new CdoException("Unexpected exception while instantiating type " + proxyMethodType.getName(), e);
                    }
                }
                if (methodMetadata instanceof ResultOfMethodMetadata) {
                    ResultOfMethodMetadata resultOfMethodMetadata = (ResultOfMethodMetadata) methodMetadata;
                    addProxyMethod(new ResultOfMethod(resultOfMethodMetadata, instanceManager, cdoTransaction, interceptorFactory, datastoreSession), typeMethod.getAnnotatedElement());
View Full Code Here

    @Override
    public T getSingleResult() {
        ResultIterator<T> iterator = iterator();
        if (!iterator.hasNext()) {
            throw new CdoException("No result available.");
        }
        try {
            T singleResult = iterator.next();
            if (iterator.hasNext()) {
                throw new CdoException("More than one result available.");
            }
            return singleResult;
        } finally {
            iterator.close();
        }
View Full Code Here

TOP

Related Classes of com.buschmais.cdo.api.CdoException

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.