Beispiel #1
0
        public static void InitConfig(Properties <string, string> config,
                                      string cacheXml, bool PdxReadSerialized)
        {
            string gfcppPropsFile = Util.AssemblyDir + "/gfcpp.properties";

            if (File.Exists(gfcppPropsFile))
            {
                Properties <string, string> newConfig = new Properties <string, string>();
                newConfig.Load(gfcppPropsFile);
                if (config != null)
                {
                    newConfig.AddAll(config);
                }
                config = newConfig;
            }
            //ConnectConfig(dsName, config);
            if (m_cache == null || m_cache.IsClosed)
            {
                try
                {
                    CacheHelper <TKey, TVal> .m_doDisconnect = false;

                    CacheFactory cf = CacheFactory.CreateCacheFactory(config);

                    if (cacheXml != null && cacheXml.Length > 0)
                    {
                        FwkInfo("seting cache-xml-file {0}", cacheXml);
                        cf = cf.Set("cache-xml-file", cacheXml);
                    }

                    if (PdxReadSerialized)
                    {
                        FwkInfo("seting PdxReadSerialized {0}", PdxReadSerialized);
                        cf = CacheFactory.CreateCacheFactory(config)
                             .SetPdxReadSerialized(PdxReadSerialized);
                    }

                    m_cache = cf.Create();
                }
                catch (CacheExistsException)
                {
                    m_cache = CacheFactory.GetAnyInstance();
                }
            }

            m_dsys = m_cache.DistributedSystem;
        }