Package com.buschmais.xo.api

Examples of com.buschmais.xo.api.XOException


    }

    private void addType(Class<?> declaringType, String name, Class<?> type, Type genericType) {
        Class<?> existingType = types.put(name, type);
        if (existingType != null && !existingType.equals(type)) {
            throw new XOException("Get and set methods for property '" + name + "' of type '" + declaringType.getName() + "' do not declare the same type: " + existingType.getName() + " <> " + type.getName());
        }
        Type existingGenericType = genericTypes.put(name, genericType);
        if (existingGenericType != null && !existingGenericType.equals(genericType)) {
            throw new XOException("Get and set methods for property '" + name + "' of type '" + declaringType.getName() + "' do not declare the same generic type: " + existingGenericType + " <> " + type.getName());
        }
    }
View Full Code Here


            case FROM:
                return datastorePropertyManager.getTo(relation);
            case TO:
                return datastorePropertyManager.getFrom(relation);
            default:
                throw new XOException("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 XOException("Unsupported relation type " + fromProperty.getClass().getName());
        }
        return relation;
    }
View Full Code Here

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

                    return invocationContext.proceed();
                } finally {
                    lock.unlock();
                }
            default:
                throw new XOException("Unsupported concurrency mode " + concurrencyMode);
        }
    }
View Full Code Here

    @Override
    public XOManagerFactory createXOManagerFactory(String name) {
        XOUnit xoUnit = xoUnits.get(name);
        if (xoUnit == null) {
            throw new XOException("XO unit with name '" + name + "' does not exist.");
        }
        return createXOManagerFactory(xoUnit);
    }
View Full Code Here

            while (resources.hasMoreElements()) {
                URL url = resources.nextElement();
                for (XOUnit xoUnit : xoUnitFactory.getXOUnits(url)) {
                    XOUnit existingXOUnit = result.put(xoUnit.getName(), xoUnit);
                    if (existingXOUnit != null) {
                        throw new XOException("Found more than one XO unit with name '" + xoUnit.getName() + "'.");
                    }
                }
            }
        } catch (IOException e) {
            throw new XOException("Cannot read xo.xml descriptors.", e);
        }
        return result;
    }
View Full Code Here

        try {
            xoContext = JAXBContext.newInstance(ObjectFactory.class);
            SchemaFactory xsdFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            xoXsd = xsdFactory.newSchema(new StreamSource(XOUnitFactory.class.getResourceAsStream("/META-INF/xsd/xo-1.0.xsd")));
        } catch (JAXBException e) {
            throw new XOException("Cannot create JAXBContext for reading xo.xml descriptors.", e);
        } catch (SAXException e) {
            throw new XOException("Cannot create Schema for validation of xo.xml descriptors.", e);
        }
    }
View Full Code Here

                unmarshaller.setEventHandler(validationHandler);
                Xo xoXmlContent = unmarshaller.unmarshal(new StreamSource(is), Xo.class).getValue();
                if (validationHandler.isValid()) {
                    return xoXmlContent;
                } else {
                    throw new XOException("Invalid xo.xml descriptor detected: " + validationHandler.getValidationMessages());
                }
            } catch (JAXBException e) {
                throw new XOException("Cannot create JAXB unmarshaller for reading xo.xml descriptors.");
            }
        }
    }
View Full Code Here

            String urlName = xoUnitType.getUrl();
            URI uri;
            try {
                uri = new URI(urlName);
            } catch (URISyntaxException e) {
                throw new XOException("Cannot convert '" + urlName + "' to url.");
            }
            String providerName = xoUnitType.getProvider();
            Class<? extends XODatastoreProvider> provider = ClassHelper.getType(providerName);
            Set<Class<?>> types = new HashSet<>();
            for (String typeName : xoUnitType.getTypes().getType()) {
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.