Ejemplo n.º 1
0
 /// <summary>
 /// 初始化插件框架
 /// </summary>
 /// <param name="adaptor"></param>
 internal void Initialize(IFrameworkAdaptor adaptor)
 {
     this.adaptor = adaptor;
     active       = false;
     /* 初始化适配器 */
     adaptor.Initialize();
     try
     {
         adaptor.InitializeStorage();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
     /* 初始化框架属性 */
     InitializeProperties(adaptor.Properties);
     /* 初始化包管理器 */
     packageAdmin = new PackageAdminImpl(this);
     /* 初始化扩展管理器 */
     extensionAdmin = new ExtensionAdmin(this);
     /* 初始化程序集解析器 */
     assemblyResolver = new AssemblyResolvingImpl(this);
     /* 初始化启动级别管理器 */
     startLevelManager = new StartLevelManager(this);
     /* 创建服务注册中心 */
     serviceRegistry = new ServiceRegistry(this);
     /* 创建系统插件 */
     this.CreateSystemBundle();
     /* 为安装的插件创建插件对象. */
     IBundleData[] bundleDatas = adaptor.InstalledBundles.ToArray();
     bundles = new BundleRepository(this);
     /* 添加系统插件到插件仓库 */
     bundles.Add(systemBundle);
     if (bundleDatas != null)
     {
         for (int i = 0; i < bundleDatas.Length; i++)
         {
             try
             {
                 AbstractBundle bundle = AbstractBundle.CreateBundle(bundleDatas[i], this, true);
                 bundles.Add(bundle);
             }
             catch (BundleException be)
             {
                 Log.Debug(be);
                 // This is not a fatal error. Publish the framework event.
                 //publishFrameworkEvent(FrameworkEvent.ERROR, systemBundle, be);
             }
         }
     }
 }
Ejemplo n.º 2
0
        /**
         * Build an array of all installed bundles to be launch.
         * The returned array is sorted by increasing startlevel/id order.
         * @param bundles - the bundles installed in the framework
         * @return A sorted array of bundles
         */
        internal AbstractBundle[] GetInstalledBundles(BundleRepository bundles, bool sortByDependency)
        {
            /* make copy of bundles vector in case it is modified during launch */
            AbstractBundle[] installedBundles;

            lock (bundles)
            {
                IList allBundles = bundles.GetBundles();
                installedBundles = new AbstractBundle[allBundles.Count];
                allBundles.CopyTo(installedBundles, 0);

                /* Sort bundle array in ascending startlevel / bundle id order
                 * so that bundles are started in ascending order.
                 */
                BundleUtil.Sort(installedBundles, 0, installedBundles.Length);
                //if (sortByDependency)
                //    SortByDependency(installedBundles);
            }
            return(installedBundles);
        }