Package com.buschmais.cdo.api

Examples of com.buschmais.cdo.api.CdoException


    @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 proxy for method '" + method.toGenericString() + "'");
        }
        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

    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (datastoreType == null) {
            throw new CdoException("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 CdoException("Cannot instantiate proxy 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(sessionContext, resultOfMethodMetadata), typeMethod.getAnnotatedElement());
View Full Code Here

            case FROM:
                return datastorePropertyManager.getTo(relation);
            case TO:
                return datastorePropertyManager.getFrom(relation);
            default:
                throw new CdoException("Unsupported direction: " + direction);
        }
    }
View Full Code Here

        } else if (toProperty instanceof EntityReferencePropertyMethodMetadata || toProperty instanceof RelationReferencePropertyMethodMetadata) {
            relation = createSingleReference(targetEntity, toProperty, sourceEntity);
        } else if (fromProperty instanceof EntityCollectionPropertyMethodMetadata || fromProperty instanceof RelationCollectionPropertyMethodMetadata) {
            relation = createReference(sourceEntity, fromProperty.getRelationshipMetadata(), fromProperty.getDirection(), targetEntity);
        } else {
            throw new CdoException("Unsupported relation type " + fromProperty.getClass().getName());
        }
        return relation;
    }
View Full Code Here

        if (interceptorFactory.hasInterceptor(instance)) {
            return getInvocationHandler(interceptorFactory.removeInterceptor(instance));
        }
        InvocationHandler invocationHandler = Proxy.getInvocationHandler(instance);
        if (!(invocationHandler instanceof InstanceInvocationHandler)) {
            throw new CdoException("Instance " + instance + " implementing " + Arrays.asList(instance.getClass().getInterfaces()) + " is not a " + InstanceInvocationHandler.class.getName());
        }
        return (InstanceInvocationHandler<DatastoreType>) invocationHandler;
    }
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 CdoException("Unsupported collection type " + collectionPropertyMetadata.getAnnotatedMethod().getType());
        }
        return sessionContext.getInterceptorFactory().addInterceptor(collection);
    }
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 CdoException("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 CdoException("Cannot access instance listener method " + method.toGenericString(), e);
                        } catch (InvocationTargetException e) {
                            throw new CdoException("Cannot invoke instance listener method " + method.toGenericString(), e);
                        }
                    }
                }
            }
        }
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.