Package com.buschmais.xo.api

Examples of com.buschmais.xo.api.XOException


    public void setEntityProperty(ObjectNode objectNode, PrimitivePropertyMethodMetadata<JsonPrimitivePropertyMetadata> metadata, Object value) {
        Class<?> type = metadata.getAnnotatedMethod().getType();
        if (String.class.equals(type)) {
            objectNode.put(metadata.getAnnotatedMethod().getName(), (String) value);
        } else {
            throw new XOException("Unsupported type " + type + " for property " + metadata.getAnnotatedMethod().getName());
        }
    }
View Full Code Here


    private boolean active = false;

    @Override
    public void begin() {
        if (active) {
            throw new XOException("There is already an active transaction.");
        }
        active = true;
    }
View Full Code Here

    @Override
    public Datastore<JsonDatastoreSession, JsonNodeMetadata, String, JsonRelationMetadata, String> createDatastore(XOUnit xoUnit) {
        URI uri = xoUnit.getUri();
        if (!"file".equals(uri.getScheme())) {
            throw new XOException("Only file URIs are supported by this store.");
        }
        try {
            return new JsonFileStore(uri.toURL().getPath());
        } catch (MalformedURLException e) {
            throw new XOException("Cannot convert URI '" + uri.toString() + "' to URL.", e);
        }
    }
View Full Code Here

    @Override
    public void deleteEntity(ObjectNode entity) {
        File file = getFile(entity);
        if (!file.exists()) {
            throw new XOException("Cannot deleteEntity entity '" + entity + "' as it does not exist.");
        }
        file.delete();
    }
View Full Code Here

    public void flushEntity(ObjectNode objectNode) {
        File file = getFile(objectNode);
        try {
            mapper.writeValue(new FileWriter(file), objectNode);
        } catch (IOException e) {
            throw new XOException("Cannot write file " + file.getName(), e);
        }
    }
View Full Code Here

    public void setProperty(ObjectNode objectNode, PrimitivePropertyMethodMetadata<JsonPropertyMetadata> metadata, Object value) {
        Class<?> type = metadata.getAnnotatedMethod().getType();
        if (String.class.equals(type)) {
            objectNode.put(metadata.getAnnotatedMethod().getName(), (String) value);
        } else {
            throw new XOException("Unsupported type " + type + " for property " + metadata.getAnnotatedMethod().getName());
        }
    }
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 XOException("Only get methods are supported for projections: '" + typeMethod.getAnnotatedElement().getName() + "'.");
                }
                PropertyMethod propertyMethod = (PropertyMethod) typeMethod;
                GetMethod proxyMethod = new GetMethod(propertyMethod.getName(), propertyMethod.getType());
                addProxyMethod(proxyMethod, propertyMethod.getAnnotatedElement());
            }
View Full Code Here

    public void init(Collection registeredMetadata) {
        ObjectName objectName = getObjectName();
        try {
            getMBeanServer().registerMBean(traceMonitor, objectName);
        } catch (JMException e) {
            throw new XOException("Cannot register trace monitor MBean for object name " + objectName);
        }
        delegate.init(registeredMetadata);
    }
View Full Code Here

        delegate.close();
        ObjectName objectName = getObjectName();
        try {
            getMBeanServer().unregisterMBean(objectName);
        } catch (JMException e) {
            throw new XOException("Cannot unregister trace monitor MBean for object name " + objectName);
        }
    }
View Full Code Here

    private ObjectName getObjectName() {
        String name = traceMonitor.getXOUnit().getName();
        try {
            return new ObjectName("com.buschmais.xo.trace","xo-unit", name);
        } catch (MalformedObjectNameException e) {
            throw new XOException("Cannot create object name for XO unit " + name);
        }

    }
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.