Package com.avast.syringe.config

Examples of com.avast.syringe.config.ConfigException


                try {
                    injection.apply(bean, props, resolver);
                } catch (ConfigException e) {
                    throw e;
                } catch (Exception e) {
                    throw new ConfigException(injection.getProperty().getName(), bean.getClass().getName(), "", e);
                }
            }
            return bean;
    }
View Full Code Here


    private void injectSimple(Object instance, Property prop, ContextualPropertyResolver resolver) throws Exception {
        List<Value> values = prop.getValues();
        if (values.size() > 1) {
            String message = String.format("Property %s takes a single value, but was configured with %s", prop.getName(), prop.getValues());
            throw new ConfigException(prop, instance.getClass(), message, null);
        }

        Value value = prop.getValues().get(0);
        Object val;
        String refType = value.getRefType();
View Full Code Here

    private void injectArray(Object instance, Property prop, ContextualPropertyResolver resolver) throws Exception {
        Class<?> componentType = property.getArrayOrCollectionComponentType();
        if (componentType.isArray()) {
            String message = String.format("Multi-dimensional array property %s is not supported. Only single-dimensional arrays are supported",
                    property.getName());
            throw new ConfigException(prop, instance.getClass(), message, null);
        }

        Object array = property.getValue(instance);
        if (array == null) {
            array = Array.newInstance(componentType, prop.getValues().size());
View Full Code Here

        Collection<Object> collection = (Collection<Object>) property.getValue(instance);
        if (collection == null) {
            if (defaultCollectionClass == null) {
                String message = String.format("Cannot infer a collection implementation for property %s. Initialize it with a concrete empty collection",
                        property.getName());
                throw new ConfigException(prop, instance.getClass(), message, null);
            }
            collection = ConfigInjector.createInstance(defaultCollectionClass);
            property.setValue(instance, collection);
        }
View Full Code Here

TOP

Related Classes of com.avast.syringe.config.ConfigException

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.