Examples of XmlConfig


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

            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

Examples of com.github.jsr330.spi.config.xml.XmlConfig

    public static Test suite() throws Exception {
        ClassAnalyser<Map<String, Class<?>[]>> analyser = new InheritanceAnalyser();
        ClassInjector instancer;
        ClassScanner scanner = new DefaultClassScanner(new RegExSourceDirFilter(".*javax\\.inject-tck-1\\.jar"), null);
       
        XmlConfig config = new XmlConfig(new File("./src/test/resources/tck.xml"));
       
        instancer = new DefaultClassInjector(config.getConfig(Thread.currentThread().getContextClassLoader()));
       
        Injector injector = new Injector(Thread.currentThread().getContextClassLoader(), scanner, analyser, instancer);
        Car car = injector.getInstance(Car.class);
        return Tck.testsFor(car, true, true);
    }
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

        element.setAttribute("type", "group");
      else
        element.setAttribute("type", "field");
    }

    load(new XmlConfig(root),this.root);
  }
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

  public void testXml() throws Exception {
   
    String xml = "<start test1='wow' test2='alf'><sub test1='wow1' test2='alf1'/><sub test1='wow2' test2='alf2'/><sub test1='wow3' test2='alf3'/></start>";
    Document doc = MXml.loadXml(xml);
   
    XmlConfig c = new XmlConfig(doc.getDocumentElement());
   
    derTeschd(c, true);

  }
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

    ConfigBuilder builder = new ConfigBuilder();
   
    String xml = "<start test1='wow' test2='alf'><sub test1='wow1' test2='alf1'/><sub test1='wow2' test2='alf2'/><sub test1='wow3' test2='alf3'/></start>";
    Document doc = MXml.loadXml(xml);
   
    XmlConfig src = new XmlConfig(doc.getDocumentElement());

    HashConfig tar1 = new HashConfig();
    JsonConfig tar2 = new JsonConfig();
    XmlConfig  tar3 = new XmlConfig();
   
    builder.cloneConfig(src, tar1);
    builder.cloneConfig(src, tar2);
    builder.cloneConfig(src, tar3);
   
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

    public void testLifecycle() throws Exception
    {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c name='Test1'/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1 };
      MyBundle b1 = new MyBundle("mybundle", true, ac1 );
     
      List<IModActivator> activators = new LinkedList<IModActivator>();
      manager.initializeBundle(b1,activators);
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

    public void testLifecycleFailInit() throws Exception
    {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c fail_initialize='1'/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1 };
      MyBundle b1 = new MyBundle("mybundle", true, ac1 );
     
      List<IModActivator> activators = new LinkedList<IModActivator>();
      try {
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

    public void testConsistentOn() throws Exception
    {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c id='test1' />").getDocumentElement() ) );
      MyConfig a2 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c id='test2' fail_initialize='1'/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1, a2 };
      MyBundle b1 = new MyBundle("mybundle", true, ac1 );
     
      List<IModActivator> activators = new LinkedList<IModActivator>();
    try {
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

    public void testConsistentOff() throws Exception
    {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      MyConfig a2 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c fail_initialize='1'/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1, a2 };
      MyBundle b1 = new MyBundle("mybundle", false, ac1 );
           
      List<IModActivator> activators = new LinkedList<IModActivator>();
      manager.initializeBundle(b1,activators);
View Full Code Here

Examples of de.mhus.lib.config.XmlConfig

    public void testBundles2() throws Exception
    {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      MyConfig a2 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1, a2 };
      MyBundle b1 = new MyBundle("mybundle", false, ac1 );
     
      List<IModActivator> activators1 = new LinkedList<IModActivator>();
      manager.initializeBundle(b1,activators1);
      assertTrue( activators1.size() == 2 );
      assertTrue( manager.getActivators().size() == 2 );
     
      IModActivator act1 = activators1.get(0);
      assertTrue( act1.getStatus() == IModActivator.STATUS.INITIALIZED );
      manager.enableActivators(activators1);
      assertTrue( act1.getStatus() == IModActivator.STATUS.ENABLED );
      manager.disableActivators(activators1);
     
      MyConfig a3 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      MyConfig a4 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      IModConfig[] ac2 = new IModConfig[] { a3, a4 };
      MyBundle b2 = new MyBundle("mybundle", false, ac2 );
           
      List<IModActivator> activators2 = new LinkedList<IModActivator>();
      manager.initializeBundle(b2,activators2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.