Package com.avast.syringe.config.internal

Examples of com.avast.syringe.config.internal.XmlConfig$Decorator


            input = processFreeMarkerTemplate(trimedConfigFileName);
        } else {
            input = new FileInputStream(configFile);
        }

        final XmlConfig xmlConfig;
        try {
            xmlConfig = xmlConfigParser.loadConfig(input);
        } finally {
            input.close();
        }

        Class<?> cls = Thread.currentThread().getContextClassLoader().loadClass(xmlConfig.getClassName());
        ConfigInjector<?> configInjector = ConfigInjector.forClass(cls, converter);

        final String cfgFileName = configFileName;
        instance = (T) configInjector.inject(xmlConfig.getProperties(), new Injection.ContextualPropertyResolver() {
            @Override
            public Object getProperty(InjectableProperty property, Value configValue) throws Exception {
                // Allow injection of this configuration loader
                if (ConfigurationLoader.class.isAssignableFrom(property.getType())) {
                    return ConfigurationLoader.this;
                }

                if (CONFIG_FILE_NAME_PROP.equals(property.getName())) {
                    return cfgFileName;
                }

                String refConfigFile = configValue != null ? configValue.getValue() : null;
                if (refConfigFile != null) {
                    return getReferencedObject(refConfigFile, configFile.getParentFile(), customResolver, converter,
                            enhancer);
                }

                if (customResolver != null) {
                    try {
                        return customResolver.getProperty(property, configValue);
                    } catch (NoSuchFieldException e) {
                        // ok
                    }
                }

                throw new NoSuchFieldException(property.getName());

            }
        });

        T decoratedInstance = instance;
        instance = decorateInstance(decoratedInstance, xmlConfig.getDecorators(), configFile.getParentFile(), customResolver,
                converter, enhancer);

        configInjector.notifyPostConstruct(decoratedInstance);

        if (doRegisterMBeans) {
View Full Code Here

TOP

Related Classes of com.avast.syringe.config.internal.XmlConfig$Decorator

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.