Пример #1
0
 public void Start(CoreServiceEngine engine)
 {
     if (this.Status != BindingComponent.NOT_INSTALLED)
     {
         this.Status            = BindingComponent.START_ASKED;
         this.CoreServiceEngine = engine;
         this.Start();
         this.Status = BindingComponent.STARTED;
     }
 }
        /**
         * Configuration load.
         * @param instance of the engine that need the Producers and Consumers config
         *
         */
        public void loadProperty(CoreServiceEngine engine)
        {
            IList <String> producersName      = new List <String>(5);
            IList <bool>   producersInstalled = new List <bool>(5);
            // List<String>
            IList <String> consumersName = new List <String>(5);
            // List<Boolean>
            IList <bool> consumersInstalled = new List <bool>(5);

            // key : name of the producer or consumer. value ArrayList<String> of the dataconverter names
            IDictionary <String, List <String> > dataconverters = new Dictionary <String, List <String> >();

            // looking for the properties file
            String propertiesFilePath = Environment.GetEnvironmentVariable(PROPERTIES_FILE);

            if (propertiesFilePath == null) // fatal no property file
            {
                ExceptionLogger.FatalFormat(PROPERTIES_FILE_MSG, new Object[] { PROPERTIES_FILE });
                throw new FileNotFoundException(PROPERTIES_FILE_MSG, PROPERTIES_FILE);
            }
            FileStream        fs        = null;
            XmlReader         xmlStream = null;
            XmlReaderSettings settings  = new XmlReaderSettings();

            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments   = true;
            try{
                fs        = File.OpenRead(propertiesFilePath);
                xmlStream = XmlReader.Create(fs, settings);
            }catch (FileNotFoundException fnfe) {
                if (fs != null)
                {
                    ExceptionLogger.FatalFormat(PROP_FILE_NOT_FOUND_MSG, new Object[] { propertiesFilePath, fs.Name });
                }
                throw fnfe;
            }

            // Exploiter le stream fs pour lire le XML en LINQ
            XElement xmlConfig = XElement.Load(xmlStream, LoadOptions.PreserveWhitespace);

            // optional property for the thread pool size
            String nbMaxThreadsString = null;

            foreach (string value in xmlConfig.Elements().Where(a => a.Name == NB_MAX_THREADS))
            {
                nbMaxThreadsString = value;
            }

            bool result = int.TryParse(nbMaxThreadsString, out nbMaxThreads);

            if (!result)
            {
                nbMaxThreads = NB_MAX_THREADS_DEFAULT_VALUE;
            }


            // Load the config concerning consumers

            foreach (XElement e in xmlConfig.Elements())
            {
            }



            //// Load the config concerning consumers
            //this.loadBindingComponents(properties,CONSUMER, consumersName, consumersInstalled, dataconverters);
            //// instanciate the array for consumers
            //Consumer[] consumers = new Consumer[consumersName.size()];
            //this.instanciateBindingComponents(consumersName, consumersInstalled, dataconverters, consumers);
            //engine.setConsumers(consumers);

            //// Load the config concerning producers
            //this.loadBindingComponents(properties,PRODUCER, producersName, producersInstalled, dataconverters);
            //// instanciate the array for producers
            //Producer[] producers = new Producer[producersName.size()];
            //this.instanciateBindingComponents(producersName, producersInstalled, dataconverters, producers);
            //engine.setProducers(producers);
        }